How to store values from multiple regression
조회 수: 13 (최근 30일)
이전 댓글 표시
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
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Linear Regression에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!