Attempt to grow array along ambiguous dimension - loop error

3 ビュー (過去 30 日間)
Daniel Hooker
Daniel Hooker 2017 年 2 月 11 日
コメント済み: Geoff Hayes 2017 年 2 月 11 日
I am trying to calculate standard errors in a loop of regressions that I am performing on mutual funds however when i try to run my code o get the 'Attempt to grow array along ambiguous dimension' error message.
Here is my coding so far:
[r,c]=size(FR);
alpha=zeros(c,1);
x=FR(:,i);
y=isnan(x);
sy=sum(y);
x=x((sy+1):end);
lx=length(x);
X=zeros(lx,5);
X(:,1)=ones(lx,1);
X(:,2:5)=C4F((sy+1):end,:);
beta=inv(X'*X)*X'*x;
alpha(i)=beta(1);
X(:,1) = alpha(lx,1);
CM(i) = cov(X(i));
SE(i) = diag(sqrt(CM(i)));
end
I know that the error first relates to the line 'CM(i) = cov(X(i));' however I am unsure what other way there is to obtain the covariance matrix for every fund in my sample (1600 funds). Does anyone know a way to achieve this or correct my current problem?
Thanks in advance!
  1 件のコメント
Geoff Hayes
Geoff Hayes 2017 年 2 月 11 日
Daniel - I think that you have omitted some of your code. Do you have a for or while loop? What is CM initialized to? What are the dimensions of cov(X(i)) as it might not be a scalar that you are assuming it to be...

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

回答 (0 件)

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by