# NOT RUN {
# 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)
# }
# NOT RUN {
## 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
# }
# NOT RUN {
## add point of optimum
# }
# NOT RUN {
points(optLambdas[1], optLambdas[2], pch=20, cex=2,
# }
# NOT RUN {
col="red")
# }
Run the code above in your browser using DataLab