Predicted Values for a 'survreg' Object Description: Predicted values for a 'survreg' object Usage: ## S3 method for class 'survreg': predict(object, newdata, type=c("response", "link", "lp", "linear", "terms", "quantile", "uquantile"), se.fit=FALSE, terms=NULL, p=c(0.1, 0.9), na.action=na.pass, ...) Arguments: object: result of a model fit using the 'survreg' function. newdata: data for prediction. If absent predictions are for the subjects used in the original fit. type: the type of predicted value. This can be on the original scale of the data (response), the linear predictor ('"linear"', with '"lp"' as an allowed abbreviation), a predicted quantile on the original scale of the data ('"quantile"'), a quantile on the linear predictor scale ('"uquantile"'), or the matrix of terms for the linear predictor ('"terms"'). At this time '"link"' and linear predictor ('"lp"') are identical. se.fit: if 'TRUE', include the standard errors of the prediction in the result. terms: subset of terms. The default for residual type '"terms"' is a matrix with one column for every term (excluding the intercept) in the model. p: vector of percentiles. This is used only for quantile predictions. na.action: applies only when the 'newdata' argument is present, and defines the missing value action for the new data. The default is to include all observations. ...: for future methods Value: a vector or matrix of predicted values. References: Escobar and Meeker (1992). Assessing influence in regression analysis with censored data. _Biometrics,_ 48, 507-528. Examples: # Draw figure 1 from Escobar and Meeker fit <- survreg(Surv(time,status) ~ age + age^2, data=stanford2, dist='lognormal') plot(stanford2$age, stanford2$time, xlab='Age', ylab='Days', xlim=c(0,65), ylim=c(.01, 10^6), log='y') pred <- predict(fit, newdata=list(age=1:65), type='quantile', p=c(.1, .5, .9)) matlines(1:65, pred, lty=c(2,1,2), col=1) # Predicted Weibull survival curve for a lung cancer subject with # ECOG score of 2 lfit <- survreg(Surv(time, status) ~ ph.ecog, data=lung) pct <- 1:98/100 # The 100th percentile of predicted survival is at +infinity ptime <- predict(lfit, newdata=data.frame(ph.ecog=2), type='quantile', p=pct, se=TRUE) matplot(cbind(ptime$fit, ptime$fit + 2*ptime$se.fit, ptime$fit - 2*ptime$se.fit)/30.5, 1-pct, xlab="Months", ylab="Survival", type='l', lty=c(1,2,2), col=1) ######################## Residuals. Compute Residuals for 'survreg' Objects Description: This is a method for the function 'residuals' for objects inheriting from class 'survreg'. Usage: ## S3 method for class 'survreg': residuals(object, type=c("response", "deviance","dfbeta","dfbetas", "working","ldcase","ldresp","ldshape", "matrix"), rsigma=TRUE, collapse=FALSE, weighted=FALSE, ...) Arguments: object: an object inheriting from class 'survreg'. type: type of residuals, with choices of '"response"', '"deviance"', '"dfbeta"', '"dfbetas"', '"working"', '"ldcase"', '"lsresp"', '"ldshape"', and '"matrix"'. See the LaTeX documentation ('survival/doc/survival.ps.gz') for more detail. rsigma: include the scale parameters in the variance matrix, when doing computations. (I can think of no good reason not to). collapse: optional vector of subject groups. If given, this must be of the same length as the residuals, and causes the result to be per group residuals. weighted: give weighted residuals? Normally residuals are unweighted. ...: other unused arguments Value: A vector or matrix of residuals is returned. Response residuals are on the scale of the original data, working residuals are on the scale of the linear predictor, and deviance residuals are on log-likelihood scale. The dfbeta residuals are a matrix, where the ith row gives the approximate change in the coefficients due to the addition of subject i. The dfbetas matrix contains the dfbeta residuals, with each column scaled by the standard deviation of that coefficient. The matrix type produces a matrix based on derivatives of the log-likelihood function. Let L be the log-likelihood, p be the linear predictor X %*% coef, and s be log(sigma). Then the 6 columns of the matrix are L, dL/dp,ddL/(dp dp), dL/ds, ddL/(ds ds) and ddL/(dp ds). Diagnostics based on these quantities are discussed in an article by Escobar and Meeker. The main ones are the likelihood displacement residuals for perturbation of a case weight ('ldcase'), the response value ('ldresp'), and the 'shape'. References: Escobar, L. A. and Meeker, W. Q. (1992). Assessing influence in regression analysis with censored data. Biometrics:48,507-528. Examples: fit <- survreg(Surv(time,status) ~x, aml) rr <- residuals(fit, type='matrix')