# NOT RUN {
# example using data from Parker et al
data01 <- data_parker
# create column 'infsubpop' in data01, fill with '0'
data01$infsubpop <- 0
# infsubpop = '1' for individuals in infected treatments (g == 1)
# with visible signs of sporulation (Sporulation = 1)
# infsubpop = '2' for individuals in infected treatments (g == 1)
# with no visible signs of sporulation (Sporulation = 0)
data01$infsubpop[data01$g == 1 & data01$Sporulation == 1] <- 1
data01$infsubpop[data01$g == 1 & data01$Sporulation == 0] <- 2
head(data01)
# step #1: parameterise nll function to be passed to 'mle2'
m01_prep_function <- function(
a1 = a1, b1 = b1, a2 = a2, b2 = b2, a3 = a3, b3 = b3){
nll_two_inf_subpops_obs(
a1 = a1, b1 = b1, a2 = a2, b2 = b2, a3 = a3, b3 = b3,
data = data01,
time = t,
censor = censored,
infected_treatment = g,
d1 = "Frechet",
d2 = "Weibull",
d3 = "Weibull",
infsubpop = infsubpop
)}
# step #2: send 'prep_function' to 'mle2' for maximum likelihood estimation
m01 <- mle2(
m01_prep_function,
start = list(a1 = 3, b1 = 1, a2 = 2, b2 = 0.5, a3 = 2, b3 = 0.5)
)
summary(m01)
# }
Run the code above in your browser using DataLab