x <- rnorm(100)
LjungBox(x)
##############################################################
## Measurements of the annual flow of the river Nile at Aswan
## from the years 1871 to 1970:
##############################################################
fit <- arima(Nile, c(2, 0, 0))
lags <- c(5, 10, 20)
## Apply the test statistic on the fitted model
LjungBox(fit, lags, order = 2) ## Univariate LjungBox test
## Apply the test statistic on the residuals
res <- resid(fit)
LjungBox(res, lags, order = 2) ## Univariate LjungBox test
##############################################################
## Monthly log stock returns of Intel corporation data
## Test for ARCH Effects
##############################################################
monthintel <- as.ts(monthintel)
LjungBox(monthintel,SquaredQ=FALSE) ## Test for usual residuals
LjungBox(monthintel,SquaredQ=TRUE) ## Test for ARCH effects
Run the code above in your browser using DataLab