# NOT RUN {
# set dimensions (p=covariates, n=individuals, T=time points, G=groups)
p <- 3; n <- 12; T <- 10; G <- 3
# set model parameters
SigmaE <- matrix(1/2, p, p)
diag(SigmaE) <- 1
A1 <- -createA(p, "clique", nCliques=1, nonzeroA=0.1)
A2 <- t(createA(p, "chain", nBands=1, nonzeroA=0.1))
A3 <- (A1 + A2) / 2
# generate data
Y1 <- dataVAR1(n/G, T, A1, SigmaE)
Y2 <- dataVAR1(n/G, T, A2, SigmaE)
Y3 <- dataVAR1(n/G, T, A3, SigmaE)
Y <- abind::abind(Y1, Y2, Y3, along=3)
id <- c(rep(1, n/G), rep(2, n/G), rep(3, n/G))-1
## determine optimal values of the penalty parameters
# }
# NOT RUN {
optLambdas <- constrOptim(c(1,1,1), loglikLOOCVVAR1fused, gr=NULL,
# }
# NOT RUN {
ui=diag(3), ci=c(0,0,0), Y=Y, id=id
# }
# NOT RUN {
control=list(reltol=0.01))$par
# }
# NOT RUN {
# ridge ML estimation of the VAR(1) parameter estimates with
# optimal penalty parameters
optLambdas <- c(0.1, 0.1, 0.1)
VAR1hats <- ridgeVAR1fused(Y, id, optLambdas[1], optLambdas[2], optLambdas[3])
# }
Run the code above in your browser using DataLab