필터 지우기
필터 지우기

Regress function provides same results regardless of predictors

조회 수: 1 (최근 30일)
aikaterini vraka
aikaterini vraka 2021년 6월 1일
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개)

Community Treasure Hunt

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

Start Hunting!

Translated by