Description
I simulate data from a simple integrated random walk model defining the initial state, the measurement disturbance standard deviation (here, I set it equal to 0), and the trend disturbance standard deviation. Given these parameters, the simulated data should be close to a straight line. However, is looks completely different. Therefore, I used statsmodel to simulate the data using the same initial state and disturbance standard deviations. Also the random generator is initialized the same in both simulations. The simulate dataset from statsmodel is close to a straight line as expected. Therefore, I wonder whether there is something wrong in simulate_from_numpy_model. Here is the code:
measurement_error = st.MeasurementError(name="obs")
IRW = st.LevelTrendComponent(order=2, innovations_order=[0, 1])
param_dict = {
"initial_trend": [0., 0.01], "sigma_trend": np.array([np.sqrt(5e-7)]),
"sigma_obs": np.array([0.]),
}
mod = IRW + measurement_error
nobs = 1024 # we simulate a time series of length Nobs
x, y = simulate_from_numpy_model(mod, np.random.default_rng(2163), param_dict, steps=nobs)
And here is the code from statsmodel:
model = sm.tsa.UnobservedComponents(y, level=True, stochastic_level=False, trend=True, stochastic_trend=True, irregular=True)
res = model.fit()
y_sim = model.simulate(initial_state = [0., 0.01], params=[0., 5e-7], nsimulations=nobs, random_state=np.random.default_rng(2163))
y and y_sim have nothing common. Whereas y_sim represents a slight deviation from the straight line, y is completely different, with a strong negative slope, though the undisturbed slope is positive. Attached the simulated data in both cases.