Last chance! 50% off unlimited learning
Sale ends in
Fits ARIMA models (including improved diagnostics) in a short command. It can also be used to perform regression with autocorrelated errors. This is a front end to arima()
with a different back door.
sarima(xdata, p, d, q, P = 0, D = 0, Q = 0, S = -1,
details = TRUE, xreg=NULL, Model=TRUE,
fixed=NULL, tol = sqrt(.Machine$double.eps),
no.constant = FALSE)
univariate time series
AR order (must be specified)
difference order (must be specified)
MA order (must be specified)
SAR order; use only for seasonal models
seasonal difference; use only for seasonal models
SMA order; use only for seasonal models
seasonal period; use only for seasonal models
Optionally, a vector or matrix of external regressors, which must have the same number of rows as xdata.
if TRUE (default), the model orders are printed on the diagnostic plot.
optional numeric vector of the same length as the total number of parameters. If supplied, only parameters corresponding to NA entries will be estimated.
if FALSE, turns off the diagnostic plot and the output from the nonlinear optimization routine, which is optim
. The default is TRUE.
controls the relative tolerance (reltol in optim
) used to assess convergence. The default is sqrt(.Machine$double.eps)
, the R default.
controls whether or not sarima includes a constant in the model. In particular, if there is no differencing (d = 0 and D = 0) you get the mean estimate. If there is differencing of order one (either d = 1 or D = 1, but not both), a constant term is included in the model. These two conditions may be overridden (i.e., no constant will be included in the model) by setting this to TRUE; e.g., sarima(x,1,1,0,no.constant=TRUE)
. Otherwise, no constant or mean term is included in the model. If regressors are included (via xreg
), this is ignored.
the arima
object
Error degrees of freedom
a little t-table with two-sided p-values
value of the AIC - all ICs are the values reported in fit
divided by the essential number of observations (after differencing)
value of the AICc
value of the BIC
If your time series is in x and you want to fit an ARIMA(p,d,q) model to the data, the basic call is sarima(x,p,d,q)
. The values p,d,q, must be specified as there is no default. The results are the parameter estimates, standard errors, AIC, AICc, BIC (as defined in Chapter 2) and diagnostics. To fit a seasonal ARIMA model, the basic call is sarima(x,p,d,q,P,D,Q,S)
. For example, sarima(x,2,1,0)
will fit an ARIMA(2,1,0) model to the series in x, and sarima(x,2,1,0,0,1,1,12)
will fit a seasonal ARIMAsarima()
and arima()
is that they differ by a scaling factor of the effective sample size.
http://www.stat.pitt.edu/stoffer/tsa4/ and http://www.stat.pitt.edu/stoffer/tsda/
# NOT RUN {
sarima(log(AirPassengers),0,1,1,0,1,1,12)
(dog <- sarima(log(AirPassengers),0,1,1,0,1,1,12))
summary(dog$fit) # fit has all the returned arima() values
plot(resid(dog$fit)) # plot the innovations (residuals)
sarima(log(AirPassengers),0,1,1,0,1,1,12,details=FALSE)$BIC # print model BIC only
# fixed paramters
x = arima.sim(list(order=c(2,0,0), ar=c(0,-.9)), n=200) + 50
sarima(x, 2,0,0, fixed=c(0,NA,NA))
# }
Run the code above in your browser using DataLab