필터 지우기
필터 지우기

Problems with regstats: more predictor variables than observations

조회 수: 1 (최근 30일)
Michela
Michela 2016년 5월 12일
편집: dpb 2016년 5월 12일
Hello, I have some problems with the calculation of the parameters of a regression. More precisely, I have a sample of N observations (monthly observations) and K assets (the last one is the market) and I need to find the alpha and beta (as the CAPM do:(Rportfolio-Rfree_risk)=(Rmarket-Rfree_risk)beta) for each period (hence, I need to have N alphas and N betas). I have written this function:
function [Alpha,Beta,EqReturns,EqVarCovar]=CAPM(RetMarket,RetAssets,VarMarket)
for k=1:size(RetAssets,1);
for i=1:size(RetAssets,2);
out(k,:)=regstats(RetAssets(k,i),RetMarket(k,:),'linear',{'beta','r','rsquare'});
Alpha(i,k)=out(k,:).beta(1);
Beta(i,k)=out(k,:).beta(2);
R2(i,k)=out(k,:).rsquare;
Resid(k,i)=out(k,:).r;
EqRet(i,k)=out(k,:).beta(2)*(RetMarket(k,:));
end
EqReturns(k,i)=eqret(i,k)';
EqVarCovar(:,:,k)=Beta(:,k)*(Beta(:,k)')*VarCovarMarket(k,:)+diag(diag(cov(Resid(k,:))));
end;
end
where RetMarket is Nx1, RetAssets is NxK and VarMarket is Nx1.
Is there someone who can explain me where is my error?? Thanks!!!

답변 (1개)

dpb
dpb 2016년 5월 12일
편집: dpb 2016년 5월 12일
In
out(k,:)=regstats(RetAssets(k,i),RetMarket(k,:),'linear',{'beta','r','rsquare'});
RetAssets(k,i) is always only a single point and RetMarket(k,:) is also if size(RetMarket) is Nx1 as stated.
To fit a linear regression you'll have to have at least two points for the x and y vectors. In general, of course, one would have at least one extra DOF and generally quite a few more than that.
It's not clear what you would mean for each period; at first I thought you were likely meaning a regression for each of the k "assets" but then you explicitly state N sets of coefficients so I'm at a loss what that would be (unless it's a point-to-point return as compared to the previous month, maybe??? If that were so, it's just a ratio of the two successive values for percentage but if is actually a regression it'd be the specific line between the two point values).

카테고리

Help CenterFile Exchange에서 Model Building and Assessment에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by