TypeError: '>=' not supported between instances of 'method' and 'float'

Viewed 42

Thanks to everyone in advance for their time!

I am trying to run a TVP-VAR for a panel in the statespace mlemodels in statsmodel. I get an error while trying to fit the model. My understanding is that mostly is regarding the start paramenters How could I do that ? The type error is showing is as below, highlighted in bold both the error and the Traceback :

 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'

My start parameter definition are as below, although I feel uncombable about my initial parameters. I have not added a return in the denition. In the res module, I use method='nm', where 'nm' stands for Nelder-Mead`solver optimizer

def start_params(self):
       
        start_params =  [.1, .1, 100, 100, 100] 
1 Answers

I have written my code accordingly.I have skipped for the moment the errors

 @property
    def state_names(self):
        state_names = np.empty((self.k_y, self.k_y + 1), dtype=object)
        for i in range(self.k_y):
            endog_name = self.y__names[i]
            state_names[i] = (
                ['intercept.%s' % y_name] +
                ['L1.%s->%s' % (other_name, y_name) for other_name in self.y_names])
        return state_names.ravel().tolist()
    
    
    @property
    def start_params(self):
       return np.r_[0, 0, 1e-5, 1e-5, 1e-5]
   
    
    @property
    def param_names(self):
        return ['level0', 'phi', 'sigma2.ar1', 'sigma2.level', 'sigma2.slope']
    
    
Related