ic_bayes: Bayesian Regression Models for Interval Censored Data

Description Usage Arguments Details Author(s) Examples

View source: R/ic_bayes.R

Description

Fits a Bayesian regression model for interval censored data. Can fit a proportional hazards, proportional odds or accelerated failure time model.

Usage

1
2
3
ic_bayes(formula, data, logPriorFxn = function(x) return(0), model = "ph",
  dist = "weibull", weights = NULL, controls = bayesControls(),
  useMCores = F)

Arguments

formula

Regression formula. Response must be a Surv object of type 'interval2' or cbind. See details.

data

Dataset

logPriorFxn

An R function that computes the log prior

model

What type of model to fit. Current choices are "ph" (proportional hazards), "po" (proportional odds) or "aft" (accelerated failure time)

dist

What baseline parametric distribution to use. See details for current choices

weights

vector of case weights. Not standardized; see details

controls

Control parameters passed to samplers

useMCores

Should multiple cores be used? Each core is used to run a single chain.

Details

Currently supported distributions choices are "exponential", "weibull", "gamma", "lnorm", "loglogistic" and "generalgamma" (i.e. generalized gamma distribution).

The logPriorFxn should take in the a vector of values corresponding to all the parameters of the model (baseline parameters first, regression parameters second) and returns the log prior, calculated up to an additive constant. Default behavior is to use a flat prior. See examples for an example of using the log prior function.

Sampling is done by a single MH block updater on all the parameters. See ?bayesControls for more details.

Response variable should either be of the form cbind(l, u) or Surv(l, u, type = 'interval2'), where l and u are the lower and upper ends of the interval known to contain the event of interest. Uncensored data can be included by setting l == u, right censored data can be included by setting u == Inf or u == NA and left censored data can be included by setting l == 0.

Does not allow uncensored data points at t = 0 (i.e. l == u == 0), as this will lead to a degenerate estimator for most parametric families. Unlike the current implementation of survival's survreg, does allow left side of intervals of positive length to 0 and right side to be Inf.

In regards to weights, they are not standardized. This means that if weight[i] = 2, this is the equivalent to having two observations with the same values as subject i.

For numeric stability, if abs(right - left) < 10^-6, observation are considered uncensored rather than interval censored with an extremely small interval.

Author(s)

Clifford Anderson-Bergman

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
data(miceData)

flat_prior_model <- ic_bayes(cbind(l, u) ~ grp, data = miceData)
# Default behavior is flat prior

priorFxn <- function(pars){
 ans <- 0
 ans <- ans + dnorm(pars[1], log = TRUE)
 ans <- ans + dnorm(pars[3], sd = 0.25, log = TRUE)
}
# Prior function puts N(0,1) prior on baseline shape parameter (first parameter)
# flat prior on baseline scale parameter (second parameter)
# and N(0,0.25) on regression parameter (third parameter)

inform_prior_fit <- ic_bayes(cbind(l, u) ~ grp, 
                             data = miceData,
                             logPriorFxn = priorFxn)

summary(flat_prior_model)
summary(inform_prior_fit)
# Note tight prior on the regression pulls posterior mean toward 0

icenReg documentation built on Oct. 16, 2018, 1:04 a.m.