【问题标题】:Covariance matrix of fit parameters with SciPy使用 SciPy 拟合参数的协方差矩阵
【发布时间】:2013-06-24 22:20:33
【问题描述】:

scipy.stats 模块中可用的分布具有 fit 方法 (http://docs.scipy.org/doc/scipy/reference/stats.html) 来估计给定输入数据的分布参数。有没有办法得到拟合参数的协方差矩阵,还是我必须求助于使用scipy.optimize.curve_fit

【问题讨论】:

  • 没有看过代码,但我猜distrib.fit 可能是curve_fit 的封装。
  • 我认为情况并非如此。 curve_fit 使用 Marquardt-Levenberg 算法(非线性最小二乘法)进行拟合。 distrib.fit 方法使用最大似然法。

标签: python scipy


【解决方案1】:

参数估计的协方差需要 Hessian 进行最大似然估计,这在 scipy.stats 中不可用。

statsmodels 有一个通用的最大似然类,我正在修复它,以便它可以处理这样的情况。 (我正在准备拉取请求。固定参数比 scipy.stats.distribution 更难处理。)

http://statsmodels.sourceforge.net/devel/examples/generated/example_gmle.html

mod_par = MyPareto(data)
res = mod_par.fit()
print res.summary()

                               MyPareto Results
==============================================================================
Dep. Variable:                      y   Log-Likelihood:                -149.32
Model:                       MyPareto   AIC:                             306.6
Method:            Maximum Likelihood   BIC:                             317.1
Date:                Sat, 29 Jun 2013
Time:                        11:17:43
No. Observations:                 100
Df Residuals:                      97
Df Model:                           3
==============================================================================
                 coef    std err          z      P>|z|      [95.0% Conf. Int.]
------------------------------------------------------------------------------
shape          2.8604      0.286     10.000      0.000         2.300     3.421
loc           -1.2970   4.48e-06   -2.9e+05      0.000        -1.297    -1.297
scale          3.3032   8.06e-06    4.1e+05      0.000         3.303     3.303
==============================================================================

【讨论】:

    猜你喜欢
    • 2017-03-04
    • 2020-02-12
    • 2022-10-05
    • 1970-01-01
    • 2019-08-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多