Open gracewutw opened 8 years ago
Not sure if this is the main cause, but one bug seems to be that you set pars[6] < 0, but then limit it to positive in the prior
Problematic line in the code:
if (any(pars[1:6] < 0) || any(pars[1:4] > 1) || pars[6] < log(0.00001) || pars[6] > log(10) )
return(-Inf)
Should be:
if (any(pars[1:5] < 0) || any(pars[1:4] > 1) || pars[6] < log(0.00001) || pars[6] > log(10) )
return(-Inf)
For some situation, I wanna fix the three parameters for susceptibility as 1. But I got the following error message: Error in UseMethod("depth") : no applicable method for 'depth' applied to an object of class "NULL" Could you help me to identify the problem? Thanks!
The codes I modified from the in depth example are as follows: initial.infected <- rep( 10^pars[6], 7 ) odes <- infectionODEs( popv, initial.infected, vaccine_calendar_T, contacts, c(1, 1, 1, 1, 1, 1, 1), transmissibility = pars[5], c(0.8,1.8), 7 ) llprior <- function(pars) { if (any(pars[1:6] < 0) || any(pars[1:4] > 1) || pars[6] < log(0.00001) || pars[6] > log(10) ) return(-Inf) lprob <- dnorm(pars[5], 0.1653183, 0.02773053, 1) lprob <- lprob + dlnorm(pars[1], -4.493789, 0.2860455, 1) lprob <- lprob + dlnorm(pars[2], -4.117028, 0.4751615, 1) lprob <- lprob + dlnorm(pars[3], -2.977965, 1.331832, 1) return(lprob) } init.pars <- c(0.01,0.015, 0.05, 1.0e-08, 0.16, -0.15)