Examples for 'survival::residuals.survreg'


Compute Residuals for 'survreg' Objects

Aliases: residuals.survreg residuals.survreg.penal

Keywords: survival

### ** Examples

fit <- survreg(Surv(futime, death) ~ age + sex, mgus2)
summary(fit)   # age and sex are both important
Call:
survreg(formula = Surv(futime, death) ~ age + sex, data = mgus2)
               Value Std. Error      z       p
(Intercept)  8.85979    0.23842  37.16 < 2e-16
age         -0.05360    0.00312 -17.19 < 2e-16
sexM        -0.31874    0.06357  -5.01 5.3e-07
Log(scale)  -0.02840    0.02787  -1.02    0.31

Scale= 0.972 

Weibull distribution
Loglik(model)= -5528.3   Loglik(intercept only)= -5699
	Chisq= 341.42 on 2 degrees of freedom, p= 7.3e-75 
Number of Newton-Raphson Iterations: 5 
n= 1384 
rr  <- residuals(fit, type='matrix')
sum(rr[,1]) - with(mgus2, sum(log(futime[death==1]))) # loglik
[1] -5528.267
plot(mgus2$age, rr[,2], col= (1+mgus2$death)) # ldresp
plot of chunk example-survival-residuals.survreg-1

[Package survival version 3.5-3 Index]