Effacer les filtres
Effacer les filtres

Create multiple regressions for each group of data

2 vues (au cours des 30 derniers jours)
Nabil Benhadda
Nabil Benhadda le 28 Avr 2020
Hello everyone,
I am trying to divide my table data into groups and calculate regression coefficients for each group using the market return and a constant as explainatory/independant variables and the stock market return as the dependant variable.
I have preceeded as follow:
Work = readtable('Begin Work.xlsx');
Work.Groups = findgroups(Work.Numero);
Work.Ones = ones(length(Work.MarketReturn),1);
%X = splitapply(@(x1,x2,y) regress(y,[x1 x2]),Work.Ones,Work.MarketReturn,Work.StockReturn,Work.Groups);
However, I get the following error message:
Error using splitapply (line 132)
The function '@(x1,x2,y)regress(y,[x1,x2])' returned a non-scalar value when applied to the 1st group of data.
To compute nonscalar values for each group, create an anonymous function to return each value in a scalar cell:
@(x1,x2,y){regress(y,[x1,x2])}
Error in BeginWork (line 20)
X = splitapply(@(x1,x2,y) regress(y,[x1 x2]),Work.Ones,Work.MarketReturn,Work.StockReturn,Work.Groups);
Can anyone please help me with this issue? Or recommend another way to calculate the regressions?

Réponses (0)

Catégories

En savoir plus sur Simulink dans Help Center et File Exchange

Produits


Version

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by