Last data update: 2014.03.03

R: Subset ARz Model Fitting
FitARzR Documentation

Subset ARz Model Fitting

Description

The subset ARz model, defined by constraining partial autocorrelations to zero, is fitted using exact MLE. When length(p)=1, an AR(p) is fit by MLE.

Usage

FitARz(z, p, demean = TRUE, MeanMLEQ = FALSE, lag.max = "default")

Arguments

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, a subset ARz is assumed. For example, to fit a subset model with lags 1 and 4 present set p to c(1,4) or equivalently c(1,0,0,4). To fit a subset model with just lag 4, you must use p=c(0,0,0,4) since p=4 will fit a full AR(4).

demean

TRUE, mean estimated. FALSE, mean is zero.

MeanMLEQ

use exact MLE for mean parameter

lag.max

the residual autocorrelations are tabulated for lags 1, ..., lag.max. Also lag.max is used for the Ljung-Box portmanteau test.

Details

The model and its properties are discussed in McLeod and Zhang (2006) and McLeod and Zhang (2008).

Value

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

pvec

lags used in AR model

demean

TRUE if mean estimated otherwise assumed zero

FitMethod

"MLE" or "LS"

IterationCount

number of iterations in mean mle estimation

convergence

value returned by optim – should be 0

MLEMeanQ

TRUE if mle for mean algorithm used

ARModel

"ARp" if FitARp used, otherwise "ARz"

tsp

tsp(z)

call

result from match.call() showing how the function was called

ModelTitle

description of model

DataTitle

returns attr(z,"title")

z

time series data input)

Note

Normally one would use the FitAR function which then calls this function for the ARz case.

Author(s)

A.I. McLeod

References

McLeod, A.I. and Zhang, Y. (2006). Partial Autocorrelation Parameterization for Subset Autoregression. Journal of Time Series Analysis, 27, 599-612.

McLeod, A.I. and Zhang, Y. (2008a). Faster ARMA Maximum Likelihood Estimation, Computational Statistics and Data Analysis, 52-4, 2166-2176. DOI link: http://dx.doi.org/10.1016/j.csda.2007.07.020.

McLeod, A.I. and Zhang, Y. (2008b, Submitted). Improved Subset Autoregression: With R Package. Journal of Statistical Software.

See Also

FitAR, FitARp, GetFitARz, GetFitARpMLE, RacfPlot

Examples

#First Example: Fit exact MLE to AR(4) 
set.seed(3323)
phi<-c(2.7607,-3.8106,2.6535,-0.9238)
z<-SimulateGaussianAR(phi,1000)
ans<-FitARz(z,4,MeanMLEQ=TRUE)
ans
coef(ans)

## Not run: #save time building package
#Second Example: compare with sample mean result
ans<-FitARz(z,4)
coef(ans)

#Third Example: Fit subset ARz 
z<-log(lynx)
FitARz(z, c(1,2,4,7,10,11))
#now obain exact MLE for Mean as well
FitARz(z, c(1,2,4,7,10,11), MeanMLE=TRUE)

#Fourth Example: Fit subset ARz
somePACF<-c(0.5,0,0,0,-0.9)
someAR<-PacfToAR(somePACF)
z<-SimulateGaussianAR(someAR,1000)
ans=FitARz(z, c(1,5),MeanMLEQ=TRUE)
coef(ans)
GetFitARz(z,c(1,5))#assuming a known zero mean

## End(Not run)

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(FitAR)
Loading required package: lattice
Loading required package: leaps
Loading required package: ltsa
Loading required package: bestglm
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/FitAR/FitARz.Rd_%03d_medium.png", width=480, height=480)
> ### Name: FitARz
> ### Title: Subset ARz Model Fitting
> ### Aliases: FitARz
> ### Keywords: ts
> 
> ### ** Examples
> 
> #First Example: Fit exact MLE to AR(4) 
> set.seed(3323)
> phi<-c(2.7607,-3.8106,2.6535,-0.9238)
> z<-SimulateGaussianAR(phi,1000)
> ans<-FitARz(z,4,MeanMLEQ=TRUE)
> ans
AR(4). MLE.  Mean estimated using MLE
length of series = 1000 ,  number of parameters = 5
loglikelihood = -11.976 ,  AIC = 34 ,  BIC =  58.5
> coef(ans)
               MLE         sd      Z-ratio
phi(1)  2.77553629 0.01204809  230.3715443
phi(2) -3.83157614 0.02692659 -142.2971263
phi(3)  2.66902921 0.02692659   99.1224430
phi(4) -0.92457753 0.01204809  -76.7406120
mu      0.05835087 0.10139560    0.5754774
> 
> ## Not run: 
> ##D #save time building package
> ##D #Second Example: compare with sample mean result
> ##D ans<-FitARz(z,4)
> ##D coef(ans)
> ##D 
> ##D #Third Example: Fit subset ARz 
> ##D z<-log(lynx)
> ##D FitARz(z, c(1,2,4,7,10,11))
> ##D #now obain exact MLE for Mean as well
> ##D FitARz(z, c(1,2,4,7,10,11), MeanMLE=TRUE)
> ##D 
> ##D #Fourth Example: Fit subset ARz
> ##D somePACF<-c(0.5,0,0,0,-0.9)
> ##D someAR<-PacfToAR(somePACF)
> ##D z<-SimulateGaussianAR(someAR,1000)
> ##D ans=FitARz(z, c(1,5),MeanMLEQ=TRUE)
> ##D coef(ans)
> ##D GetFitARz(z,c(1,5))#assuming a known zero mean
> ## End(Not run)
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>