0

I would like to define a state space representation of a model with a nonzero drift term in statsmodels. The documentation for the state state representation framework appears to assume that the stochastic terms (epsilon and eta) have zero mean:

statsmodels documentation for state space representations

Is there a way to introduce (and then set as parameters) a mean drift term to these stochastic processes in the state space representation? Perhaps by adding them to the intercept matrices c_t and d_t?

Thank you!

tom_servo
  • 308
  • 1
  • 15

1 Answers1

1

Yes, you can add a constant term to either equation by placing values into obs_intercept or state_intercept.

self.ssm['obs_intercept', 0] = 1.4

If the parameter is being estimated, then you would do this in the update method.

def update(self, params, **kwargs):
    params = super().update(params, **kwargs)

    self.ssm['obs_intercept, 0] = params[0]

Finally, the intercepts can be time-varying, so if you wanted the constant term to show a linear trend, you could do:

def __init__(self, endog, ...):
    ...

    # (note that by default the intercept terms are not time-varying.
    # If you want to set them to be time-varying, it is usually best
    # to do that in the constructor)
    self['obs_intercept'] = np.zeros((self.k_endog, self.nobs))

    ...

def update(self, params, **kwargs):
    params = super().update(params, **kwargs)

    self.ssm['obs_intercept', 0, :] = (
        params[0] * np.arange(1, self.nobs + 1))
cfulton
  • 2,855
  • 2
  • 14
  • 13
  • Is adding a term to d_t (let's call it mu) equivalent to making epsilon_t ~ N(mu, H_t) instead of N(0, H_t)? – tom_servo Nov 05 '22 at 11:06
  • 1
    Yes, that is correct and, as you probably suspected, just follows from the usual properties of a Normal distribution. – cfulton Nov 05 '22 at 19:03