ic_sample: Draw samples from an icenReg model

Description Usage Arguments Details Author(s) Examples

View source: R/user_utilities.R

Description

Samples response values from an icenReg fit conditional on covariates.

Usage

1
ic_sample(fit, newdata = NULL, sampleType = "fullSample", samples = 5)

Arguments

fit

icenReg model fit

newdata

data.frame containing covariates. If blank, will use data from model

sampleType

type of samples See details for options

samples

Number of samples

Details

Returns a matrix of samples. Each row of the matrix corresponds with a subject with the covariates of the corresponding row of newdata. For each column of the matrix, the same sampled parameters are used to sample response variables.

If newdata is left blank, will provide estimates for original data set.

There are several options for how to sample. To get random samples without accounting for error in the estimated parameters imputeType ='fixedParSample' takes a random sample of the response variable, conditional on the response interval, covariates and estimated parameters at the MLE. Alternatively, imputeType = 'fullSample' first takes a random sample of the coefficients, (assuming asymptotic normality for the ic_par) and then takes a random sample of the response variable, conditional on the response interval, covariates, and the random sample of the coefficients.

Author(s)

Clifford Anderson-Bergman

Examples

1
2
3
4
5
6
7
8
simdata <- simIC_weib(n = 500)

fit <- ic_par(cbind(l, u) ~ x1 + x2,
              data = simdata)

newdata = data.frame(x1 = c(0, 1), x2 = c(1,1))

sampleResponses <- ic_sample(fit, newdata = newdata, samples = 100)

Example output

Loading required package: survival
Loading required package: Rcpp
Loading required package: coda

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