if (FALSE) {
nn <- 5000; prop.lost <- 0.40 # Proportion lost to truncation
wdata <- data.frame(x2 = runif(nn)) # Complete Weibull data
wdata <- transform(wdata,
Betaa = exp(1)) # > 2 okay (satisfies regularity conds)
wdata <- transform(wdata, Alpha = exp(0.5 - 1 * x2))
wdata <- transform(wdata, Shape = Betaa,
# aaa = Betaa,
# bbb = 1 / Alpha^(1 / Betaa),
Scale = 1 / Alpha^(1 / Betaa))
wdata <- transform(wdata, y2 = rweibull(nn, Shape, scale = Scale))
summary(wdata)
# Proportion lost:
lower.limit2 <- with(wdata, quantile(y2, prob = prop.lost))
# Smaller due to truncation:
wdata <- subset(wdata, y2 > lower.limit2)
fit1 <- vglm(y2 ~ x2, maxit = 100, trace = TRUE,
truncweibull(lower.limit = lower.limit2), wdata)
coef(fit1, matrix = TRUE)
summary(fit1)
vcov(fit1)
head(fit1@extra$lower.limit)
}
Run the code above in your browser using DataLab