Description Usage Arguments Details See Also Examples
View source: R/nll_functions.R
Function returning negative log-likelihood (nll) for patterns of mortality in infected and uninfected treatments when an infected population is assumed to harbour two distinct subpopulations of hosts experiencing different virulence. The nll is based on seven parameters, the location and scale parameters for background mortality, separate location and scale parameters for each of the two infected subpopulations, and a parameter estimating the proportions of the two subpopulations
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | nll_two_inf_subpops_unobs(
a1 = a1,
b1 = b1,
a2 = a2,
b2 = b2,
a3 = a3,
b3 = b3,
p1 = p1,
data = data,
time = time,
censor = censor,
infected_treatment = infected_treatment,
d1 = "Weibull",
d2 = "Weibull",
d3 = "Weibull"
)
|
a1, b1 |
location and scale parameters describing background mortality |
a2, b2 |
location and scale parameters describing mortality due to infection in one subpopulation |
a3, b3 |
location and scale parameters describing mortality due to infection in the other subpopulation |
p1 |
parameter estimating the proportion of infected hosts in the first of the two subpopulations; 0 <= p1 <= 1 |
data |
name of data frame containing survival data |
time |
name of data frame column identifying time of event; time > 0 |
censor |
name of data frame column idenifying if event was death (0) or right-censoring (1) |
infected_treatment |
name of data frame column identifying if data are from an infected (1) or uninfected (0) treatment |
d1, d2, d3 |
names of probability distributions chosen to describe background mortality and mortality due to infection in each subpopulation, respectively; defaults to the Weibull distribution |
p1 is the estimated proportion of hosts associated with the location and scale parameters a2, b2; 0 <= p1 <= 1.
It is assumed the patterns of mortality within each subpopulation act independently of one another.
nll_exposed_infected
nll_two_inf_subpops_obs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | # example using data from Parker et al
data01 <- data_parker
# 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, p1 = p1){
nll_two_inf_subpops_unobs(
a1 = a1, b1 = b1, a2 = a2, b2 = b2, a3 = a3, b3 = b3, p1 = p1,
data = data01,
time = t,
censor = censored,
infected_treatment = g,
d1 = "Frechet",
d2 = "Weibull",
d3 = "Weibull"
)}
# step #2: send 'prep_function' to 'mle2' for maximum likelihood estimation
m01 <- mle2(
m01_prep_function,
start = list(a1 = 2, b1 = 1,
a2 = 2, b2 = 0.3,
a3 = 2, b3 = 0.7,
p1 = 0.5)
)
summary(m01)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.