Learn R Programming

VGAM (version 0.8-1)

cnormal1: Censored Normal Distribution

Description

Maximum likelihood estimation for the normal distribution with left and right censoring.

Usage

cnormal1(lmu="identity", lsd="loge", imethod=1, zero=2)

Arguments

lmu, lsd
Parameter link functions applied to the mean and standard deviation parameters. See Links for more choices. The standard deviation is a positive quantity, therefore a log link is the default.
imethod
Initialization method. Either 1 or 2, this specifies two methods for obtaining initial values for the parameters.
zero
An integer vector, containing the value 1 or 2. If so, the mean or standard deviation respectively are modelled as an intercept only. Setting zero=NULL means both linear/additive predictors are modelled as functions of the explanatory

Value

  • An object of class "vglmff" (see vglmff-class). The object is used by modelling functions such as vglm, and vgam.

Details

This function is like normal1 but handles observations that are left-censored (so that the true value would be less than the observed value) else right-censored (so that the true value would be greater than the observed value). To indicate which type of censoring, input extra = list(leftcensored = vec1, rightcensored = vec2) where vec1 and vec2 are logical vectors the same length as the response. If the two components of this list are missing then the logical values are taken to be FALSE. The fitted object has these two components stored in the extra slot.

See Also

tobit, normal1, dcnormal1.

Examples

Run this code
cdata = data.frame(x = runif(nn <- 1000)) # ystar are true values
cdata = transform(cdata, ystar  = rnorm(nn, mean=100 + 15 * x, sd=exp(3)))
hist(ystar)
L = runif(nn,  80,  90) # Lower censoring points
U = runif(nn, 130, 140) # Upper censoring points
cdata = transform(cdata, y = pmax(L, ystar)) # Left  censored
cdata = transform(cdata, y = pmin(U, y))     # Right censored
hist(y)
extra = list(leftcensored = with(cdata, ystar < L),
            rightcensored = with(cdata, ystar > U))
fit = vglm(y ~ x, cnormal1(zero=2), cdata, trace=TRUE, extra=extra)
coef(fit, matrix=TRUE)
Coef(fit)
names(fit@extra)

Run the code above in your browser using DataLab