使用我的数据,我使用 VGAM 包创建了对数刻度(限制/比例赔率)累积概率和无限制累积概率,如下所示(使用模拟数据进行):
vglm(data[,2]~log(data[,1]),cumulative(link='probit',parallel = TRUE, reverse = TRUE))
vglm(data[,2]~data[,1],cumulative(link='probit',parallel = FALSE, reverse = TRUE))
#Results from log probit (int = intercept; slope = slope)
intlog1 <- 13.524476
intlog2 <- 15.273834
slopelog <- 3.955213
#Results from unrestricted (int = intercept; slope = slope)
int1 <- 3.62633019
int2 <- 4.30913284
slope <- 0.09444457
slope2 <- 0.07985183
#Creating the plots
plot.unrest = function ()
{
age = seq(0, 100, 0.1)
p1 = 1 - plnorm(age, intlog1/slopelog,1/slopelog)
p2 = 1 - plnorm(age,intlog2/slopelog,1/slopelog)
plot(age, p1, type = "l", ylim = c(0, 1), main = "Data", xlab = "Age", ylab = "Probability in Stage",col='gray',lwd = 2)
lines(age, p2 - p1, lty = 3, lwd = 2, col = 'gray')
lines(age, 1 - p2, lty = 2, lwd = 2, col = 'gray')
legend(x = 75, y = 0.5, c("P(Stage 1)", "P(Stage 2)", "P(Stage 3)"), lwd = rep(2, 3), lty = c(1, 3, 2), bty = "n")
p1 = 1 - pnorm(age,int1/slope1, 1/slope1)
p2 = 1 - pnorm(age,int2/slope2, 1/slope2)
lines(age, p1, lwd=2)
lines(age, p2 - p1, lty = 3, lwd = 2)
lines(age, 1 - p2 , lty = 2, lwd = 2)
}
plot.unrest()
我也想绘制 95% 的可信区间,但我不知道如何。我了解confintvglm
计算它,但我不确定如何正确使用和绘制它。