Interpreting Weibull parameters from survreg

后端 未结 2 1728
终归单人心
终归单人心 2021-02-06 00:19

I am trying to generate an inverse Weibull distribution using parameters estimated from survreg in R. By this I mean I would like to, for a given probability (which will be a ra

相关标签:
2条回答
  • 2021-02-06 00:31

    The key is that the shape parameter the rweibull generates is the inverse of the shape parameter the survreg inputs

    0 讨论(0)
  • 2021-02-06 00:49

    This is explained in the manual page, ?survreg (in the "examples" section).

    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 * ( -ln( 1-runif(1000) ) ) ^(1/a)
    y3 <- rweibull(1000, shape=a, scale=5)
    # Check graphically that the distributions are the same
    plot(sort(y), sort(y2))
    abline(0,1)
    
    0 讨论(0)
提交回复
热议问题