Can polyfit give R^2 value for linear fit? How??
Thanks a lot.
-Noob
Noob, it does not compute this directly but you can compute it using the
"normr" field in the output structure. This shows that you get the same
results as from the regstats function in the Statistics Toolbox.
>> load census
>> [p,s] = polyfit(cdate,pop,2);
>> 1 - s.normr^2 / norm(pop-mean(pop))^2
ans =
0.99871296577201
>> regstats(pop, cdate,'quadratic', 'rsquare')
ans =
source: 'regstats'
rsquare: 0.99871296577201
-- Tom