Fit ARMA Models to Time Series
arma.RdFit an ARMA model to a univariate time series by conditional least
squares. For exact maximum likelihood estimation see
arima0.
Usage
arma(x, order = c(1, 1), lag = NULL, coef = NULL,
include.intercept = TRUE, series = NULL, qr.tol = 1e-07, ...)Arguments
- x
a numeric vector or time series.
- order
a two dimensional integer vector giving the orders of the model to fit.
order[1]corresponds to the AR part andorder[2]to the MA part.- lag
a list with components
arandma. Each component is an integer vector, specifying the AR and MA lags that are included in the model. If both,orderandlag, are given, only the specification fromlagis used.- coef
If given this numeric vector is used as the initial estimate of the ARMA coefficients. The preliminary estimator suggested in Hannan and Rissanen (1982) is used for the default initialization.
- include.intercept
Should the model contain an intercept?
- series
name for the series. Defaults to
deparse(substitute(x)).- qr.tol
the
tolargument forqrwhen computing the asymptotic standard errors ofcoef.- ...
additional arguments for
optimwhen fitting the model.
Details
The following parametrization is used for the ARMA(p,q) model:
$$y[t] = a[0] + a[1]y[t-1] + \dots + a[p]y[t-p] + b[1]e[t-1] + \dots + b[q]e[t-q] + e[t],$$
where \(a[0]\) is set to zero if no intercept is included. By using
the argument lag, it is possible to fit a parsimonious submodel
by setting arbitrary \(a[i]\) and \(b[i]\) to zero.
arma uses optim to minimize the conditional
sum-of-squared errors. The gradient is computed, if it is needed, by
a finite-difference approximation. Default initialization is done by
fitting a pure high-order AR model (see ar.ols).
The estimated residuals are then used for computing a least squares
estimator of the full ARMA model. See Hannan and Rissanen (1982) for
details.
Value
A list of class "arma" with the following elements:
- lag
the lag specification of the fitted model.
- coef
estimated ARMA coefficients for the fitted model.
- css
the conditional sum-of-squared errors.
- n.used
the number of observations of
x.- residuals
the series of residuals.
- fitted.values
the fitted series.
- series
the name of the series
x.- frequency
the frequency of the series
x.- call
the call of the
armafunction.- vcov
estimate of the asymptotic-theory covariance matrix for the coefficient estimates.
- convergence
The
convergenceinteger code fromoptim.- include.intercept
Does the model contain an intercept?
References
E. J. Hannan and J. Rissanen (1982): Recursive Estimation of Mixed Autoregressive-Moving Average Order. Biometrika 69, 81–94. doi:10.1093/biomet/69.1.81 .
See also
summary.arma for summarizing ARMA model fits;
arma-methods for further methods;
arima0, ar.
Examples
data(tcm)
r <- diff(tcm10y)
summary(r.arma <- arma(r, order = c(1, 0)))
#>
#> Call:
#> arma(x = r, order = c(1, 0))
#>
#> Model:
#> ARMA(1,0)
#>
#> Residuals:
#> Min 1Q Median 3Q Max
#> -1.707400 -0.116059 0.006282 0.128118 1.471796
#>
#> Coefficient(s):
#> Estimate Std. Error t value Pr(>|t|)
#> ar1 0.328972 0.039991 8.226 2.22e-16 ***
#> intercept 0.003325 0.011430 0.291 0.771
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#>
#> Fit:
#> sigma^2 estimated as 0.07287, Conditional Sum-of-Squares = 40.44, AIC = 125.89
#>
summary(r.arma <- arma(r, order = c(2, 0)))
#>
#> Call:
#> arma(x = r, order = c(2, 0))
#>
#> Model:
#> ARMA(2,0)
#>
#> Residuals:
#> Min 1Q Median 3Q Max
#> -1.603801 -0.117037 0.002274 0.129126 1.376261
#>
#> Coefficient(s):
#> Estimate Std. Error t value Pr(>|t|)
#> ar1 0.40790 0.04114 9.915 < 2e-16 ***
#> ar2 -0.23962 0.04113 -5.826 5.67e-09 ***
#> intercept 0.00420 0.01111 0.378 0.705
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#>
#> Fit:
#> sigma^2 estimated as 0.06881, Conditional Sum-of-Squares = 38.12, AIC = 95.94
#>
summary(r.arma <- arma(r, order = c(0, 1)))
#>
#> Call:
#> arma(x = r, order = c(0, 1))
#>
#> Model:
#> ARMA(0,1)
#>
#> Residuals:
#> Min 1Q Median 3Q Max
#> -1.590634 -0.118433 -0.000165 0.129751 1.339717
#>
#> Coefficient(s):
#> Estimate Std. Error t value Pr(>|t|)
#> ma1 0.506871 0.042113 12.036 <2e-16 ***
#> intercept 0.005287 0.016632 0.318 0.751
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#>
#> Fit:
#> sigma^2 estimated as 0.06811, Conditional Sum-of-Squares = 37.8, AIC = 88.21
#>
summary(r.arma <- arma(r, order = c(0, 2)))
#>
#> Call:
#> arma(x = r, order = c(0, 2))
#>
#> Model:
#> ARMA(0,2)
#>
#> Residuals:
#> Min 1Q Median 3Q Max
#> -1.5497077 -0.1224297 0.0009082 0.1343164 1.3639450
#>
#> Coefficient(s):
#> Estimate Std. Error t value Pr(>|t|)
#> ma1 0.449184 0.042387 10.597 <2e-16 ***
#> ma2 -0.117937 0.042662 -2.764 0.0057 **
#> intercept 0.004701 0.014613 0.322 0.7477
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#>
#> Fit:
#> sigma^2 estimated as 0.0673, Conditional Sum-of-Squares = 37.28, AIC = 83.58
#>
summary(r.arma <- arma(r, order = c(1, 1)))
#>
#> Call:
#> arma(x = r, order = c(1, 1))
#>
#> Model:
#> ARMA(1,1)
#>
#> Residuals:
#> Min 1Q Median 3Q Max
#> -1.5529214 -0.1189386 0.0001515 0.1337559 1.3663775
#>
#> Coefficient(s):
#> Estimate Std. Error t value Pr(>|t|)
#> ar1 -0.202320 0.074961 -2.699 0.00695 **
#> ma1 0.658111 0.056927 11.561 < 2e-16 ***
#> intercept 0.006799 0.018195 0.374 0.70866
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#>
#> Fit:
#> sigma^2 estimated as 0.06731, Conditional Sum-of-Squares = 37.35, AIC = 83.62
#>
plot(r.arma)
data(nino)
s <- nino3.4
summary(s.arma <- arma(s, order=c(20,0)))
#>
#> Call:
#> arma(x = s, order = c(20, 0))
#>
#> Model:
#> ARMA(20,0)
#>
#> Residuals:
#> Min 1Q Median 3Q Max
#> -1.378647 -0.223040 0.007358 0.215996 1.103511
#>
#> Coefficient(s):
#> Estimate Std. Error t value Pr(>|t|)
#> ar1 1.10163 0.04090 26.932 < 2e-16 ***
#> ar2 -0.05461 0.06063 -0.901 0.367693
#> ar3 -0.17718 0.06060 -2.924 0.003457 **
#> ar4 0.07072 0.06056 1.168 0.242900
#> ar5 -0.05292 0.05990 -0.884 0.376941
#> ar6 0.06743 0.05932 1.137 0.255661
#> ar7 -0.17060 0.05877 -2.903 0.003698 **
#> ar8 -0.03509 0.05857 -0.599 0.549068
#> ar9 0.03326 0.05827 0.571 0.568113
#> ar10 0.14149 0.05829 2.427 0.015206 *
#> ar11 0.01597 0.05812 0.275 0.783504
#> ar12 0.16400 0.05791 2.832 0.004629 **
#> ar13 -0.22467 0.05833 -3.852 0.000117 ***
#> ar14 -0.01355 0.05869 -0.231 0.817394
#> ar15 -0.04530 0.05845 -0.775 0.438283
#> ar16 -0.18815 0.05807 -3.240 0.001196 **
#> ar17 0.20923 0.05868 3.566 0.000363 ***
#> ar18 0.07387 0.05868 1.259 0.208074
#> ar19 -0.13363 0.05792 -2.307 0.021045 *
#> ar20 0.05234 0.04002 1.308 0.190952
#> intercept 4.46824 0.79612 5.613 1.99e-08 ***
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#>
#> Fit:
#> sigma^2 estimated as 0.1079, Conditional Sum-of-Squares = 62.24, AIC = 407.41
#>
summary(s.arma
<- arma(s, lag=list(ar=c(1,3,7,10,12,13,16,17,19),ma=NULL)))
#> Warning: order is ignored
#>
#> Call:
#> arma(x = s, lag = list(ar = c(1, 3, 7, 10, 12, 13, 16, 17, 19), ma = NULL))
#>
#> Model:
#> ARMA(19,0)
#>
#> Residuals:
#> Min 1Q Median 3Q Max
#> -1.360875 -0.230887 0.005043 0.226822 1.090989
#>
#> Coefficient(s):
#> Estimate Std. Error t value Pr(>|t|)
#> ar1 1.07772 0.02642 40.793 < 2e-16 ***
#> ar3 -0.16942 0.03016 -5.618 1.93e-08 ***
#> ar7 -0.13913 0.02254 -6.174 6.67e-10 ***
#> ar10 0.16459 0.02931 5.615 1.97e-08 ***
#> ar12 0.20472 0.04754 4.306 1.66e-05 ***
#> ar13 -0.29976 0.04133 -7.253 4.07e-13 ***
#> ar16 -0.21637 0.04349 -4.975 6.54e-07 ***
#> ar17 0.25139 0.04648 5.408 6.37e-08 ***
#> ar19 -0.04510 0.02580 -1.748 0.0804 .
#> intercept 4.61896 0.77687 5.946 2.75e-09 ***
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#>
#> Fit:
#> sigma^2 estimated as 0.1094, Conditional Sum-of-Squares = 63.24, AIC = 393.87
#>
acf(residuals(s.arma), na.action=na.remove)
pacf(residuals(s.arma), na.action=na.remove)
summary(s.arma
<- arma(s, lag=list(ar=c(1,3,7,10,12,13,16,17,19),ma=12)))
#> Warning: order is ignored
#>
#> Call:
#> arma(x = s, lag = list(ar = c(1, 3, 7, 10, 12, 13, 16, 17, 19), ma = 12))
#>
#> Model:
#> ARMA(19,12)
#>
#> Residuals:
#> Min 1Q Median 3Q Max
#> -1.339941 -0.209727 0.001678 0.224448 1.065923
#>
#> Coefficient(s):
#> Estimate Std. Error t value Pr(>|t|)
#> ar1 1.06644 0.02807 37.997 < 2e-16 ***
#> ar3 -0.15394 0.03295 -4.673 2.98e-06 ***
#> ar7 -0.12194 0.01971 -6.187 6.14e-10 ***
#> ar10 0.12689 0.02735 4.639 3.50e-06 ***
#> ar12 0.46228 0.10391 4.449 8.63e-06 ***
#> ar13 -0.53619 0.09507 -5.640 1.70e-08 ***
#> ar16 -0.18195 0.05069 -3.589 0.000331 ***
#> ar17 0.24859 0.05087 4.887 1.02e-06 ***
#> ar19 -0.04463 0.02864 -1.558 0.119164
#> ma12 -0.36376 0.11096 -3.278 0.001044 **
#> intercept 3.62293 0.78419 4.620 3.84e-06 ***
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#>
#> Fit:
#> sigma^2 estimated as 0.103, Conditional Sum-of-Squares = 59.54, AIC = 359.84
#>
summary(s.arma
<- arma(s, lag=list(ar=c(1,3,7,10,12,13,16,17),ma=12)))
#> Warning: order is ignored
#>
#> Call:
#> arma(x = s, lag = list(ar = c(1, 3, 7, 10, 12, 13, 16, 17), ma = 12))
#>
#> Model:
#> ARMA(17,12)
#>
#> Residuals:
#> Min 1Q Median 3Q Max
#> -1.27924 -0.19931 0.01423 0.22825 1.08027
#>
#> Coefficient(s):
#> Estimate Std. Error t value Pr(>|t|)
#> ar1 1.05679 0.02457 43.010 < 2e-16 ***
#> ar3 -0.10723 0.02392 -4.482 7.39e-06 ***
#> ar7 -0.15482 0.01939 -7.984 1.33e-15 ***
#> ar10 0.14458 0.02713 5.330 9.84e-08 ***
#> ar12 0.53544 0.07242 7.394 1.43e-13 ***
#> ar13 -0.64133 0.06248 -10.265 < 2e-16 ***
#> ar16 -0.14278 0.04063 -3.514 0.000441 ***
#> ar17 0.19739 0.03386 5.830 5.53e-09 ***
#> ma12 -0.43009 0.07957 -5.405 6.48e-08 ***
#> intercept 3.01582 0.63664 4.737 2.17e-06 ***
#> ---
#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#>
#> Fit:
#> sigma^2 estimated as 0.1023, Conditional Sum-of-Squares = 59.37, AIC = 353.98
#>
plot(s.arma)