I'm getting a different error variance than regress...

1 次查看(过去 30 天)
Hi All, I'm confused about how the error variance is computed in regress. Why is STATS(4) sometimes larger than var(Y)? Why isn't it always equal to var(Resid)?
clear all;clc;
X=rand(100,3);
Y=rand(100,1);
[B,BINT,R,RINT,STATS] = regress(Y,[ones(size(X,1),1),X]);
varY=var(Y);
varResid=var(Y'-B'*[ones(size(X,1),1),X]');
disp(['var(Y) = ' num2str(varY)]);
disp(['var(Resid) = ' num2str(varResid)]);
disp(['STATS(4) = ' num2str(STATS(4))]);
thanks!

回答(0 个)

Community Treasure Hunt

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

Start Hunting!

Translated by