# NOT RUN {
# set dimensions (p=covariates, n=individuals, T=time points)
p <- 3; n <- 12; T <- 10
# set model parameters
SigmaE <- diag(p)/4
Ax <- createA(3, "chain")
# generate time-varying covariate data
X <- dataVAR1(n, T, Ax, SigmaE)
# regression parameter matrices of VARX(1) model
A <- createA(p, topology="clique", nonzeroA=0.1, nClique=1)
B <- createA(p, topology="hub", nonzeroA=0.1, nHubs=1)
# generate data
Y <- dataVARX1(X, A, B, SigmaE, lagX=0)
## plot contour of cross-validated likelihood
# }
# NOT RUN {
lambdaAgrid <- seq(0.01, 1, length.out=20)
# }
# NOT RUN {
lambdaBgrid <- seq(0.01, 1000, length.out=20)
# }
# NOT RUN {
lambdaPgrid <- seq(0.01, 1000, length.out=20)
# }
# NOT RUN {
loglikLOOCVcontourVARX1(lambdaAgrid, lambdaBgrid, lambdaPgrid, Y, X)
# }
# NOT RUN {
## determine optimal values of the penalty parameters
# }
# NOT RUN {
optLambdas <- constrOptim(c(1,1,1), loglikLOOCVVARX1, gr=NULL,
# }
# NOT RUN {
ui=diag(3), ci=c(0,0,0), Y=Y, X=X,
# }
# 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