cennormal1 {VGAM} | R Documentation |
Maximum likelihood estimation for the normal distribution with left and right censoring.
cennormal1(lmu = "identity", lsd = "loge", emu = list(), esd = list(), imethod = 1, zero = 2)
lmu, lsd, emu, esd |
Parameter link functions and its extra arguments,
applied to the mean and standard deviation parameters.
See |
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 |
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.
An object of class "vglmff"
(see vglmff-class
).
The object is used by modelling functions such as vglm
,
and vgam
.
This function is an alternative to tobit
but cannot handle a matrix response
and uses different working weights.
If there are no censored observations then normal1
is recommended instead.
T. W. Yee
cdata = data.frame(x2 = runif(nn <- 1000)) # ystar are true values cdata = transform(cdata, ystar = rnorm(nn, m = 100 + 15 * x2, sd = exp(3))) ## Not run: with(cdata, hist(ystar)) cdata = transform(cdata, 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 ## Not run: with(cdata, hist(y)) Extra = list(leftcensored = with(cdata, ystar < L), rightcensored = with(cdata, ystar > U)) fit1 = vglm(y ~ x2, cennormal1, cdata, crit = "c", extra = Extra, trace = TRUE) fit2 = vglm(y ~ x2, tobit(Lower = with(cdata, L), Upper = with(cdata, U)), cdata, crit = "c", trace = TRUE) coef(fit1, matrix = TRUE) max(abs(coef(fit1, matrix = TRUE) - coef(fit2, matrix = TRUE))) # Should be 0 names(fit1@extra)