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!