Attempt to grow array along ambiguous dimension - loop error

2 次查看(过去 30 天)
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 CenterFile Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by