Aliases: survreg.distributions
Keywords: survival
### ** Examples # time transformation survreg(Surv(time, status) ~ ph.ecog + sex, dist='weibull', data=lung)
Call: survreg(formula = Surv(time, status) ~ ph.ecog + sex, data = lung, dist = "weibull") Coefficients: (Intercept) ph.ecog sex 5.8195907 -0.3557319 0.4013684 Scale= 0.7310495 Loglik(model)= -1133.1 Loglik(intercept only)= -1147.4 Chisq= 28.73 on 2 degrees of freedom, p= 5.76e-07 n=227 (1 observation deleted due to missingness)
# change the transformation to work in years # intercept changes by log(365), everything else stays the same my.weibull <- survreg.distributions$weibull my.weibull$trans <- function(y) log(y/365) my.weibull$itrans <- function(y) 365*exp(y) survreg(Surv(time, status) ~ ph.ecog + sex, lung, dist=my.weibull)
Call: survreg(formula = Surv(time, status) ~ ph.ecog + sex, data = lung, dist = my.weibull) Coefficients: (Intercept) ph.ecog sex -0.08030664 -0.35573188 0.40136844 Scale= 0.7310495 Loglik(model)= -1133.1 Loglik(intercept only)= -1147.4 Chisq= 28.73 on 2 degrees of freedom, p= 5.76e-07 n=227 (1 observation deleted due to missingness)
# Weibull parametrisation y<-rweibull(1000, shape=2, scale=5) survreg(Surv(y)~1, dist="weibull")
Call: survreg(formula = Surv(y) ~ 1, dist = "weibull") Coefficients: (Intercept) 1.607703 Scale= 0.4994601 Loglik(model)= -2201.6 Loglik(intercept only)= -2201.6 n= 1000
# survreg scale parameter maps to 1/shape, linear predictor to log(scale) # Cauchy fit mycauchy <- list(name='Cauchy', init= function(x, weights, ...) c(median(x), mad(x)), density= function(x, parms) { temp <- 1/(1 + x^2) cbind(.5 + atan(x)/pi, .5+ atan(-x)/pi, temp/pi, -2 *x*temp, 2*temp*(4*x^2*temp -1)) }, quantile= function(p, parms) tan((p-.5)*pi), deviance= function(...) stop('deviance residuals not defined') ) survreg(Surv(log(time), status) ~ ph.ecog + sex, lung, dist=mycauchy)
Call: survreg(formula = Surv(log(time), status) ~ ph.ecog + sex, data = lung, dist = mycauchy) Coefficients: (Intercept) ph.ecog sex 5.4517240 -0.3979387 0.4692383 Scale= 0.4788955 Loglik(model)= -274.6 Loglik(intercept only)= -294.9 Chisq= 40.75 on 2 degrees of freedom, p= 1.42e-09 n=227 (1 observation deleted due to missingness)