【问题标题】:polynomial fit statistics in matlabmatlab中的多项式拟合统计
【发布时间】:2014-03-05 17:14:27
【问题描述】:

我正在使用 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

【问题讨论】:

  • 计算root mean square error? sqrt(mean((pop-pop_fit).^2)) 或者标准化版本可能会更好:sqrt(mean((1-pop_fit./pop).^2))

标签: matlab correlation


【解决方案1】:

您可以使用以下内容:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-03-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-12-17
    相关资源
    最近更新 更多