# how does R ensure stationarity and invertibility when fitting an ARIMA model?

In the Forecasting: principles and practice book they claim that:

R ensures the fitted model is both stationary and invertible

I checked and indeed - for example the following model fits, even though the data are not stationary and I should have differenced:

library(fpp2)
fit2 <- arima(taylor, order=c(1,0,1),
include.mean = TRUE, transform.pars=FALSE)
1/forecast:::arroots(fit2)$roots autoplot(fit2)  and the AR inverse root is 0.9813966+0i, which is a bad sign according to the text. but HOW do they do it? When I try fitting the same model with python's statsmodels it fails. What's the technique used for ensuring stationarity and invertibility? Note that transform.pars=FALSE so it's not that. • See my answer at stats.stackexchange.com/a/432342/919, which includes code for changing a non-invertible MA model into an invertible one. – whuber Nov 2 '19 at 19:29 • thanks! what do you mean by using the reciprocals of the roots inside the unit circle and rescaling the polynomial to have a constant term of 1? can you be more specific about what to do and why will it always work – ihadanny Nov 2 '19 at 21:18 • My answer was very specific about that by providing code to carry out the calculations (which is only two lines long!). "Rescaling" means multiplying by a constant, as executed by the line coeff <- Re(p[-1] / p[1]). This multiplies the polynomial$p_0+p_1t + \cdots + p_kt^k$by$1/p_0$and drops the constant term (which, since it's$1\$ by construction, doesn't need to be carried around). The reason for taking the real part via Re is only to coerce the data type of the coefficients to double-precision numbers; they will already be real numbers. – whuber Nov 2 '19 at 22:07
• @whuber - ok, I now understand the mechanism you suggest for transforming a non-invertible process to an invertible one. I understand that this will preserve the statistical properties of the process (i.e. the mean and the auto-covariance), but won't it be a different process than the one we fitted? Won't the residuals be different and the quality of our fit to the data be different? – ihadanny Nov 6 '19 at 7:32
• Actually not. The fit and residuals will not differ. That's why the various versions of the process cannot be distinguished by the data alone. – whuber Nov 6 '19 at 13:39