Regress function provides same results regardless of predictors
1 次查看(过去 30 天)
显示 更早的评论
Hi all,
I am trying to calculate the linear regression (R squared, p-value) of two variables w and z, once by using variable w as predictor and then using variable z as the predictor. I have written the following script:
%a-predictor
%b-response
a=a';
b=b';
x1=ones(size(a,1),1);
X=[x1 a];
y=b;
[~,~,~,~,stats2] = regress(y, X);
R2=stats2(1);
p2=stats2(3);
reg=[R2 p2];
where I interchange variables a and b being the former firstly "w" and then "z" and the opposite for the latter. However, in either cases I get the same values for R2 and p2. When I try with "Regression Learner App" I do get different values for the two cases. Does anybody know what's going on?
Thanks in advance!
Katerina
0 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Linear and Nonlinear Regression 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!