| MCPortmanteauTest {PRTest} | R Documentation |
Monte-Carlo portmanteau tests for Pena-Rodriguez and Ljung-Box tests.
MCPortmanteauTest(obj, lags = seq(5, 40, 5), NREP = 250, TestStatistic = "PR", StableQ = FALSE, InitializeRandomSeedQ = TRUE, SquaredQ = FALSE)
obj |
If obj is a class Arima object, then
a portmanteau goodness-of-fit test is done on the residuals.
Otherwise if obj is class ts or numeric, a test of randomness is done.
|
lags |
lags used in test |
NREP |
number of bootstrap replications |
TestStatistic |
PR for generalized-variance test and LB for Ljung-Box type test and BP for Box-Pierce. |
StableQ |
TRUE, assume stable distribution otherwise Gaussian |
InitializeRandomSeedQ |
TRUE, use a fixed pre-set seed. Otherwise use a random seed. |
SquaredQ |
TRUE, apply the test to the squared values. Otherwise the usual test. |
The tests discussed in Lin and McLeod (2006, 2007) are implemented.
vector of p-values
A.I. McLeod
Lin, J.W. and McLeod, A.I. (2006). Improved Pena-Rodriguez Portmanteau Test. Computational Statistics and Data Analysis, 51, 1731-1738.
Lin, J.W. and McLeod, A.I. (2007, accepted). Portmanteau Tests for ARMA Models with Infinite Variance. Journal of Time Series Analysis.
#test DEXCAUS returns for randomness
r<-Returns(DEXCAUS)
MCPortmanteauTest(r)
#The following script generates Table 2 in Lin and McLeod (2007).
#It takes about 30 minutes on a Pentium 4, 3 GHZ PC
#To run, just uncomment the code
#
# data(CRSP)
# CRSP.AR5<-arima(CRSP, c(5,0,0))
# NREP<-1000
# lags=c(10,20,30)
# tb<-matrix(numeric(5*length(lags)),nrow=5)
# tb[1,]<-MCPortmanteauTest(CRSP.AR5, lags=lags, NREP=NREP, StableQ=TRUE))[1]
# tb[2,]<-MCPortmanteauTest(CRSP.AR5, lags=lags, NREP=NREP, TestStatistic="LB", StableQ=TRUE))[1]
# tb[3,]<-MCPortmanteauTest(CRSP.AR5, lags=lags, NREP=NREP))[1]
# tb[4,]<-MCPortmanteauTest(CRSP.AR5, lags=lags, NREP=NREP, TestStatistic="LB"))[1]
# tb[5,]<-LBNTest(CRSP.AR5, lags=lags)
# rn<-c("PR-Stable","LB-Stable","PRN-MC","LBN-MC")
# dimnames(tb)<-list(c(rn,"LBN"),lags)