Same problem here. I also wanted to do a variable selection, and I used the mlik criteria.
f.null<-as.formula(y~1)
model0 = inla(f0, family="binomial", data = mydata, Ntrials=rep(1,n))
null.lml <- model0$mlik[1];
p<-dim(mydata)[2]
predictor.index <- c(1:p)
log.mlik <- rep(0,length(predictor.index))
for (i in 1:length(log.mlik)){
formula = y ~ mydata[,predictor.index[i]] + f(id, model = "iid")
result = inla(formula,family="binomial", data = mydata,
control.compute =list(mlik = TRUE,config=TRUE))
}
names(mydata)[predictor.index[which(
log.ml>null.lml)]]
And so for the 1st variable to include in the model, I put the one with the highest mlik. However, for the next step, adding more variables
( I want to do like a forward selection, or stepwise procedure), I am still confused on how to keep the selected ones, then combining it with the others.
e.g. let x1 be the selected, so my model is:
y~x1
Then, I want to add x2, ..., xp one at a time to the model, and re-do the above steps again.
How can I do this without 'manually' write the model one by one? Any help is much appreciated.