samplecensored: Inverse sampling - GAMLSS

Description Usage Arguments Value Examples

View source: R/samplecensored.R

Description

Inverse sampling of censored variables to impute only valid observations, conditional on the respective fit.

Usage

1
2
samplecensored(object, censtype, predictdata, fitdata, censor,
  quantiles = c(0.05, 0.25, 0.5, 0.75, 0.95), intervalstart = NULL)

Arguments

object

gamlss object. Fitted model whose parameters are predicted for predictdata.

censtype

character. Specifies the type of censoring (right/left/interval/missing).

predictdata

dataframe. Predict-data of the missing/censored observations, for which imputations are drawn.

fitdata

data.frame. The orignal dataset upon which gamlss was fitted.

censor

character. Name of the (damaged) column to be predicted on in predictdata. This is only required if censtype is NOT "missing".

quantiles

numeric vector. Containing the quantiles to be evaluated in the conditoned distribution, i.e. conditoned on the parameters and the information contained in the censored value.

intervalstart

character. Name of the column of the interval's starting values. By convention, the starting duration in this column is assumed to be the time passed without failure, before entering the interval, in which the exact time of failure is unknown.

Value

Returns draws and quantiles.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
# Simulating a dataset
ld <- simulateData(n= 300,
param.formula = list(mu = ~exp(x1) + x2 + x3, sigma = ~sin(x2)),
name = 'x1', subset = ~ (x2 < 0.3 & x3 < 0.4), prob = 0.8, 
damage =c(0.3, 0.9), family = 'NO', 
correlation = NULL)$defected

# Fitting a gamlss model
lmodel <- gamlss(formula = y ~ . -indicator, data=ld)
nl <- length(ld$x1[ld$indicator==1])
lpredict.df <- data.frame(x1 = runif(n = nl), x2 = runif(n = nl), x3 = runif(n = nl), indicator = 1)
samplecensored(lmodel ,censtype = 'left', lpredict.df, ld, censor = "x1")

TiStat/Imputegamlss documentation built on May 20, 2019, 9:25 a.m.