loglikLOOCVcontourVAR2: Contourplot of LOOCV log-likelihood of the VAR(2) model

Description Usage Arguments Value Note Author(s) References See Also Examples

View source: R/loglikLOOCVcontourVAR2.r

Description

Evaluates the leave-one-out cross-validated log-likelihood of the estimated VAR(2) model over a grid of the ridge penalty parameters (λ_{a1} and λ_{a2}) for the lag one and lag two autoregression coefficient matrices \mathbf{A}_1 and \mathbf{A}_2 (respectively), while keeping λ_{ω}, the penalty parameter of the inverse error covariance matrix \mathbf{Ω}_{\varepsilon} (=\mathbf{Σ_{\varepsilon}^{-1}}), fixed at a user-specified value. The result is plotted as a contour plot, which facilitates the choice of optimal penalty parameters. The function also works with a (possibly) unbalanced experimental set-up. The VAR(2)-process are assumed to have mean zero.

Usage

1
2
loglikLOOCVcontourVAR2(lambdaA1grid, lambdaA2grid, 
                       lambdaPgrid, Y, figure=TRUE, verbose=TRUE, ...)

Arguments

lambdaA1grid

A numeric of length larger than one, comprising positive numbers only. It contains the grid points corresponding to λ_{a1}, the ridge penalty parameter for the lag one autoregression coefficient matrix \mathbf{A}_1.

lambdaA2grid

A numeric of length larger than one, comprising positive numbers only. It contains the grid points corresponding to λ_{a2}, the ridge penalty parameter for the lag two autoregression coefficient matrix \mathbf{A}_2.

lambdaPgrid

A numeric of length larger than one, comprising positive numbers only. It contains the grid points corresponding to the λ_{ω} (the penalty parameters for the inverse error covariance matrix \mathbf{Ω}_{\varepsilon} (=\mathbf{Σ_{\varepsilon}^{-1}})).

Y

Three-dimensional array containing the data. The first, second and third dimensions correspond to covariates, time and samples, respectively. The data are assumed to be centered covariate-wise.

figure

A logical, indicating whether the contour plot should be generated.

verbose

A logical indicator: should intermediate output be printed on the screen?

...

Other arguments to be passed on (indirectly) to ridgeVAR2.

Value

A list-object with slots:

lambdaA1

A numeric with the grid points corresponding to λ_{a1} (the ridge penalty parameter for the lag one autoregression coefficient matrix \mathbf{A}_1).

lambdaA2

A numeric with the grid points corresponding to λ_{a2} (the ridge penalty parameter for the lag one autoregression coefficient matrix \mathbf{A}_2).

lambdaP

A numeric with the grid points corresponding to λ_{ω} (the penalty parameter for the inverse error covariance matrix \mathbf{Ω}_{\varepsilon} (=\mathbf{Σ_{\varepsilon}^{-1}})).

llLOOCV

A matrix of leave-one-out cross-validated log-likelihoods. Rows and columns correspond to λ_{a1} and λ_{a2} values, respectively.

Note

When lambdaA1grid, lambdaA2grid and lambdaPgrid are all vectors of length exceeding one, the contour is determined for the grid formed by the Cartesius product of lambdaA1grid and lambdaA2grid meanwhile restricting lambdaPgrid to its first element.

Internally, this function calls the loglikLOOCVVAR2-function, which evaluates the minus (!) LOOCV log-likelihood (for practical reasons). For interpretation purposes loglikLOOCVcontourVAR2 provides the regular LOOCV log-likelihood (that is, without the minus).

Author(s)

Wessel N. van Wieringen <w.vanwieringen@vumc.nl>, Viktorian Miok.

References

Miok, V., Wilting, S.M., Van Wieringen, W.N. (2017), “Ridge estimation of the VAR(1) model and its time series chain graph from multivariate time-course omics data”, Biometrical Journal, 59(1), 172-191.

See Also

loglikLOOCVcontourVAR1, loglikLOOCVcontourVARX1.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# set dimensions (p=covariates, n=individuals, T=time points)
p <- 3; n <- 12; T <- 10

# set model parameters
SigmaE <- diag(p)/4
A1 <- -createA(p, "clique", nCliques=1, nonzeroA=0.1)
A2 <- t(createA(p, "chain", nBands=1,   nonzeroA=0.1))

# generate data
Y <- dataVAR2(n, T, A1, A2, SigmaE)

## plot contour of cross-validated likelihood
## Not run:  lambdaA1grid <- seq(0.01, 1, length.out=20) 
## Not run:  lambdaA2grid <- seq(0.01, 1000, length.out=20) 
## Not run:  lambdaPgrid  <- seq(0.01, 1000, length.out=20) 
## Not run:  loglikLOOCVcontourVAR2(lambdaA1grid, lambdaA2grid, lambdaPgrid, Y) 

## determine optimal values of the penalty parameters
## Not run: optLambdas <- constrOptim(c(1,1,1), loglikLOOCVVAR2, gr=NULL, 
## Not run:               ui=diag(3), ci=c(0,0,0), Y=Y, 
## Not run:               control=list(reltol=0.01))$par 

## add point of optimum
## Not run:  points(optLambdas[1], optLambdas[2], pch=20, cex=2, 
## Not run:  col="red") 

wvanwie/ragt2ridges documentation built on May 4, 2019, 12:03 p.m.