【问题标题】:How to compute p value for my fitting function?如何计算拟合函数的 p 值?
【发布时间】:2019-06-04 15:36:52
【问题描述】:

我已将 3 个高斯函数的混合拟合到我的数据中,并且拟合得非常好。我的问题是拟合在数字上的定义有多好。是不是可以用p值来定义。如果是,那么我如何从拟合函数本身进行计算。

   g = fittype( @(c1,c2,p5,p6,p3,p4,p1,p2, x) (c1)*(1/(p6*sqrt(2*pi)))*exp(-((x-p5).^2)./(2*(p6.^2))) + ...
   (c2)*(1/(p4*sqrt(2*pi)))*exp(-((x-p3).^2)./(2*(p4.^2))) + ...
    (1-c1-c2)*(1/(p2*sqrt(2*pi)))*exp(-((x-p1).^2)./(2*(p2.^2)))       );

 %xr and yr is data (basically normalized histogram) 
[fE,GE,O] = fit(xr',yr',g,'StartPoint',startingVals);

%O gives me following quantity. 
        numobs: 50
         numparam: 8
    residuals: [50×1 double]
     Jacobian: [50×8 double]
     exitflag: 3
firstorderopt: 7.763960157882235e-04
   iterations: 24
    funcCount: 225
 cgiterations: 0
    algorithm: 'trust-region-reflective'
     stepsize: 0.002272922321389
      message: 'Success, but fitting stopped because change in residual…'

这里没有 p 值。如何计算谢谢。

【问题讨论】:

    标签: matlab p-value


    【解决方案1】:

    您可以使用corrcoef 函数参见matlab documentation

    基本上,如果您有数据y,以及拟合函数Y 的预测数据,您只需:

    [R,p] = corrcoef(y, Y);
    

    这将为您提供 R 值,以及高斯拟合后数据与预测数据之间相关性的 p 值,因此基本上您的拟合效果如何。

    yY必须对应同一个输入值:

    假设f 是您数据的“函数”。它验证 y = f(x),(对于x 的每个值,您都有一个测量值y)。

    那么你必须有Y = f_fitted(x),其中f_fitted是你适合的高斯函数。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-11-24
      • 1970-01-01
      • 2015-06-14
      • 1970-01-01
      • 2017-12-20
      • 1970-01-01
      • 1970-01-01
      • 2014-04-13
      相关资源
      最近更新 更多