Learn R Programming

portes (version 1.08)

portes-package: Portmanteau Tests for Time Series Models

Description

This package contains a set of portmanteau diagnostic checks for univariate and multivariate time series based on the asymptotic approximation distributions and the Monte-Carlo significance test. It can be used for simulating data from nonseasonal ARIMA or VARIMA Models whith innovations from finite or infinite variances distributions. The simulated data may have deterministic terms, a constant drift and a time trend, with non-zero mean.

Arguments

Main Function

The main function in this package, portest, is used with univariate and multivariate time series. It implements the Portmanteau test statistics, gvtest, BoxPierce, LjungBox, Hosking, and LiMcLeod based on two methods. The first method uses the Monte-Carlo techniques as described by Lin and McLeod (2006), Mahdi and McLeod (2011) and the second one uses the approximation asymptotic distribution. Originally, the generalized variance portmanteau test, gvtest, for univariate time series based on the gamma distribution was proposed by Pena and Rodriguez (2002). Lin and McLeod (2006) proposed the Monte-Carlo version of this test and Mahdi and McLeod (2011) extended both methods to the multivariate case. Simulation results suggest that the Monte-Carlo version of gvtest statistic is more accurate and powerful than its competitors proposed by Box and Pierce (1970), Ljung and Box (1978), and Pena and Rodriguez (2002,2006) in the univariate time series and Hosking (1980) and Li and McLeod (1981) in the multivariate time series. For faster calculations, users with multi-core PC may take advantage of implementing of the parallel computing techniques in portest function after loading the package snow. The default argument in portest function, nslaves=1, implements the Monte-Carlo test on PC with only one CPU. When the argument nslaves>1 is used, the package snow is used provided that the default argument MonteCarlo=TRUE is selected. When MonteCarlo=FALSE is selected, the test statistic selected from the argument test is implemented based on the asymptotic approximation distribution. The default test statistic is the generalized variance test, gvtest. The snow R package is available on CRAN with more details in the link http://www.stat.uiowa.edu/~luke/R/cluster/cluster.html. Test for usual residuals and ARCH effects{ By setting the argument SquaredQ = TRUE in portest function, the portmanteau test based on the Monte-Carlo or the asymptotic distribution method (depending on the choice of the argument MonteCarlo) for ARCH effects will be implemented on the squared residuals. Otherwise, the portmanteau test will be applied on the usual residuals when the default argument SquaredQ = FALSE is selected. } Monte-Carlo test for residuals with infinite variances{ The argument InfiniteVarianceQ = TRUE in portest function is used only with Monte-Carlo techniques. By selecting this argument, the Monte-Carlo diagnostic test on residuals with infinite variances effects is implemented. } Test for fractional Gaussian noise, FGN, effects{ After fitting FGN model using the function FitFGN in the FGN R package, the output object has a class "FitFGN". By substituting this object as a first entry in the portest function, the portmanteau test based on the Monte-Carlo or the asymptotic distribution method (depending on the choice of MonteCarlo) for FGN model will be implemented. }

Simulate data from nonseasonal <code>ARIMA(p,d,q)</code> or <code>VARIMA(p,d,q)</code>

The function varima.sim in this package is useful for simulating data from nonseasonal ARIMA or VARIMA of order $(p,d,q)$ with or without deterministic terms (drift and trend), where innovations generated from stable distribution with finite or infinite variances. The argument $d$ must entered as a nonnegative integer in the ARIMA case, whereas it must entered as a vector of $k$ components $d_1,...,d_k$ in the VARIMA case. $d_i$ represents the difference lag need to be applied on series i. The default argument of varima.sim function, StableParameters=NA, is used for innovations with finite variances. For innovations from stable distribution with stable parameters ALPHA, BETA, GAMMA, and DELTA, the argument StableParameters equals to these parameters.

Details

ll{ Package: portes Type: Package Version: 1.08 Date: 2013-04-10 LazyLoad: yes LazyData: yes Depends: FitAR, akima Suggests: FGN, forecast, vars, snow Recommends: rlecuyer Classification/ACM: G.3, G.4, I.5.1 Classification/MSC: 62M10, 91B84 License: CC BY-NC-SA 3.0 }

References

