繁体   English   中英

Matlab中的多项式拟合统计

[英]polynomial fit statistics in matlab

我正在使用mathowrks示例计算多项式拟合:

load census
figure
plot(cdate,pop,'ro')
corrcoef(cdate,pop)

figure
% Calculate fit parameters
[p,ErrorEst] = polyfit(cdate,pop,2);
% Evaluate the fit
pop_fit = polyval(p,cdate,ErrorEst);
% Plot the data and the fit
plot(cdate,pop_fit,'-',cdate,pop,'+');
% Annotate the plot
legend('Polynomial Model','Data','Location','NorthWest');
xlabel('Census Year');
ylabel('Population (millions)');

在此处输入图片说明

如何找到这种拟合的相关性? 通过简单的线性关系,我可以使用corrcoef来计算拟合度,但是在mathworks网站上,他们只提到“他的下图显示二次多项式拟合度可以很好地近似数据”,但是没有涉及任何统计信息。

谁能建议一种方法?

http://www.mathworks.co.uk/help/matlab/data_analysis/programmatic-fitting.html

您可以使用以下内容:

ft_ = fittype('poly2');
[cf,gf,o] = fit(cdate,pop,ft_)

当我这样做时,我的结果是:

cf = 

     Linear model Poly2:
     cf(x) = p1*x^2 + p2*x + p3
     Coefficients (with 95% confidence bounds):
       p1 =    0.006541  (0.006124, 0.006958)
       p2 =      -23.51  (-25.09, -21.93)
       p3 =  2.113e+004  (1.964e+004, 2.262e+004)

gf = 

           sse: 159.029299176792
       rsquare: 0.998712965772009
           dfe: 18
    adjrsquare: 0.998569961968899
          rmse: 2.97236624011533


o = 

        numobs: 21
      numparam: 3
     residuals: [21x1 double]
      Jacobian: [21x3 double]
      exitflag: 1
     algorithm: 'QR factorization and solve'
    iterations: 1

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM