# NOT RUN {
# check column names in head of data frame with data to analyse
head(data_parker)
# step #1: prepare nll function for analysis
m01_prep_function <- function(a1 = a1, b1 = b1, a2 = a2, b2 = b2, p1 = p1){
nll_exposed_infected(
a1 = a1, b1 = b1, a2 = a2, b2 = b2, p1 = p1,
data = data_parker,
time = t,
censor = censored,
infected_treatment = g,
d1 = "Frechet",
d2 = "Weibull")
}
# step #2: send 'prep_function' to mle2 for maximum likelihood estimation
m01 <- mle2(m01_prep_function,
start = list(a1 = 2.5, b1 = 1, a2 = 2, b2 = 0.5, p1 = 0.5)
)
summary(m01)
# model setting lower & upper bounds to parameter estimates
# including 0 < p1 < 1
m02 <- mle2(m01_prep_function,
start = list(a1 = 2.5, b1 = 1.2, a2 = 1.9, b2 = 0.16, p1 = 0.48),
method = "L-BFGS-B",
lower = c(a1 = 0, b1 = 0, a2 = 0, b2 = 0, p1 = 0),
upper = c(a1 = Inf, b1 = Inf, a2 = Inf, b2 = Inf, p1 = 1),
)
summary(m02)
# }
Run the code above in your browser using DataLab