Hosking, J. R. M. (1980). "The Multivariate Portmanteau Statistic". Journal of American Statistical Association, 75, 602-608. Li, W. K. and McLeod, A. I. (1981). "Distribution of The Residual Autocorrelations in Multivariate ARMA Time Series Models". Journal of The Royal Statistical Society, Series B, 43, 231-239. Lin, J.-W. and McLeod, A.I. (2006). "Improved Generalized Variance Portmanteau Test". Computational Statistics and Data Analysis 51, 1731-1738. Lin, J.-W. and McLeod, A.I. (2008). "Portmanteau Tests for ARMA Models with Infinite Variance". Journal of Time Series Analysis, 29, 600-617. Mahdi, E. and McLeod, A.I. (2011). "Improved Multivariate Portmanteau Diagnostic Test". Submitted. McCulloch, J. H. (1986). "Simple Consistent Estimator of Stable Distribution Parameters". Commun. Statist.--Simula., 15(4), 1109-1136. McLeod A.I, Li W.K (1983). "Distribution of the Residual Autocorrelation in Multivariate ARMA Time Series Models". Journal of Time Series Analysis, 4, 269-273. McLeod, A.I., Yu, Hao, Krougly, Zinovi L. (2007). "Algorithms for Linear Time Series Analysis". Journal of Statistical Software. Pena, D. and Rodriguez, J. (2006). "The log of the determinant of the autocorrelation matrix for testing goodness of fit in time series". Journal of Statistical Planning and Inference, 136, 2706-2718.

Examples

Run this code
#########################################################################
## Monte-Carlo test for randomness On PC with Single CPU ##
#########################################################################
data("DEXCAUS")
returns <- log(DEXCAUS[-1]/DEXCAUS[-length(DEXCAUS)])
portest(returns)
#########################################################################
## Monte-Carlo test for usual residuals using "snow" ##
#########################################################################
ans <- arima(Nile, order=c(1,0,1))
portest(ans, nslaves = 8)
##
IBMSP500 <- monthibmspln
Fit3 <-  ar.ols(IBMSP500, aic=TRUE,intercept=F, order.max=3)
portest(Fit3,test="gvtest",nslaves=8)
portest(Fit3,test="Hosking",nslaves=8)
## Use VAR function in the R package "vars"
##
library(vars)
Fit3 <- VAR(IBMSP500,p=3)
portest(Fit3,test="gvtest",nslaves=8)
#########################################################################
## Monte-Carlo test for squared residuals: ARCH effects using "snow" ##
#########################################################################
data("monthintel")
returns <- as.ts(monthintel)
lags <- c(5, 10, 40)
portest(returns, lags = lags, nslaves = 8, SquaredQ = TRUE)
#########################################################################
## Monte-Carlo test on residuals with infinite variances using "snow" ##
#########################################################################
data("CRSP")
CRSP.AR5<- arima(CRSP, c(5, 0, 0))
NREP<- 1000
lags=c(10, 20, 30)
portest(CRSP.AR5,lags=lags,nslaves=8,NREP=NREP,InfiniteVarianceQ=TRUE)      
#########################################################################
## Monte-Carlo test for FGN using "snow" ##
#########################################################################
library("FGN")
data("NileMin")
NILE.FGN <- FitFGN(NileMin)
lags <- c(5, 10, 20)
portest(NILE.FGN, lags = lags, nslaves = 8) 
#########################################################################
## Simulate a VARMA process with innovations that have finite variance ##
#########################################################################
## Example 1
## Data from VARMA (1,1) with mean zero vector without drift or trend.
#
n <- 300
phi <-  array(c(0.5, 0.4, 0.1, 0.5),dim = c(2, 2, 1))
theta <-  array(c(0, 0.25, 0, 0),dim = c(2, 2, 1))
d <- NA
sigma <- matrix(c(1, 0.71, 0.71, 2), 2, 2)
Z <- varima.sim(phi, theta, d, sigma, n)
plot(Z)
#
## Example 2
## Mean = c(10,20), drift equation a + b * t, a = c(2,3), and b = c(0,0.06).
#
n <- 300  
phi <-  array(c(0.5, 0.4, 0.1, 0.5),dim = c(2, 2, 1))
theta <-  array(c(0, 0.25, 0, 0),dim = c(2, 2, 1))
d <- c(0,0)
sigma <- matrix(c(1, 0.71, 0.71, 2), 2, 2)
constant <- c(2,3)
trend <- c(0,0.06)
demean <- c(10,20)
Z <- varima.sim(phi, theta, d, sigma, n, constant, trend, demean)
plot(Z)
#########################################################################
##  Simulate from VARIMA process with innovations of infinite variance ##
#########################################################################
n <- 500
phi <-  array(c(0.5, 0.4, 0.1, 0.5),dim = c(2, 2, 1))
theta <-  array(c(0, 0.25, 0, 0),dim = c(2, 2, 1))
d <- c(1,0)
sigma <- matrix(c(1, 0.71, 0.71, 2), 2, 2)
ALPHA <- c(1.3, 1.6)
BETA <- c(0, 0.2)
GAMMA <- c(1, 1)
DELTA <- c(0, 0.2)
StableParameters <- c(ALPHA, BETA, GAMMA, DELTA)
varima.sim(phi, theta, d, sigma, n, StableParameters = StableParameters)

Run the code above in your browser using DataLab