提前感谢大家的参与!
我正在尝试为statsmodel中的statespace mlmodels中的面板运行TVP-VAR。在尝试拟合模型时出现错误。我的理解是主要与启动参数有关。我该如何操作?显示的类型错误如下,以粗体突出显示了错误和追溯:
preliminary = tvppanelvarmodel.fit(maxiter=1000)
Traceback (most recent call last):
File "/opt/anaconda3/envs/spyder-env/lib/python3.10/site-packages/numpy/core/fromnumeric.py", line 57, in _wrapfunc
return bound(*args,**kwds)
File "/opt/anaconda3/envs/spyder-env/lib/python3.10/site-packages/numpy/core/_methods.py", line 159, in _clip
return _clip_dep_invoke_with_casting(
File "/opt/anaconda3/envs/spyder-env/lib/python3.10/site-packages/numpy/core/_methods.py", line 113, in _clip_dep_invoke_with_casting
return ufunc(*args, out=out,**kwargs)
**TypeError: '>=' not supported between instances of 'method' and 'float'**
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/var/folders/m6/68zljfsj2t9_dzgpwwslj29r0000gp/T/ipykernel_11675/3038987883.py", line 1, in <module>
preliminary = tvppanelvarmodel.fit(maxiter=1000)
File "/opt/anaconda3/envs/spyder-env/lib/python3.10/site-packages/statsmodels/tsa/statespace/mlemodel.py", line 704, in fit
mlefit = super(MLEModel, self).fit(start_params, method=method,
File "/opt/anaconda3/envs/spyder-env/lib/python3.10/site-packages/statsmodels/base/model.py", line 563, in fit
xopt, retvals, optim_settings = optimizer._fit(f, score, start_params,
File "/opt/anaconda3/envs/spyder-env/lib/python3.10/site-packages/statsmodels/base/optimizer.py", line 241, in _fit
xopt, retvals = func(objective, gradient, start_params, fargs, kwargs,
File "/opt/anaconda3/envs/spyder-env/lib/python3.10/site-packages/statsmodels/base/optimizer.py", line 651, in _fit_lbfgs
retvals = optimize.fmin_l_bfgs_b(func, start_params, maxiter=maxiter,
File "/opt/anaconda3/envs/spyder-env/lib/python3.10/site-packages/scipy/optimize/lbfgsb.py", line 197, in fmin_l_bfgs_b
res = _minimize_lbfgsb(fun, x0, args=args, jac=jac, bounds=bounds,
File "/opt/anaconda3/envs/spyder-env/lib/python3.10/site-packages/scipy/optimize/lbfgsb.py", line 298, in _minimize_lbfgsb
x0 = np.clip(x0, new_bounds[0], new_bounds[1])
File "<__array_function__ internals>", line 180, in clip
File "/opt/anaconda3/envs/spyder-env/lib/python3.10/site-packages/numpy/core/fromnumeric.py", line 2152, in clip
return _wrapfunc(a, 'clip', a_min, a_max, out=out,**kwargs)
File "/opt/anaconda3/envs/spyder-env/lib/python3.10/site-packages/numpy/core/fromnumeric.py", line 66, in _wrapfunc
return _wrapit(obj, method, *args,**kwds)
File "/opt/anaconda3/envs/spyder-env/lib/python3.10/site-packages/numpy/core/fromnumeric.py", line 43, in _wrapit
result = getattr(asarray(obj), method)(*args,**kwds)
File "/opt/anaconda3/envs/spyder-env/lib/python3.10/site-packages/numpy/core/_methods.py", line 159, in _clip
return _clip_dep_invoke_with_casting(
File "/opt/anaconda3/envs/spyder-env/lib/python3.10/site-packages/numpy/core/_methods.py", line 113, in _clip_dep_invoke_with_casting
return ufunc(*args, out=out,**kwargs)
TypeError: '>=' not supported between instances of 'method' and 'float'
我的起始参数定义如下,虽然我对我的初始参数感到不太舒服。我没有在定义中添加return。在res模块中,我使用method ='nm',其中'nm'代表Nelder-Mead solver optimizer '
def start_params(self):
start_params = [.1, .1, 100, 100, 100]
1条答案
按热度按时间u0njafvf1#
我已经相应地编写了代码。我暂时跳过了错误