I am trying to generate non-zero mean AR(2) samples using statsmodels package. But it seems , by default we can't generate non-zero mean samples.
Is there any workaround, in python. I want to generate only positive samples.
My current code is
import numpy as np
from statsmodels.tsa.arima_process import ArmaProcess
rng = np.random.default_rng(12345)
ar_1 = np.array([2, -0.25, -0.25])
ar_2 = np.array([2, -0.5, -0.25])
ma1 = np.array([1])
ar1_proc = ArmaProcess(ar_1, ma1)
ar1_dat = ar1_proc.generate_sample(nsample=2*60*60, distrvs=rng.lognormal)
ar2_proc = ArmaProcess(ar_2, ma1)
ar2_dat = ar2_proc.generate_sample(nsample=2*60*60, distrvs=rng.lognormal)
i'm a bit confused by your question. Since you are using
istrvs=rng.lognormalthat should be enough to ensure no negative values.To check this I have wrapped up your code in a Monte-Carlo simulation loop.
which took just over a minute on my machine and the result was: 0.004882878764670938