difficulty using the mvregress function

5 vues (au cours des 30 derniers jours)
Andrew Kreitzman
Andrew Kreitzman le 25 Juin 2013
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!

Réponses (1)

the cyclist
the cyclist le 2 Juil 2013
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:

Catégories

En savoir plus sur Descriptive Statistics dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by