survreg.distributions package:survival R Documentation _P_a_r_a_m_e_t_r_i_c _S_u_r_v_i_v_a_l _D_i_s_t_r_i_b_u_t_i_o_n_s _D_e_s_c_r_i_p_t_i_o_n: List of distributions for accelerated failure models. These are location-scale families for some transformation of time. The entry describes the cdf F and density f of a canonical member of the family. _U_s_a_g_e: survreg.distributions _F_o_r_m_a_t: There are two basic formats, the first defines a distribution de novo, the second defines a new distribution in terms of an old one. name: name of distribution variance: function(parms) returning the variance (currently unused) init(x,weights,...): Function returning an initial estimate of the mean and variance (used for initial values in the iteration) density(x,parms): Function returning a matrix with columns F, 1-F,f,f'/f,f''/f quantile(p,parms): Quantile function scale: Optional fixed value for the scale parameter parms: Vector of default values and names for any additional parameters deviance(y,scale,parms): Function returning the deviance for a saturated model; used only for deviance residuals. and to define one distribution in terms of another name: name of distribution dist: name of parent distribution trans: transformation (eg log) dtrans: derivative of transformation itrans: inverse of transformation scale: Optional fixed value for scale parameter _D_e_t_a_i_l_s: There are four basic distributions:'extreme', 'gaussian', 'logistic' and 't'. The last three are parametrised in the same way as the distributions already present in R. The extreme value cdf is F=1-e^{-e^t}. When the logarithm of survival time has one of the first three distributions we obtain respectively 'weibull', 'lognormal', and 'loglogistic'. The location-scale parameterizaion of a Weibull distribution found in 'survreg' is not the same as the parameterization of 'rweibull'. The other predefined distributions are defined in terms of these. The 'exponential' and 'rayleigh' distributions are Weibull distributions with fixed 'scale' of 1 and 0.5 respectively, and 'loggaussian' is a synonym for 'lognormal'. For speed parts of the three most commonly used distributions are hardcoded in C; for this reason the elements of 'survreg.distributions' with names of "Extreme value", "Logisitic" and "Gaussian" should not be modified. (The order of these in the list is not important, recognition is by name.) As an alternative to modifying 'survreg.distributions' a new distribution can be specified as a separate list. This is the preferred method of addition and is illustrated below. _S_e_e _A_l_s_o: 'survreg', 'pweibull', 'pnorm','plogis', 'pt', 'survregDtest' _E_x_a_m_p_l_e_s: # time transformation survreg(Surv(time, status) ~ ph.ecog + sex, dist='weibull', data=lung) # 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) # Weibull parametrisation y<-rweibull(1000, shape=2, scale=5) survreg(Surv(y)~1, dist="weibull") # survreg parameters are scale=1/shape, intercept=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(temp)/pi, .5+ atan(-temp)/pi, temp/pi, -2 *x*temp, 2*temp^2*(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)