# profiling takes a while
if (FALSE) {
#Load the twinstim model fitted to the IMD data
data("imdepi", "imdepifit")
# for profiling we need the model environment
imdepifit <- update(imdepifit, model=TRUE)
#Generate profiling object for a list of parameters for the new model
names <- c("h.(Intercept)","e.typeC")
coefList <- lapply(names, function(name) {
c(pmatch(name,names(coef(imdepifit))),NA,NA,11)
})
#Profile object (necessary to specify a more loose convergence
#criterion). Speed things up by using do.ltildeprofile=FALSE (the default)
prof <- profile(imdepifit, coefList,
control=list(reltol=0.1, REPORT=1), do.ltildeprofile=TRUE)
#Plot result for one variable
par(mfrow=c(1,2))
for (name in names) {
with(as.data.frame(prof$lp[[name]]),
matplot(grid,cbind(profile,estimated,wald),
type="l",xlab=name,ylab="loglik"))
legend(x="bottomleft",c("profile","estimated","wald"),lty=1:3,col=1:3)
}
}
Run the code above in your browser using DataLab