how to run multiple number of regressions?
4 views (last 30 days)
Show older comments
I have table T with
Date Location Sales Visitors
1/1 NY 10 5
1/1 LA 7 3
1/2 NY 9 5
1/2 LA 4 1
Then I want to run regressions
(sales)=a_i*(visitor)+b_i
for each i = {NY, LA}. Is there any simpler way to do this?
0 Comments
Accepted Answer
dpb
on 29 Jul 2021
tRegress=rowfun(@(x,y)polyfit(x,y,1),T,'GroupingVariables',{'Location'}, ...
'InputVariables',{'Visitors','Sales'}, ...
'NumOutputs',1, ...
'OutputVariableNames',{'Coefficients'});
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!