nowcaster
nowcaster copied to clipboard
Implement Hessian testing
Hessian test is constructed to avoid problems when the INLA solver stack in negative eigenvalues, to avoid it we can work on the length iteration steps. The test can be implemented through a while
test until it reach a certain amount of tries. Follows a schematic test to be put on the nowcasting_age
and nowcasting_no_age
functions:
hess.min <- -1
h.value <- 0.01
h.trials <- 0.001
trials <- 0
while (hess.min <= 0 & trials < 50){
# Running the Negative Binomial model in INLA
output0 <- inla(model, family = "nbinomial", data = dados.age,
control.predictor = list(link = 1, compute = T),
control.compute = list(config = T, waic=F, dic=F, openmp.strategy='huge'),
control.family = list(
hyper = list("theta" = list(prior = "loggamma",
param = c(0.001, 0.001))
)
),
num.threads = 6,
control.inla = list(h = h.value),
...
)
hess.start <- which(output0$logfile == 'Eigenvalues of the Hessian')
hess.min <- min(as.numeric(output0$logfile[(hess.start+1):(hess.start+3)]))
h.value <- h.trials + 0.001
h.trials <- h.value
trials <- trials + 1
}