Next: arimahelp() Up: Arima Macros Help File Previous: acfarma()   Contents


arima(y [,pdq:vector(p,d,q)] [,PDQ:vector(P,D,Q),seasonal:period]\
  [,x:x,fitmean:T, start:b0,active:active,cast:n, cycles:m,mle:T,\
  mlecycles:m1, masign:Masign, arsign:Arsign, maxit:itmax, minit:itmin,\
  crit:vector(numsig, nsigsq, delta), print:T,keep:T,quiet:T]),
  REAL vector y, REAL variable x, nonnegative integers p, d, q, P, D, Q,
  period > 1, cast, n, m, m1, REAL vector b0, LOGICAL vector active with
  length(active) = length(b0), Masign and Arsign +1 or -1, integers
  itmax, itmin, numsig, nsiqsq, REAL scalar delta >= 0

Keywords: arima models, time domain, nonlinear fitting
arima(y [,pdq:vector(p,d,q)] [,PDQ:vector(P,D,Q),seasonal:Period]),
where y is a REAL vector with no MISSING values and p, d, q, P, D, Q
are non-negative integers and Period > 1 is an integer, uses
unconditional least squares to estimate the parameters of an
ARIMA(p,d,q)x(P,D,Q) time series model, with season length Period.

When d = D = 0, a non-zero mean is fit; otherwise no mean is fit.
Keyword 'seasonal' is required when keyword 'PDQ' is used.

arima(y, x:x [,pdq:vector(p,d,q)] [,PDQ:vector(P,D,Q),seasonal:Period])
does the same, except a linear regression with ARIMA errors of y on the
columns of REAL matrix x is carried out.  x must have no MISSING
elements and nrows(x) = nrows(y).  It should not include a constant

arima(y [, x:x], pdq:pdq, PDQ:PDQ, mle:T) does the same, except maximum
likelihood estimation is used instead of unconditional least squares.

You can use keywords 'minit', 'maxit', 'cast', 'cycles', and 'mlecycles'
to control certain details of the estimation algorithm.  See below for
more information.

You can use keywords 'masign' and 'arsign' or define variables MASIGN
and ARSIGN to control the sign conventions assumed for moving average
and autoregressive coefficients.  See below and topic 'MASIGN' for

The model coefficients estimated include some or all of the following:
   mu     mean (of differenced data when d > 0 or D > 0)
   beta   vector of coefficients of columns of x, if any
   phi    vector of AR coefficients
   theta  vector of MA coefficients
   phiS   vector of seasonal AR coefficients
   thetaS vector of seasonal MA coefficients.

They are grouped in a coefficient vector b = vector(mu, beta, phi,
theta, phiS, thetaS), omitting any coefficients not in the model.

You can provide starting values using keyword 'start'; see below.

To force inclusion of mu when d > 0 or D > 0, use 'fitmean:T' as an
argument.  To force exclusion of mu when d = D = 0, use 'fitmean:T'.
See below.

You can omit certain coefficients from being included in the estimation
algorithm using keyword 'active'; see below.  This is useful when
fitting models using a subset of lags.  Any starting values you provide
for them (non-zero starting value for mu) using 'start' are not changed
but will be used in computing residuals.

When mu is in the model, but is not an active parameter, it is estimated
by the sample mean of the possibly differenced data unless a non-zero
starting value is given.

arima() prints a table of the estimated coefficients, their approximate
standard errors, t = coef/StdErr, and a nominal P-value based on the t
distribution.  It also prints the mean square error (MSE), its degrees
of freedom (DF), -2*log(L), where L = likelihood, a modification of
Akaike's information critirion (AICC), and the complete sum of squared
residuals, including backcast values, if any (RSS).  Printing can be
suppressed by either quiet:T or keep:T; see below.  Side effect
variables are always produced; see below.

DF = n - d - D*Period - (number of parameters being estimated).  When mu
is estimated by a sample mean, it counts as a parameter, even if it is
not active in the optimization (active[1] is false).

