How to store values from multiple regression
13 views (last 30 days)
Show older comments
Hi,
I am trying to perform a multiple linear regression: Y = a + bX + e
The dependent variable Y is 16x18 (each column is a time series), the independent variable X is 16x2 (again, each column is a time series and I have 2 variables). I want to regress first column of Y on both columns of X then second column of Y on both columns of X and so on. The constant term, a and the coefficient b should be allowed to change in each regression. In addition, I need to save the resulting a (1x18), b (2x18 for each regression) and e matrices and also find the f-stat, p-value and R2.
The code I am tring is the following:
for i = 1:18
Y = qEMP(:,i);
X = [ones(16,1), k1(:,1:2)];
[beta, bint,r,rint,stats] = regress(Y,X);
end
k1 includes my 2 variables.
This code generates one constant term and 2 coefficients and 16 residuals for the entire regression. However, I need to store constant a, coefficients b and residuals e that results from each and every iteration. Thanks in advance.
0 Comments
Answers (0)
See Also
Categories
Find more on Linear Regression in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!