FitAR {FitAR} | R Documentation |
The estimation algorithm in McLeod & Zhang (2006a) is implemented.
FitAR(z, p, SubsetQ=FALSE, demean = TRUE, MeanMLEQ = FALSE, lag.max = "default")
z |
time series, vector or ts object. |
p |
p specifies the model. If length(p) is 1, an AR(p) is assumed and if p has length greater than 1, an ARz subset model with lags indicated by p is assumed. If you wish to fit a subset model with only one lag, say for example, 4, then set p to be c(0,0,0,4). For p=0, white noise model. |
SubsetQ |
default FALSE. Ignored if p has length > 1. Need set to TRUE for ambiguous cases – see Note. |
demean |
if True, subtract mean. Otherwise assume it is zero. |
MeanMLEQ |
if True, an iterative algorithm is used for exact simultaneous MLE estimation of the mean and other parameters. |
lag.max |
the residual autocorrelations are tabulated for lags 1, ..., lag.max. Also lag.max is used for the Ljung-Box portmanteau test. |
The exact MLE for AR(p) and subset AR(p) are using methods described in McLeod and Zhang (2006a). In addition the exact MLE for the mean can be computed using an iterative backfitting approach described in McLeod and Zhang (2006b).
The default for lag.max is ceiling(min(length(z)/4, min(max(length(z)/4, 30), 100))).
A list with class name "FitAR" and components:
loglikelihood |
value of the loglikelihood |
phiHat |
coefficients in AR(p) – including 0's |
sigsqHat |
innovation variance estimate |
muHat |
estimate of the mean |
covHat |
covariance matrix of the coefficient estimates |
zetaHat |
transformed parameters, length(zetaHat)=# coefficients estimated |
RacfMatrix |
residual autocorrelations and sd for lags 1...lag.max |
LjungBox |
table of Ljung-Box portmanteau test statistics |
SubsetQ |
parameters in AR(p) – including 0's |
res |
innovation residuals, same length as z |
fits |
fitted values, same length as z |
lags |
lags used in AR model |
demean |
TRUE if mean estimated otherwise assumed zero |
FitMethod |
"MLE" for this function |
IterationCount |
number of iterations in mean mle estimation |
convergence |
value returned by optim – should be 0 |
MLEMeanQ |
TRUE if mle for mean algorithm used |
tsp |
tsp(z) |
call |
result from match.call() showing how the function was called |
ModelTitle |
description of model |
DataTitle |
returns attr(z,"title") |
The SubsetQ parameter is used to distinguish models such as seasonal lag models from full AR models. For large p, this algorithm is faster than the built-in R function. See example below. There are generic print, summary, coef and resid functions for class "FitAR".
A.I. McLeod
McLeod, A.I. and Zhang, Y. (2006a). Partial autocorrelation parameterization for subset autoregression. Journal of Time Series Analysis, 27, 599-612.
McLeod, A.I. and Zhang, Y. (2006b, Accepted). Faster ARMA Maximum Likelihood Estimation, Computational Statistics and Data Analysis.
#First Example: Fit exact MLE to AR(4) using FitAR and arima set.seed(3323) phi<-c(2.7607,-3.8106,2.6535,-0.9238) z<-SimulateGaussianAR(phi,1000) ans1<-arima(z, order=c(4,0,0)) ans2<-FitAR(z,4,MeanMLEQ=TRUE) ans1 coef(ans2) #Second Example: compare with sample mean result ans3<-FitAR(z,4) coef(ans3) #Third Example: Fit subset AR model to lynx series z<-log(lynx) FitAR(z, c(1,2,4,7,10,11)) #now obain exact MLE for Mean as well FitAR(z, c(1,2,4,7,10,11), MeanMLE=TRUE) #Fourth Example: Some Timings t1<-system.time(ans1<-ar(sunspot.month, order.max=25, aic=FALSE, method="mle"))[[1]] t2<-system.time(ans2<-FitAR(sunspot.month, 25))[[1]] #uncomment lines below to run full examples but it takes about # 4 minutes on a 3.6GHz PC # #t3<-system.time(ans3<-FitAR(sunspot.month, 25, MeanMLE=TRUE))[[1]] #times<-c(t1,t2,t3) #names(times)<-c("ar","FitAR", "FitAR-MeanMLE")