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