Description Usage Format Details See Also Examples
List of distributions for accelerated failure models. These are locationscale families for some transformation of time. The entry describes the cdf F and density f of a canonical member of the family.
1 
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, 
1F,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 
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=1e^{e^t}.
When the logarithm of survival time has one of the first three distributions
we obtain respectively weibull
, lognormal
, and
loglogistic
. The locationscale parameterization 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", "Logistic" 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.
survreg
, pweibull
,
pnorm
,plogis
, pt
,
survregDtest
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27  # 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 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(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.8e07
n=227 (1 observation deleted due to missingness)
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.8e07
n=227 (1 observation deleted due to missingness)
Call:
survreg(formula = Surv(y) ~ 1, dist = "weibull")
Coefficients:
(Intercept)
1.631871
Scale= 0.4991687
Loglik(model)= 2226.4 Loglik(intercept only)= 2226.4
n= 1000
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.4e09
n=227 (1 observation deleted due to missingness)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.