difficulty using the mvregress function
조회 수: 7 (최근 30일)
이전 댓글 표시
I am trying to use the mvregress function to regress stock returns over various style factor weights (8 to be exact) and also a binary variable representing the industry (essentially, we have a 34-column matrix of zeros with one 1 in every row to indicate the industry the equity belongs to. I have grouped the stocks by country, so all of my data (returns, industry factor, and style factors) exist in 1x68 cells, with each matrix representing a different country. I want to use a for loop to iterate over every country when the regression is run. Here is what I tried. I understand how the multivariate regression works in real life, but I am having trouble implementing in MATLAB:
for i = 1:(numel(code_list)-1)
factor_regressor_cell{1,i} = horzcat(industry_cell{1,i},style_factors_cell{1,i});
end
for i = 1:(numel(code_list)-1)
[beta1,~,E,covB,~] = mvregress(factor_regressor_cell{1,i},returns_cell{1,i});
end
I am also getting warnings from MATLAB to preallocate for speed before my for loops, especially those involving cells. Does anyone have a relevant example of how to do this....I was having trouble finding a good exmaple that applied to my code. Thanks!
댓글 수: 0
답변 (1개)
the cyclist
2013년 7월 2일
See my answer to this question
for a simple, commented example of using mvregress. Using the design matrices is admittedly tricky.
There are also examples on the Mathworks site:
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 R Language에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!