I reckon this bug might be introduced from the beginning when generate.AR is added. I didn't put much time into this but if I'm understanding it correctly, reg_resid is the remainder after removing the effect of linear predictors, specifically the intercept in AR, then there is no need to *x_sd here and x - xm should be fine.
I first noticed this when I tried to simulate from
tsibbledata::pelt
with AR(2) and got weird values.Created on 2023-06-20 with reprex v2.0.2
I reckon this bug might be introduced from the beginning when
generate.AR
is added. I didn't put much time into this but if I'm understanding it correctly,reg_resid
is the remainder after removing the effect of linear predictors, specifically the intercept inAR
, then there is no need to*x_sd
here andx - xm
should be fine.https://github.com/tidyverts/fable/blob/9b926f8be993594c3ae448b912366aca09ab78d7/R/ar.R#L206