# NOT RUN {
### Example 1: unobserved variation in virulence with gamma distribution
# step #1: parameterise nll function to be passed to 'mle2'
m01_prep_function <- function(
log.a1 = log.a1, log.b1 = log.b1,
log.a2 = log.a2, log.b2 = log.b2,
log.theta = log.theta){
nll_frailty_logscale(
log.a1 = log.a1, log.b1 = log.b1,
log.a2 = log.a2, log.b2 = log.b2,
log.theta = log.theta,
data = data_lorenz,
time = t,
censor = censored,
infected_treatment = g,
d1 = "Gumbel", d2 = "Weibull", d3 = "Gamma"
)}
# step #2: send 'prep_function' to 'mle2' for maximum likelihood estimation
m01 <- mle2(
m01_prep_function,
start = list(
log.a1 = 3, log.b1 = 1.5, log.a2 = 0.7, log.b2 = -0.7, log.theta = 1
)
)
summary(m01)
exp(coef(m01))
# }
Run the code above in your browser using DataLab