Download presentation
Presentation is loading. Please wait.
Published byEvan Charles Modified over 9 years ago
1
Univariate Survival Analysis Prof. L. Duchateau Ghent University
2
Model specification Most survival models are defined in terms of the hazard with the hazard at time t for subject i the baseline hazard at time t the incidence vector for subject i the parameter vector
3
Hazard function Density function Cumulative distribution function Survival function Hazard function
5
Alternative models Hazard model: Baseline hazard function parametric Baseline hazard function unspecified Summary measure: hazard ratio Accelerated failure time (AFT) model: Typically parametric Summary measure: accelerator factor
6
Parametric hazard model: Analytical solution Assume constant baseline hazard (exponential lifetimes) with only control and treated group with = 0 for control and =1 for treated Likelihood for exponential:
7
Likelihood specification constant hazard Define as number of events in treated (control) group and Define as at risk time in treated (control) group and
8
Solution from likelihood specification Maximise the log likelihood function leading to
9
Analytical solution reconstitution data #The analytical solution DT<-sum(stat[trt==1]); DC<-sum(stat[trt==0]); yT<-sum(timerec[trt==1]);yC<-sum(timerec[trt==0]); lambda<-DC/yC;HR<-(DT/yT)/(DC/yC) lambda;HR
10
Exercise Obtain the analytical solution for the diagnosis data set First rework the data: #Read the data diag<-read.table("timetodiag.csv",header=T,sep=";") #Create 5 column vectors, five different variables timetodiag<-c(diag$t1,diag$t2) stat<-c(diag$c1,diag$c2) technique<-c(rep(0,106),rep(1,106)) dogid<-c(diag$dogid,diag$dogid) diagnosis<- data.frame(dogid=dogid,technique=technique,timetodiag=t imetodiag,stat=stat)
11
Variance of the estimates? Obtain the Hessian, i.e., the matrix of the second derivatives of the log likelihood which is The information matrix is then
12
Inverse of observed information matrix The observed information matrix is thus and the asymptotic variance-covariance matrix is
13
Variance estimators #The observed information matrix I<-matrix(data=c((DT+DC)/(lambda^2), yT*HR,yT*HR,lambda*yT*HR), nrow = 2, ncol = 2) V<-solve(I) V;sqrt(V) [,1] [,2] [1,] 0.0006494837 -0.003003433 [2,] -0.0030034326 0.026234568 [,1] [,2] [1,] 0.02548497 NaN [2,] NaN 0.1619709
14
Exercise Obtain the asymptotic variance estimates for the parameters of the diagnosis data set
15
Maximizer solution reconstitution data #(negative) loglikelihood exponential with l=exp(p[1]), beta=p[2] loglikelihood.exponential<-function(p){ cumhaz<- exp(p[1])*timerec*(exp(p[2]*trt)) hazard<-stat*log(exp(p[1])*exp(p[2]*trt)) loglik<-sum(hazard)-sum(cumhaz) -loglik} #Apply minimizer to minus loglikelihood function res<-nlm(loglikelihood.exponential,c(-1,0)) res;lambda<-exp(res$estimate[1]);HR<- exp(res$estimate[2]) lambda;HR
16
Variances from maximizer solution #Apply minimizer to obtain Hessian matrix res<-nlm(loglikelihood.exponential,c(-1,0),hessian=T) solve(res$hessian) [,1] [,2] [1,] 0.01388753 -0.01388753 [2,] -0.01388753 0.02623197
17
Use parameters of interest as input #(negative) loglikelihood exponential with l=p[1], HR=p[2] loglikelihood.exponentialHR<-function(p){ cumhaz<- p[1]*timerec*(exp(log( p[2])*trt)) hazard<-stat*log(p[1]*exp(log(p[2])*trt)) loglik<-sum(hazard)-sum(cumhaz) -loglik} #Apply minimizer to obtain Hessian matrix res<- nlm(loglikelihood.exponentialHR,c(lambda,HR),hessian=T,iterl im=1) solve(res$hessian) [,1] [,2] [1,] 0.0006509066 -0.003590494 [2,] -0.0035904937 0.037368602
18
Exercise Obtain the parameter estimates and their variance for the diagnosis data set using the maximizer
19
Standard software? #Univariate model-exponential library(survival) res.unadjust<- survreg(Surv(timerec,stat)~trt,dist="exponential",data=reconstituti on) res.unadjust summary(res.unadjust) lambda<-res.unadjust$coef[1]; beta<-res.unadjust$coef[2];HR<-exp(beta) lambda;beta;HR
20
Loglinear model representation Hazard model with parametric baseline hazard can be rewritten in a loglinear model representation Most often used:
21
Examples Weibull distributions – varying
22
Survival function for Weibull hazard model Assume
23
Survival function for Weibull loglinear model Assume with From this follows that and thus Based on the Gumbel assumption, the survival function becomes
24
Two presentations for Weibull event times and thus:
25
Two presentations for exponential event times and thus:
26
survreg function #unadjusted model-exponential res.unadjust<- survreg(Surv(timerec,stat)~trt,dist="exponential",data=reconstituti on) res.unadjust;summary(res.unadjust) mu<-res.unadjust$coef[1];alpha<-res.unadjust$coef[2]; lambda<- exp(-mu);beta<- -alpha;HR<-exp(beta) lambda;beta;HR
27
Exercise Obtain the parameter estimates of the diagnosis data set using the survreg function in R
28
survreg function variances #unadjusted model-exponential res.unadjust<- survreg(Surv(timerec,stat)~trt,dist="exponential",data=reconstituti on) res.unadjust;summary(res.unadjust) mu<-res.unadjust$coef[1];alpha<-res.unadjust$coef[2]; lambda<- exp(-mu);beta<- -alpha;HR<-exp(beta) lambda;beta;HR res.unadjust$var (Intercept) trt (Intercept) 0.01388889 -0.01388889 trt -0.01388889 0.02623457
29
The delta method on variance Obtaining the variance of using the variance of
30
The delta method - general Original parameters Interest in univariate cont. function Use one term Taylor expansion of with
31
The delta method - specific Interest in univariate cont. function The one term Taylor expansion of With
32
survreg function variances #unadjusted model-exponential-variances of transformed variables lambda<- exp(-mu);beta<- -alpha;HR<-exp(beta) Vlambda<- res.unadjust$var[1,1]*(lambda^2) Vbeta<- res.unadjust$var[2,2]
33
Exercise Obtain the variances parameter estimates of the diagnosis data set using the survreg function in R, and applying the delta method
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.