statsmodels.regression.linear_model.OLSResults.el_test

OLSResults.el_test(b0_vals, param_nums, return_weights=0, ret_params=0, method='nm', stochastic_exog=1)[source]

使用经验似然检验单一或联合假设。

Parameters:
b0_vals1darray

要检验的参数的假设值。

param_nums1darray

要测试的参数编号。

return_weightsbool

如果为真,返回在b0_vals处优化似然比权重的值。默认值为False。

ret_paramsbool

如果为真,返回在b0_vals处最大化似然比率的参数向量。同时返回权重。默认值为False。

methodstr

可以是‘nm’表示Nelder-Mead或‘powell’表示Powell。 优化方法,用于优化过扰参数。 默认值是‘nm’。

stochastic_exogbool

当为True时,假定外生变量是随机的。 当回归变量是非随机的时,在外生变量上放置矩条件。 随机回归变量的置信区间至少与非随机回归变量一样大。默认值为True。

Returns:
tuple

假设值的p值和-2倍的对数似然比。

示例

>>> import statsmodels.api as sm
>>> data = sm.datasets.stackloss.load()
>>> endog = data.endog
>>> exog = sm.add_constant(data.exog)
>>> model = sm.OLS(endog, exog)
>>> fitted = model.fit()
>>> fitted.params
>>> array([-39.91967442,   0.7156402 ,   1.29528612,  -0.15212252])
>>> fitted.rsquared
>>> 0.91357690446068196
>>> # Test that the slope on the first variable is 0
>>> fitted.el_test([0], [1])
>>> (27.248146353888796, 1.7894660442330235e-07)

Last update: Oct 16, 2024