Effacer les filtres
Effacer les filtres

Regress function provides same results regardless of predictors

1 vue (au cours des 30 derniers jours)
aikaterini vraka
aikaterini vraka le 1 Juin 2021
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

Réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by