Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions R/MTS.R
Original file line number Diff line number Diff line change
Expand Up @@ -1164,7 +1164,7 @@
VARirf <- list(irf=Si,orthirf=orSi)
}

"mq" <- function(x,lag=24,adj=0){
"mq" <- function(x,lag=24,adj=0,return.only=FALSE){
# Compute multivariate Ljung-Box test statistics
#
# adj: adjustment for the degrees of freedomm in the chi-square distribution.
Expand Down Expand Up @@ -1194,13 +1194,18 @@
}
pvs=QM[,4]
dimnames(QM) = list(names(pvs),c(" m "," Q(m) "," df "," p-value"))
cat("Ljung-Box Statistics: ","\n")
printCoefmat(QM,digits = 3)
#
par(mfcol=c(1,1))
plot(pvs,ylim=c(0,1),xlab="m",ylab="prob",main="p-values of Ljung-Box statistics")
abline(h=c(0))
lines(rep(0.05,lag),lty=2,col='blue')
if(!return.only){
cat("Ljung-Box Statistics: ","\n")
printCoefmat(QM,digits = 3)
#
par(mfcol=c(1,1))
plot(pvs,ylim=c(0,1),xlab="m",ylab="prob",main="p-values of Ljung-Box statistics")
abline(h=c(0))
lines(rep(0.05,lag),lty=2,col='blue')
}
else{
return(QM)
}
}

###
Expand Down
5 changes: 4 additions & 1 deletion man/mq.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
cross-correlation matrices
}
\usage{
mq(x, lag = 24, adj = 0)
mq(x, lag = 24, adj = 0, return.only=FALSE)
}
\arguments{
\item{x}{The data matrix of a vector time series or residual series of a
Expand All @@ -16,6 +16,9 @@ fitted multivariate model.
}
\item{adj}{Adjustment for the degrees of freedom for the Ljung-Box
statistics. This is used for residual series. Default is zero.
}
\item{return.only}{If TRUE, the results are returned, but not printed or
plotted. Default is FALSE.
}
}
\details{Computes the multivariate Ljung-Box statistics and their
Expand Down