The Modified Multivariate Portmanteau Test, Li-McLeod (1981)
The modified multivariate portmanteau test suggested by Li and McLeod (1981).
LiMcLeod(obj,lags=seq(5,30,5),order=0,season=1,squared.residuals=FALSE)
obj |
a univariate or multivariate series with class |
lags |
vector of lag auto-cross correlation coefficients used for |
order |
Default is zero for testing the randomness of a given sequence with
class |
season |
seasonal periodicity for testing seasonality. Default is 1 for testing the non seasonality cases. |
squared.residuals |
if |
However the portmanteau test statistic can be applied directly on the output objects from
the built in R
functions ar()
, ar.ols()
, ar.burg()
,
ar.yw()
, ar.mle()
, arima()
, arim0()
, Arima()
,
auto.arima()
, lm()
, glm()
, and VAR()
,
it works with output objects from any fitted model.
In this case, users should write their own function to fit any model they want, where they
may use the built in R
functions FitAR()
, garch()
, garchFit()
,
fracdiff()
, tar()
, etc.
The object obj
represents the output of this function.
This output must be a list with at least two outcomes:
the fitted residual and the order of the fitted model (list(res = ..., order = ...)
).
See the following example with the function FitModel()
.
The multivariate test statistic suggested by Li and McLeod (1981) and its corresponding p-values
for different lags based on the asymptotic chi-square distribution with k^2(lags-order)
degrees of freedom.
Esam Mahdi and A.I. McLeod.
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.
x <- rnorm(100) LiMcLeod(x) ## univariate test x <- cbind(rnorm(100),rnorm(100)) LiMcLeod(x) ## multivariate test ## ## ## Monthly log stock returns of Intel corporation data: Test for ARCH Effects monthintel <- as.ts(monthintel) LjungBox(monthintel) ## Usual test LjungBox(monthintel,squared.residuals=TRUE) ## Test for ARCH effects ## ## ## Quarterly, west German investment, income, and consumption from 1960 Q1 to 1982 Q4 data(WestGerman) DiffData <- matrix(numeric(3 * 91), ncol = 3) for (i in 1:3) DiffData[, i] <- diff(log(WestGerman[, i]), lag = 1) fit <- ar.ols(DiffData, intercept = TRUE, order.max = 2) lags <- c(5,10) ## Apply the test statistic on the fitted model (order will be automatically applied) LiMcLeod(fit,lags,order = 2) ## Correct (no need to specify order) LiMcLeod(fit,lags) ## Correct ## Apply the test statistic on the residuals res <- ts((fit$resid)[-(1:2), ]) LiMcLeod(res,lags,order = 2) ## Correct LiMcLeod(res,lags) ## Wrong (order is needed!) ## ## ## Write a function to fit a model: Apply portmanteau test on fitted obj with class "list" FitModel <- function(data){ fit <- ar.ols(data, intercept = TRUE, order.max = 2) order <- 2 res <- res <- ts((fit$resid)[-(1:2), ]) list(res=res,order=order) } data(WestGerman) DiffData <- matrix(numeric(3 * 91), ncol = 3) for (i in 1:3) DiffData[, i] <- diff(log(WestGerman[, i]), lag = 1) Fit <- FitModel(DiffData) LiMcLeod(Fit)
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.