nn <- 1000; Scale <- exp(2)
rdata <- data.frame(ystar = rrayleigh(nn, scale = Scale))
fit <- vglm(ystar ~ 1, rayleigh, rdata, trace = TRUE, crit = "c")
head(fitted(fit))
with(rdata, mean(ystar))
coef(fit, matrix = TRUE)
Coef(fit)
# Censored data
rdata <- transform(rdata, U = runif(nn, 5, 15))
rdata <- transform(rdata, y = pmin(U, ystar))
par(mfrow = c(1,2)); hist(with(rdata, ystar)); hist(with(rdata, y))
extra <- with(rdata, list(rightcensored = ystar > U))
fit <- vglm(y ~ 1, cenrayleigh, rdata, trace = TRUE, extra = extra)
table(fit@extra$rightcen)
coef(fit, matrix = TRUE)
head(fitted(fit))
Run the code above in your browser using DataLab