## regular (non-modular) model fit
m0 <- glmmTMB(count ~ mined + (1|site),
family=poisson, data=Salamanders)
## construct model structures
m1 <- update(m0, doFit=FALSE)
names(m0)
m2 <- fitTMB(m1, doOptim = FALSE)
## could modify the components of m1$env$data at this point ...
## rebuild TMB structure (*may* be necessary)
m2 <- with(m2$env,
TMB::MakeADFun(data,
parameters,
map = map,
random = random,
silent = silent,
DLL = "glmmTMB"))
m3 <- with(m2, nlminb(par, objective = fn, gr = gr))
m4 <- finalizeTMB(m1, m2, m3)
Run the code above in your browser using DataLab