简体   繁体   English

statsmodels 的 MLEModel class 是否使用期望最大化进行拟合?

[英]is statsmodels' MLEModel class using Expectation Maximization for fitting?

I am building a custom stat space model using statsmodels ' MLEModel class, and fitting the unknown parameters with the .fit() method.我正在使用statsmodelsMLEModel class 构建自定义统计空间 model,并使用.fit()方法拟合未知参数。 I thought that it was using Expectation Maximization, but I am not sure of that and I cannot find any hint to this in the documentation.我认为它正在使用期望最大化,但我不确定,我在文档中找不到任何提示。 Moreover, the verbose output of the .fit() method shows the steps of a single optimization, and this makes me even more doubtful.而且.fit()方法的冗长的output显示了单个优化的步骤,这让我更加怀疑。

If it is not using EM, what is it doing?如果它不使用 EM,它在做什么? maybe I am missing something here, but I thought that for models with hidden variables (like state space models) you cannot directly minimize the likelihood (since you don't know and don't observe the hidden states).也许我在这里遗漏了一些东西,但我认为对于具有隐藏变量的模型(如 state 空间模型),你不能直接最小化可能性(因为你不知道也不观察隐藏状态)。

thanks for any suggestion感谢您的任何建议

By default, MLEModel uses a quasi-Newton approach to numerically find parameters that maximize the likelihood function.默认情况下, MLEModel使用准牛顿方法以数值方式查找最大化似然 function 的参数。 Ultimately, it relies on the Scipy minimize function.最终,它依赖于Scipy minimize function。 The default algorithm is the BFGS algorithm , but you can select others using the method argument.默认算法是BFGS 算法,但您可以使用method参数 select 其他人。 For example, method='nm' uses the Nelder-Mead algorithm .例如, method='nm'使用Nelder-Mead 算法

The Statsmodels state space framework provides all the tools (eg the appropriate smoothers) to use the EM algorithm, but you would have to implement it yourself. Statsmodels state 空间框架提供了使用 EM 算法的所有工具(例如适当的平滑器),但您必须自己实现它。 For example, the EM algorithm is the default method used to fit the DynamicFactorMQ model, because it has a large number of parameters, and quasi-Newton methods can be slow and unreliable for such problems.例如,EM 算法是用于拟合DynamicFactorMQ model 的默认方法,因为它具有大量参数,而准牛顿方法对于此类问题可能会很慢且不可靠。

In general, fit() is a method of the model class.一般来说, fit()是 model class 的方法。 Depending on the class object the method fit() from that class will be called.根据 class object 的方法 fit() 从 class 将被调用。 In general, fit() estimates parameters via maximum likelihood and return a results object.一般来说,fit() via maximum likelihood估计参数并返回结果 object。

The expectation maximization (EM) algorithm requires and uses the Kalman smoother for models with hidden variables if I'm not mistaken.如果我没记错的话, expectation maximization (EM)算法需要并使用Kalman smoother器来处理具有隐藏变量的模型。

EDIT: fit() will cal the fit() of its parent class which in this case is tsbase.TimeSeriesModel as seen in class MLEModel(tsbase.TimeSeriesModel) .编辑: fit() 将调用其父 class 的 fit() ,在这种情况下是tsbase.TimeSeriesModelclass MLEModel(tsbase.TimeSeriesModel) In turn, class TimeSeriesModel(base.LikelihoodModel) will call its parent class which is base.LikelihoodModel .反过来, class TimeSeriesModel(base.LikelihoodModel)将调用其父 class ,即base.LikelihoodModel class LikelihoodModel(Model)'s fit() function default method argument is 'newton' . class LikelihoodModel(Model)'s fit() function默认方法参数是'newton' Thus, Maximum likelihood (ML) estimation will be estimated using Newton's method in this custom state space model.因此,最大似然 (ML) 估计将在此自定义 state 空间 model 中使用牛顿法进行估计。

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

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