Attempt to grow array along ambiguous dimension - loop error

3 visualizaciones (últimos 30 días)
Daniel Hooker
Daniel Hooker el 11 de Feb. de 2017
Comentada: Geoff Hayes el 11 de Feb. de 2017
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 comentario
Geoff Hayes
Geoff Hayes el 11 de Feb. de 2017
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...

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Creating and Concatenating Matrices en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by