I am trying to do a cross sectional regression and i get the error The expression to the left of the equals sign is not a valid target for an assignment. What should i do?
>> %whole sample CAPM
returns=xlsread('Stock Returns','B2:AE321');
factors=xlsread('Factors','B2:E321');
T=min(size(factors,1),size(returns,1));
beta=ones(30,2);
%Step 1:Time-series regression]
for i=1:30
alpha=[ones(T,1) factors(:,1)];
Y=returns(:,i)-factors(:,4);
coefficients(i,:)=(alpha\Y);
end
%Step 2:Cross-sectional regression
Market_Premium=ones(T,2);
for n=1:T
alpha01=[ones(30,1) coefficients(:,2)
Y=(returns(n,:)-factors(t,4))';
Y=(returns(n,:)-factors(t,4))';
Error: The expression to the left of the equals sign is not a valid target for an assignment.

 採用された回答

dpb
dpb 2017 年 11 月 24 日

0 投票

...
alpha01=[ones(30,1) coefficients(:,2)
Y=(returns(n,:)-factors(t,4))';
The opening [ of the first line isn't terminated so the next line is interpreted as if you'd typed in
alpha01=[ones(30,1) coefficients(:,2) Y=(returns(n,:)-factors(t,4))';
Fix the typo; the editor should have flagged a line there I'd think...
alpha01=[ones(30,1) coefficients(:,2)];

1 件のコメント

Loukas Politikos
Loukas Politikos 2017 年 11 月 24 日
thank you very much!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by