nll_frailty_shared: Negative log-likelihood function: frailty shared

Description Usage Arguments Details Value See Also Examples

View source: R/nll_functions.R

Description

Function calculating negative log-likelihood (nll) for patterns of mortality in infected and uninfected treatments where unobserved variation is assumed to act equally on background mortality and mortality due to infection.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
nll_frailty_shared(
  a1 = a1,
  b1 = b1,
  a2 = a2,
  b2 = b2,
  theta = theta,
  data = data,
  time = time,
  censor = censor,
  infected_treatment = infected_treatment,
  d1 = "",
  d2 = ""
)

Arguments

a1, b1

location and scale parameters for background mortality

a2, b2

location and scale parameters for mortality due to infection

theta

parameter describing variance of unobserved variation acting on mortality rates

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

names of probability distributions chosen to describe background mortality and mortality due to infection, respectively; both default to the Weibull distribution

Details

This function assumes unobserved variation acting on both the background rate of mortality and the rate of mortality due to infection is continuously distributed and follows the gamma distribution, with mean = 1.0 and variance = theta. The function returns the nll based on five parameters; the location and scale parameters for background mortality and mortality due to infection, plus the parameter describing the variance of the unobserved variation.

Value

numeric

See Also

nll_frailty

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
# step #1: prepare nll function for analysis
  m01_prep_function <- function(a1 = a1, b1 = b1, a2 = a2, b2 = b2, theta = theta){
    nll_frailty_shared(a1 = a1, b1 = b1, a2 = a2, b2 = b2, theta = theta,
      data = data_lorenz,
      time = t,
      censor = censored,
      infected_treatment = g,
      d1 = "Gumbel", d2 = "Gumbel"
      )}

# step #2: send 'prep_function' to mle2 for maximum likelihood estimation,
  # specifying starting values
  m01 <- mle2(m01_prep_function,
            start = list(a1 = 23, b1 = 5, a2 = 10, b2 = 1, theta = 1),
            method = "Nelder-Mead",
            control = list(maxit = 5000)
            )

  summary(m01)

anovir documentation built on Oct. 24, 2020, 9:08 a.m.