Density, cumulative distribution function, quantile function and random
generation for the set of distributions
supported by the survreg
function.
dsurvreg(x, mean, scale=1, distribution='weibull', parms)
psurvreg(q, mean, scale=1, distribution='weibull', parms)
qsurvreg(p, mean, scale=1, distribution='weibull', parms)
rsurvreg(n, mean, scale=1, distribution='weibull', parms)
vector of quantiles.
Missing values (NA
s) are allowed.
vector of quantiles.
Missing values (NA
s) are allowed.
vector of probabilities.
Missing values (NA
s) are allowed.
number of random deviates to produce
vector of linear predictors for the model.
This is replicated to be the same length as p
, q
or n
.
vector of (positive) scale factors.
This is replicated to be the same length as p
,
q
or n
.
character string giving the name of the distribution. This must be one
of the elements of survreg.distributions
optional parameters, if any, of the distribution. For the t-distribution this is the degrees of freedom.
density (dsurvreg
),
probability (psurvreg
),
quantile (qsurvreg
), or
for the requested distribution with mean and scale
parameters mean
and
sd
.
Elements of q
or
p
that are missing will cause the corresponding
elements of the result to be missing.
The location
and scale
values are as they would be for survreg
.
The label "mean" was an unfortunate choice (made in mimicry of qnorm);
since almost none of these distributions are symmetric it will not
actually be a mean, but corresponds instead to the linear predictor of
a fitted model.
Translation to the usual parameterization found in a textbook is not
always obvious.
For example, the Weibull distribution is fit using the
Extreme value distribution along with a log transformation.
Letting
Kalbfleisch, J. D. and Prentice, R. L. (1970). The Statistical Analysis of Failure Time Data Wiley, New York.
# NOT RUN {
# List of distributions available
names(survreg.distributions)
# }
# NOT RUN {
[1] "extreme" "logistic" "gaussian" "weibull" "exponential"
[6] "rayleigh" "loggaussian" "lognormal" "loglogistic" "t"
# }
# NOT RUN {
# Compare results
all.equal(dsurvreg(1:10, 2, 5, dist='lognormal'), dlnorm(1:10, 2, 5))
# Hazard function for a Weibull distribution
x <- seq(.1, 3, length=30)
haz <- dsurvreg(x, 2, 3)/ (1-psurvreg(x, 2, 3))
# }
# NOT RUN {
plot(x, haz, log='xy', ylab="Hazard") #line with slope (1/scale -1)
# }
Run the code above in your browser using DataLab