weibull 拟合的预测与原始数据分布不匹配
Predictions from a weibull fit don't match original data distribtuion
作为这个问题的后续:Interpreting Weibull parameters from survreg,我试图理解为什么基于模型拟合的预测直方图似乎与原始数据的直方图不匹配。使用从该问题中借用的代码的示例:
library(survival)
y <- rweibull(1000, shape=2, scale=5)
r <- survreg(Surv(y)~1, dist="weibull")
a <- 1/r$scale # Approximately 2
b <- exp( coef(r) ) # Approximately 5
y2 <- b * ( -log( 1-runif(1000) ) ) ^(1/a)
y3 <- rweibull(1000, shape=a, scale=5)
df2 <- data.frame(y,y2,y3)
df2 <- gather(df2)
ggplot(df2, aes(x = value, fill=key)) + geom_histogram()
剧情是这样的:
为什么每个y在y轴上达到的高度都不一样?
使用geom_histogram(position = "identity")
.
作为这个问题的后续:Interpreting Weibull parameters from survreg,我试图理解为什么基于模型拟合的预测直方图似乎与原始数据的直方图不匹配。使用从该问题中借用的代码的示例:
library(survival)
y <- rweibull(1000, shape=2, scale=5)
r <- survreg(Surv(y)~1, dist="weibull")
a <- 1/r$scale # Approximately 2
b <- exp( coef(r) ) # Approximately 5
y2 <- b * ( -log( 1-runif(1000) ) ) ^(1/a)
y3 <- rweibull(1000, shape=a, scale=5)
df2 <- data.frame(y,y2,y3)
df2 <- gather(df2)
ggplot(df2, aes(x = value, fill=key)) + geom_histogram()
剧情是这样的:
为什么每个y在y轴上达到的高度都不一样?
使用geom_histogram(position = "identity")
.