Attempt to grow array along ambiguous dimension - loop error

조회 수: 2 (최근 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 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