arima() creates the following side effect variables
  COEF = bhat = vector(muhat,betahat,phihat,thetahat,phiShat,thetaShat),
    omitting any coefficients not in the model.  When coefficient b[i]
    is inactive (seek keyword 'active' below), COEF[i] = the starting
    value, if any, or 0.
  ALLRESIDUALS = residuals from fitted model including incomplete and
    backcast residuals
  RESIDUALS = ALLRESIDUALS, omitting backcast and incomplete residuals
  NEG2LOGL = -2*log(likelihood) assuming a Gaussian series.  The likeli-
    hood includes a factor of (2*PI)^((n-d-D*Period)/2)
  NPAR = number of active parameters plus 1 for the mean if estimated
    as sample mean.  The active parameters correspond to rows k of
    XTXINV with XTXINV[k,k] != 0
  JACOBIAN = REAL matrix of derivatives of ALLRESIDUALS with respect to
   active parameters.
  XTXINV = analogue of solve(X' %*% X) matrix in regression computed
   from JACOBIAN, with rows and columns corresponding to inactive
   parameters set to 0
  HII, REAL vector of leverages of length n - d - D*Period, computed
   from JACOBIAN
  GRADIENT = REAL gradient vector (approximation to to partial
   derivatives sum of squares or log likelihood with respect to the
   coefficients) with an element for each active parameter

The innovation variances is estimated as MSE = RSS/(n-d-D*Period-NPAR).
MSE is used to compute estimated standard errors as

When there is no seasonal part to the model and no omitted lags, you may
be able to speed convergence by finding starting values using macros
hannriss() or innovest() and providing them to arima() using keyword
'start' (see below).

Other ARIMA estimation programs may differ in what is computed as the
estimated innovation variance.  Two alternatives to MSE as computed by
arima() are sum^2(ALLRESIDUALS)/DF and
sum(ALLRESIDUALS^2)/(n-d-D*Period), the maximum likelihood estimate.

Programs also may differ in sign conventions used for the autoregressive
and moving average coefficients.  In arima(), the signs are determined
either by variables MASIGN and ARSIGN (defaults are -1 and -1) or the
value of keywords 'arsign' and 'masign'.  See topic 'MASIGN'.

arima() allows you to choose among several conventions that have been
used for the signs of AR and MA coefficients.  These are specified by
numbers Arsign and Masign with values +1 or -1.  Either or both can be
set as values of keywords 'arsign' and 'masign'; see below.  If not set
by 'arsign', the default value for Arsign is the value of variable
ARSIGN if it exists, or -1 otherwise.  Similarly the default value for
Masign is MASIGN or -1.  For details, see topic 'MASIGN'.

To use the Brockwell and Davis convention, before you start your
analysis you should do the following:
  Cmd> MASIGN <- 1; ARSIGN <- -1

See topic 'MASIGN'.

                  Other Optional Keyword Phrases
  Keyword phrase               Explanation
  fitmean:T or F Include mu in model when T, omit mu otherwise. Default
                 is T with d = D = 0 and F otherwise.  When d > 0 or D
                 > 0, mu is the mean of the differenced series
  active:active  LOGICAL vector with length(active) = npars = length(b)
                 where b = vector(mu, beta, phi, theta, phiS, thetaS).
                 When active[i] is F, b[i] is "inactive" and does not
                 change from its starting value.  If you want to
                 estimate mu by the sample mean rather than least
                 squares or MLE, use active[1] = F and b0[1] = 0
  start:b0       REAL vector b0 = vector(mu0, beta0, phi0, theta0,
                 phiS0, thetaS0) of starting values values for the
                 iteration.  Default is rep(0,npar).  b0 should include
                 values for "inactive" parameters.  When the mean is in
                 the model, b0[1] = 0 is equivalent to b0[1] = sample
  cast:nback     Residuals will be computed by "backcasting" for nback
                 >= 0 time points before the start of the series
  cycles:m       m (non-negative integer) cycles of forecasting/
                 backcasting cycles used in computing residuals; default
                 m = 1.
  masign:Masign  Alters definition of MA parameters.  Masign must be +1
                 or -1.  As an example, a MA(2) model is
                  Y(t) = Z(t) + Masign*(theta[1]*Z(t-1) +
                 instead of
                  Y(t) = Z(t) - theta[1]*Z(t-1) - theta[2]*Z(t-2)
  arsign:Arsign  Alters definition of AR parameters.  Arsign must be +1
                 or -1.  As an example, an AR(2) model is
                  Y(t) = Z(t) - Arsign*phi[1]*Y(t-1) -
                 instead of
                  Y(t) = Z(t) + phi[1]*Y(t-1) + phi[2]*Y(t-2)
  maxit:itmax    Maximum number of iterations allowed (default 30, 0 is
                 ok).  With mle:T, when itmax < 0, no iterations of
                 least squares fitting is done and up to abs(itmax)
                 iterations of MLE using sigmahat based on coefficients
                 in b0.  When itmax = 0, no iteration is done at all,
                 but calculations are done using starting values.
  minit:itmin    Minimum number of iterations carried out (default = 0)
  crit:vector(numsig, nsigsq, delta)
                 Integer numsig >= 1 is the number of accurate digits
                 wanted in coefficients.
                 Integer nsiqsq >= 1 is the number of accurate digits
                 wanted in the residual sum of squares.
                 When delta > 0, iterations stop when the norm of the
                 gradient <= delta
                 Iteration terminates the first time any of these
                 criteria is met.  When any of numsig, nsigsq or delta
                 are 0, that criterion is ignored.
                 Example: crit:vector(6,0,0) specifies iteration
                 continues until the relative change in all
                 coefficients is less than 1e-6.
  print:T        Partial results are printed at each iteration
  keep:T         arima() returns a structure as value (see below).
  quiet:F        No summary results are printed, although side effect
                 variables are created.  Default is F except with keep:T

Without keyword phrase 'keep:T', arima() returns NULL as value.

With keyword phrase 'keep:T', arima() returns a structure with the
following components:
  Name           Contents
  coefs          vector(muhat,betahat,phihat,thetahat,phiShat,thetaShat)
                 with coefficients not in the model omitted.
  hessian        NPAR by NPAR matrix JACOBIAN %c% JACOBIAN
  gradient       Same as GRADIANT
  residuals      Same as ALLRESIDUALS
  nobs           length(y) - d - D*Period
  npar           number of active parameters
  pdq            zero padded value of keyword 'pdq' or rep(0,3)
  PDQ            zero padded value of keyword 'PDQ' or rep(0,3)
  seasonal       value of keyword 'seasonal' or 0
  active         logical vector the same length as coefs; active[i] is
                 True if and only if coefs[i] is an active parameter
  iter           Number of iterations to convergence or termination
  iconv          0: not converged by any criterion
                 1: converged by relative coefficient change criterion
                 2: converged by relative RSS or log L change criterion
                 3: changed by norm of gradient criterion
                 4: could not further reduce RSS or -2logL
  rss            Same as RSS
  neg2logL       Same as NEG2LOGL
  aicc           Same as AICC

See also hannriss(), innovest().

Gary Oehlert 2003-01-15