필터 지우기
필터 지우기

Create multiple regressions for each group of data

조회 수: 2 (최근 30일)
Nabil Benhadda
Nabil Benhadda 2020년 4월 28일
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?

답변 (0개)

카테고리

Help CenterFile Exchange에서 Simulink에 대해 자세히 알아보기

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by