Regression with Frailty in Survival analysis Kyuson Lim November 26, 2021 STATS 756 2 Kyuson Lim Contents 1 Acknowledgement 5 2 Introduction 7 2.1 8 Understanding the concept of cox-proportional hazard model . . . . . . 2.1.1 3 Partial Likelihood 3.1 3.2 4 5 Parametric cox model with frailty term . . . . . . . . . . . . . Breslow Partial likelihood 10 11 . . . . . . . . . . . . . . . . . . . . . . . . 11 3.1.1 Example for computing Partial likelihood . . . . . . . . . . . . 12 3.1.2 Penalize Partial Likelihood (PPL) . . . . . . . . . . . . . . . . 14 Newton-Raphson Method . . . . . . . . . . . . . . . . . . . . . . . . . 14 3.2.1 15 Newton-Raphson algorithm - example . . . . . . . . . . . . . . Simulation for data 17 4.1 Simulation study: Infection in Kidney patients . . . . . . . . . . . . . . 17 4.2 Simulation study: testing the model fit . . . . . . . . . . . . . . . . . . 18 4.3 Extensions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 4.3.1 20 Generalized gamma frailty model . . . . . . . . . . . . . . . . Appendix: R codes 21 3 STATS 756 4 Kyuson Lim CONTENTS Chapter 1 Acknowledgement The purpose of this report is solely on the interpretation and analysis of ‘Regression with Frailty in survival analysis’ written by the McGilchrist and Aisbett in 1991. Note that the concepts of penalized partial likelihood and the Newton-Raphson algorithm used for elicitation of maximized coefficients in the Cox model extends to the paper of ’Estimation in generalized mixed models‘ with the same author. Moreover, the original dataset that is used for the analysis is attached in the R package ‘survival’ which is imported to be re-assessed. More specification of the original dataset, Infections in kidney patients, is found from the R document of ‘survival’ page 55. Also, this report rephrase for the specification of dataset containing the outlier, model specification and the codes to have used in the ’survival‘ package. However, the examples and codes are extracted from the textbook, ‘Applied survival analysis using R’ written by the author Dirk F. Moore for graph visualization of optimization in Newton-Raphson method and the guidance for elicitation process. Combined with the textbook ‘Frailty models in survival analysis’ written by the Andreas Wienke, the frailty terms are defined and derived for the equation of log likelihood as well as the penalized partial likelihood. Interpretation for the original paper and optimization method are defined by rephrasing the definitions used in the textbooks. Finally, the reports briefly extend to the paper of ‘Generalized gamma frailty model’ written by Professor Dr. Balakrishnan which extends the idea and method of the original paper as to be used with. This paper is highly reputable in the matter where the distribution of frailty term is parametric to be specified for lognormal, Weibull frailty model and the generalized gamma distribution. The comparison of the model performance with these distributions and the Newton-Raphson algorithm is used for extension of the original paper. I am pleased thank for all textbooks and guideline for writing this report in behalf of the course STATS 756 for analysis in Cox model with frailty terms. Also, I would be pleased to thank for Professor Dr. Balakishnan to support me to learn with the ideas of survival analysis and censoring and writing the report. 5 STATS 756 6 Kyuson Lim CHAPTER 1. ACKNOWLEDGEMENT Chapter 2 Introduction To begin with, some concepts and relationship between the survival function and the hazard function is explained. First of all, the Cox proportional-hazards model (Cox, 1972) is essentially a regression model commonly used statistical in medical research for investigating the association between the survival time of patients and one or more predictor variables. A graph of survival analysis The empirical hazard function is a step function evaluated at each time. Therefore, The survival probability, π(π‘) is the probability that an individual survives from time origin to a specified future time π‘. The hazard, β(π‘) is a continuous probability function that an individual who is under observation at a time π‘ has an event at that time. These two hazard function and survival function is modeled as follows. As the survival function is a decreasing from π‘ = 0 → ∞ for continuous variable, the distribution function is explained by πΉ (π‘) = π(π ≤ π‘). Hence, ∫ ∞ π(π‘) = π(π > π‘) = π (π’)ππ’ = 1 − πΉ (π‘) π‘ π (π‘) π(π‘) and instantaneous time ∫(4π‘ → 0) π‘ π (log π(π‘)) π (π‘) − ππ‘ = 1−πΉ (π‘) for cdf of π» (π‘) = 0 β(π’)ππ’. For survival time π, hazard function β(π‘) = illustrate the event after time π‘, β(π‘) = 7 STATS 756 Kyuson Lim Therefore, π» (π‘) = − log(π(π‘)) and π(π‘) = exp(−π» (π‘)). If one is known, other two are easily determined. 2.1 Understanding the concept of cox-proportional hazard model In the survival analysis, the paper of regression with frailty in survival analysis contains the data for the infections of kidney patients. The survival analysis plot for the infection of 76 Kidney patients in the paper, analyzed by R shows that Figure 2.1: A graph of survival analysis for Kidney data As to have known with, the survival function defines a probability of surviving up to a point π‘, π(π‘) = π(π > π‘). Since the hazard function is an instantaneous failure rate, given subject has survived up to time π‘ and fails in next small interval of time, >π‘) β(π‘) = limπΏ→0 π(π‘<π <π‘+πΏ|π . πΏ In this report, some of the goals for understanding the cox proportional hazard model with frailty terms include • Cox proportional hazard model analyzes the various influential covariates simultaneously, where β0 (π‘) is non-parametric part and exp( π·xπ ) is parametric part. • Fit regression model to censored survival data and partial likelihood allows us to compare 2 groups of survival data. • By maximized log-likelihood of π·, Newton-Raphson algorithm is used to derive the estimates. 8 CHAPTER 2. INTRODUCTION Kyuson Lim STATS 756 An endpoint, a single cause of death, and the survival times of each case have been assumed to be independent. Methods for analyzing such survival data is not sufficient if cases are not independent or if the event could occur repeatedly. Hence, the proportional hazard model is described as β(π‘|xπ ) = β0 (π‘) exp( π·0xπ (π‘)), π·0 = (π½1 , .., π½ π ) A cluster-specific random effect terms have a relative effect on the baseline hazard function, β0 (xπ ), reflect underlying hazard for subjects with all covariates x1 , ..., x π equal to 0. We can find that the distribution of the baseline hazard function is a non-parametric part and the parametric part is exp( π·0xπ ) for the cox proportional hazard model to be semi-parametric. For 2 covariates, x1 = 1 and x2 = 0, a hazard rate for treated group is β1 (π‘|xπ = 1) = β0 (π‘) exp( π·), β1 (π‘|xπ = 1) = β1 (π‘). Two hazards is constant exp( π·), not dependent on time (t) and two hazards ratio of 2 groups remain proportional over time β1 (π‘) = exp( π·) β0 (π‘) Moreover, a ratio of relative Hazard of two patients (π₯1π = 1, π₯2π = 0) as explained in the lecture can be shown as exp(π½1 π₯11 + π½2 π₯12 + · · · + π½ π π₯ 1π + · · · + π½ π π₯ 1π ) β1 (π‘|x) β0 (π‘) exp( π·0x) = 0 0 = 0 β2 (π‘|x ) β0 (π‘) exp( π· x ) exp(π½1 π₯21 + π½2 π₯22 + · · · + π½ π π₯ 2π + · · · + π½ π π₯ 2π ) exp(π½1 π₯ 11 + π½2 π₯ 12 + · · · + π½ π · 1 + · · · + π½ π π₯ 1π ) exp(π½ π ) = = exp(π½ π ) exp(π½1 π₯ 21 + π½2 π₯ 22 + · · · + π½ π · 0 + · · · + π½ π π₯ 2π ) exp(0) Hence, the Cox Proportional Hazards model is a linear model for the log of the hazard ratio. = A graph of relative hazard ratio for each coefficient The relative hazard ratio of each prediction in the paper is computed as follows. The dependence of particular diseases is found to influence the relative hazard ratio. The sex is insignificant predictor to be considered as well. While age is estimated to be 1 and sex to be 0.23, the GS disease is 1.09, the AN is 1.42 and the PKD is 0.24. CHAPTER 2. INTRODUCTION 9 STATS 756 2.1.1 Kyuson Lim Parametric cox model with frailty term In clustered data, survival times of individuals that are in same unit or family, meaning that survival times within a cluster are similar, to each other than to those from other clusters then the independence no longer holds. To accommodate such structure of subjects in the same cluster is to assign each individual in a cluster a common factor known as a frailty or as random effect. A random effects incorporated for within-cluster homogeneity in outcomes 1. Shared frailty model: β(π‘|xπ π ) = β0 (π‘) exp(π½0xπ π (π‘) + π€ π ) Note that π€ π is the random effect for πth cluster for all individuals, vary across clusters. Subjects in the same cluster all share the same frailty factor. A frailty model refer to a survival model with only a random intercept. Meaning that the frailty term in the random effect, the frailty term of the model follows with some distribution such as log-normal, gamma, and Weibull distributions. In the paper, logfrailities are assumed to be normally distributed with πΈ (log(π€ π )) = 0, π ππ (log(π€ π )) = π 2 (I − M−1 110) 2 1increase/decrease hazard for distinct class 2π€ π = 1, 10u = 0 10 CHAPTER 2. INTRODUCTION Chapter 3 Partial Likelihood The goal is to estimate π· that does not depend on β0 (π‘) for ordered death time of π individuals, π‘ (1) < · · · < π‘ (π) . First, we define risk set, π (π‘ ( π) ), to be the group of individuals who are alive and uncensored at at a time prior to π‘ ( π) . The failure time π‘π is 0 when Hence, π(individuals π dies at π‘ ( π) given one individual from risk set on π (π‘ ( π) ) dies at π‘ ( π) | one death from the risk set π (π‘ ( π) ) at π‘ ( π) ) = π(individual π dies at π‘ ( π) )/π( one death at π‘ ( π) ) β0 (π‘ ( π) ) exp( π·0xπ ) βπ (π‘ π |xπ ) exp( π·0xπ ) Í π (π‘ ( π) ) = Í =Í = 0 0 π∈π (π‘ ( π) ) β π (π‘π |x π ) π∈π (π‘ ( π) ) β0 (π‘ ( π) ) exp( π· x π ) π∈π (π‘ ( π) ) exp( π· x π ) The partial likelihood differs from the likelihood as the factors are conditional probabilities and frailties are latent variables that is unobserved. Then, the partial likelihood is simply expressed as a multiplication of conditional probabilities among π samples for π events exp( π·0xπ ) πΏ ( π·) = Πππ=1 Í , π ∈ {π‘ (1) , ..., π‘ (π) }(survival time) 0 π ∈π (π‘ ( π) ) exp( π· x π ) Notice that π₯π is a vector of covariates for individual π who dies at π‘ ( π) . As we can see from the equation, the risk function prior to the πth event is not counted in the denominator. A partial likelihood allow to use unspecified baseline survival distribution to define a survival distributions of subjects based on their covariates. Also, the derivation for maximized π· could be determined by taking the log of the equation. 3.1 Breslow Partial likelihood The likelihood is also expressed with hazard function β(π₯) = π (π‘)/π(π‘). Note that the likelihood function is only for uncensored individuals. π πΏ( π·, xπ ) = Ππ=1 π (π‘π , π·) ππ π(π‘π , π·) 1−ππ π = Ππ=1 β(π‘π , π·) ππ π(π‘π .π·), β(t, π·) = β0 (π‘) exp( π·0xπ ) 11 STATS 756 Kyuson Lim As one of the simplest method, Breslow approximation adjusts both terms of the marginal method so that they have the same denominator, corresponding to all subjects at risk exp( π·0xπ ) π πΏ ( π·) = Ππ=1 Í { π ∈π (π‘ ( π) ) exp( π·0x π )} ππ Note that π‘1 , ..., π‘ π is defined for observed survival time for π individuals. Also, a ππ is an event indicator as follows. ( 0 if patient is censored ππ = 1 if patient dies Likewise, the partial likelihood is written in terms of a product of terms for each individuals, as opposed to each failure time. ππ exp( π·0xπ ) π log πΏ ( π·) = log Π π=1 Í 0 π∈π (π‘ ( π) ) exp( π· x π ) π ∑οΈ exp( π·0xπ ) ππ log Í = 0 π∈π (π‘ ( π) ) exp( π· x π ) π=1 ∑οΈ π π ∑οΈ ∑οΈ 0 0 = ππ log(exp( π· xπ )) − ππ log exp( π· x π ) π=1 = π ∑οΈ 0 ππ π· xπ − π=1 = π ∑οΈ π ∈π (π‘ ( π) ) π=1 π ∑οΈ ∑οΈ ππ log ππ π·xπ − log exp( π· x π ) π∈π (π‘ ( π) ) π=1 0 ∑οΈ 0 exp( π· x π ) (e1) π∈π (π‘ ( π) ) π=1 The partial likelihood is valid when there are no two subjects who have same event time. A variation of hazard rate attribute to dependence of risk variables or frailty terms, hence the frailty is a random component. In our paper, the We can investigate to find for the specific derivation of computation for partial likelihood as follows. 3.1.1 Example for computing Partial likelihood Now, the simple example of 6 patients with two groups, treatment and control, is shown below. At time 0, 6 patients are at a risk of experiencing an event, which is defined as group of patients for initial set π 1 . Patient 1 2 3 4 5 6 12 Survtime 6 7 10 15 19 25 Censor 1 0 1 1 0 1 Group C C T T T T CHAPTER 3. PARTIAL LIKELIHOOD Kyuson Lim STATS 756 1. Before first failure at time π‘ = 6, all 6 patients are at risk and anyone could experience event. 2. By groups, we know for each control and treatment group that exp(π₯1 π½) = exp(π₯2 π½) = exp(π₯4 π½) = 1, exp(π₯ 3 π½) = exp(π₯ 5 π½) = exp(π₯ 6 π½) = exp(π½). 3. Substitute for π 1 = Í β0 (π‘1 ) exp(π₯ π π½) , π ∈π 1 β0 (π‘ 1 ) exp(π₯ π π½) where β0 (π‘1 ) is the hazard for a subject from a control group, the equation yield for π 1 = 1β0 (π‘1 ) 3β0 (π‘1 ) exp(π½)+3β0 (π‘1 ) 4. At time 7, a control patient dropped out and at π‘ = 10, π 2 = 1 time π‘ = 15 three patients at risk to give π 3 = 2 exp(π½)+1 . = exp(π½) 3 exp(π½)+1 1 3 exp(π½)+3 . as well as at 5. At last event π‘ = 25, one subject is at risk with partial likelihood to be the product exp(π½) of all, πΏ(exp(π½)) = (3 exp(π½)+3) (3 exp(π½)+1) (2 exp(π½)+1) . 6. Taking the log transformation, π (π½) = π½ − log(3 exp(π½) + 3) − log(3 exp(π½) + 1) − log(2 exp(π½) + 1). We can put into R code for computation of the example to easily estimate the π½. Note that we used a partial likelihood to maximize for obtaining for the estimate of π½. > plsimple <- function(beta) { + psi <- exp(beta) + result <- log(psi) - log(3*psi + 3) - log(3*psi + 1) - log(2*psi + 1) + result } > result <- optim(par=0, fn = plsimple, method = "L-BFGS-B", control=list(fnscale = -1), lower = -3, upper = 1) > result$par [1] -1.326129 We may find from the maximum partial likelihood estimate, π½ˆ = −1.326 which is also found from the plot, π (π½) versus π½. The optimized maximum value achieved by the Maximum partial likelihood estimate by Newton-Rapshon algorithm The solid curved black line is a plot of the log partial likelihood over a range of values of π½. The maximum is indicated by the vertical dashed blue line, and the value of the CHAPTER 3. PARTIAL LIKELIHOOD 13 STATS 756 Kyuson Lim log-partial likelihood at a point is -3.672. The value -4.277 of the log-partial likelihood is at the null hypothesis value, π½ = 0. The tangent to the π (π½) curve at π½ = 0 is shown by the straight red line. Its slope is the derivative of the log-likelihood evaluated at π½ = 0. 3.1.2 Penalize Partial Likelihood (PPL) Taking a log, random effect are treated as penalty term in GLM by the Best Linear Unbiased Prediction (BLUP). Previously, we have defined the partial log likelihood as two terms for unknown π·. This also extend to the joint likelihood of parameters π, π· and w for two separate parts of the equations (e1). A full likelihood is also expressed as , π π π’ππ (β0 (·), π, π·) = log π (x, u|β0 (·), π, π·) = log π (x|β0 (·), π·, u) + log( π (u|π)) = π π π’ππ,1 (β0 (·), π·) + π π π’ππ,2 (β0 (π)). Maximization in PPL is a double iterative process, alternates between inner (π ππππ‘ ) and outer loop (π πππππππ§π ) until convergence. A penalty term of random effect is far away from mean value 0, by reducing a penalized partial likelihood. If log π€ π is π (0, π 2 π·) where π· is known matrix, then BLUP consists of maximizing a sum of two log-likelihood: π πππΏ (π, π·, w) = π ππππ‘ ( π·, w) − π πππππππ§π (π, w) We know π ππππ‘ ( π·, w) which is the conditional likelihood for data given frailties. Also, the π πππππππ§π (π, w) stands for the distribution for frailties. The sum is a termed a penalized likelihood function in the sense that the π πππππππ§π is a penalty function for the conditional log-likelihood of π ππππ‘ . Note that this procedure is also specified in the paper ‘Estimation in generalized mixed models’. When a Cox model with random shared frailty terms is fit, one can use the median hazard ratio as a measure of the magnitude of the effect of clustering on the hazard of the outcome. In π ππππ‘ , a Newton-Raphson uses local quadratic approximations of penalty term. Iterate to estimate π· and wπ , using the derivative of likelihood and variance matrix, V 1. 3.2 Newton-Raphson Method The Newton-Raphson algorithm is originated from Taylor’s series π (π₯) ≈ π (π₯ π ) + (π₯ − π₯ π ) π 0 (π₯ π ) + 2!1 (π₯ − π₯ π ) 2 π 00 (π₯ π ) + · · · + π!1 (π₯ − π₯ π ) π π (π) (π₯ π ) about some point, the system of non-linear equations is solved by the procedure of Newton-Raphson method. Now the Newton-Raphson method takes the first two terms of the expansion, π (π₯) = π (π₯ π ) + (π₯ − π₯ π ) π 0 (π₯ π ), and assume that π₯ = π₯ π+1 is the solution of the equation π (π₯) = 0 then 0 = π (π₯ π ) + (π₯ π+1 − π₯ π ) π 0 (π₯ π ) to be rearranged. Generally, the Newton-Raphson method could 1If V is replaced by πΈ (V), then the iterative procedure becomes the method of scoring. 14 CHAPTER 3. PARTIAL LIKELIHOOD Kyuson Lim STATS 756 only be solved for non-linear equation with a single variable. We approximate roots, π (π½) = 0. 1. Start with initial value π½ (0) of π½. 2. First-order linear approximation of π at π½ (0) + β: π (π½ (0) + β) ≈ π (π½ (0) ) + β π 0 (π½ (0) ) 3. Solve to find solution π½ (1) (updated) = π½ (0) + β of π (π½) = 0 ⇒ π (π½ (1) ) = 0 by β = −{ π 0 (π½ (0) )}−1 π (π½ (0) ) and thus π½ (1) = π½ (0) − { π 0 (π½ (0) )}−1 π (π½ (0) ) 4. Iterate until process converges π½ (π+1) ≈ π½ (π) . A GLM (poisson, logistic) uses the method of iteration for estimating the coefficients. A distribution of frailties are obtained when dependence on frailty terms. A NewtonRaphson procedure converge if sufficient variation of measure risk variables exists within each patients. 3.2.1 Newton-Raphson algorithm - example The goal is to produce better approximations to the roots of a real-valued function. π (π₯ 0 ) π 0 (π₯0 ) π₯1 = π₯0 − .. . π₯ π+1 = π₯ π − π (π₯ π ) π 0 (π₯ π ) For example, when π (π₯) = π₯ 2 − π and π 0 (π₯) = 2π₯, the initial guess is π₯ 0 = 10 and the difference is set to be small to iterate until convergence. 102 − 612 π (π₯ 0 ) = 10 − = 35.6 π 0 (π₯ 0 ) 2 × 10 π (π₯ 1 ) 35.62 − 612 = π₯1 − 0 = 35.6 − = 26.395 π (π₯ 1 ) 2 × 35.6 = · · · = 24.790 = · · · = 24.7376 = · · · = 24.738633753 π₯1 = π₯0 − π₯2 π₯3 π₯4 π₯5 However, we could implement into a set f non-linear systems to solve for π·. Simply, by the implementation of Jacobian matrix, π· π = π· π−1 − π½ ( π· π−1 ) −1 V( π· π−1 ) CHAPTER 3. PARTIAL LIKELIHOOD 15 STATS 756 Kyuson Lim With initial estimate of π·0 , w0 , the goal is to iteratively estimate π· with PPL. Loglikelihood is approximately quadratic in region of true values. Previously, we have found that maximized π ππππ‘ − π πππππππ§π gives estimators where a joint log-likelihood is π πππΏ , 2 π·0 0 −π π πππ π‘ /π π·π π· 0 −π 2 π πππ π‘ /π π·ππ 0 π·ˆ −1 ππ πππ π‘ /π π·0 −1 = +V −V , V= w0 ππ πππ π‘ /ππ 0 π −2 w0 −π 2 π πππ π‘ /π π·π π· 0 −π 2 π πππ π‘ /ππππ 0 + π −2 I wΜ ˆ wΜ has approximately The variance matrix V taken to be π 2 (I − M−1 ), 10V = 0. So, π·, a joint normal distribution with mean π·, w with variance matrix V. 16 CHAPTER 3. PARTIAL LIKELIHOOD Chapter 4 Simulation for data 4.1 Simulation study: Infection in Kidney patients Analyzed by the R package ‘survival’, the survfit of the original dataset is shown below. The data of 76 patients for > data(kidney) > kfitm1 <- coxph(Surv(time,status) ~ age + sex + disease + frailty(id, dist=’gauss’)) > kfitm1 Call: coxph(formula = Surv(time, status) ~ age + sex + disease + frailty(id, dist = "gauss"), data = kidney) coef se(coef) age 0.00489 0.01497 sex -1.69728 0.46101 diseaseGN 0.17986 0.54485 diseaseAN 0.39294 0.54482 diseasePKD -1.13631 0.82519 frailty(id, dist = "gauss se2 Chisq DF 0.01059 0.10678 1.0 0.36170 13.55454 1.0 0.39273 0.10897 1.0 0.39816 0.52016 1.0 0.61728 1.89621 1.0 17.89195 12.1 p 0.74384 0.00023 0.74131 0.47077 0.16850 0.12376 Iterations: 7 outer, 42 Newton-Raphson Variance of random effect= 0.493 Degrees of freedom for terms= 0.5 0.6 1.7 12.1 Likelihood ratio test=47.5 on 14.9 df, p=3e-05 n= 76, number of events= 58 The only regression coefficient with -1.697 that is significantly large compared to its standard error is that of the sex variable, indicating a lower infection rate for female patients. The estimate of π 2 = 0.3821. In general, the effect of the prior distribution on frailty terms is to shrink estimates toward the origin, which bias the estimate. > kfit <- coxph(Surv(time, status)~ age + sex + disease + frailty(id), kidney) > kfit Iterations: 6 outer, 35 Newton-Raphson Variance of random effect= 5e-07 I-likelihood = -179.1 Degrees of freedom for terms= 1 1 3 0 Likelihood ratio test=17.6 on 5 df, p=0.003 n= 76, number of events= 58 17 STATS 756 Kyuson Lim > round(kfit$coefficients, 3) age sex diseaseGN 0.003 -1.483 0.088 diseaseAN diseasePKD 0.351 -1.431 Compare to previously defined code where the distribution of the frailty term is unspecified, the iterations of Newton-Raphson algorithm iterates only for 35 times to find the approximated value of π·. 4.2 Simulation study: testing the model fit We also test the proportional hazards assumption for a Cox regression model fit. Note the function to have used in the analysis is ‘coxph’. > cox.zph(kfit) chisq df age 0.105 1 sex 5.953 1 disease 1.985 3 GLOBAL 7.869 5 p 0.746 0.015 0.576 0.164 Figure 4.1: A graph of coefficient vs. time The plot gives an estimate of the time-dependent coefficient π·(π‘). If the proportional hazards assumption holds then the true π·(π‘) function would be a horizontal line, slope of 0. However, the linearity of the regression model in the survival analysis could be tested via a plot of Martingale residuals. Martingale residuals are the discrepancy between the observed value of a subject’s failure indicator and its expected value, integrated over the time for which that patient was at risk. Note that the martingale residuals are plotted against covariates to detect nonlinearity. Plots of martingale residuals and partial residuals are examined against the last two of covariates, age and sex. Smooths are produced by local linear regression (using the lowess function). There are no observed non-linearity. 18 CHAPTER 4. SIMULATION FOR DATA Kyuson Lim STATS 756 Figure 4.2: A graph of residuals Comparing the magnitudes of the largest values to the regression coefficients suggests that 1 observation is influential individually. Figure 4.3: A graph of coefficient vs. time One of the males (id 21) is a large outlier, with much longer survival than his peers. If this observation is removed, then no evidence remains for a random subject effect. CHAPTER 4. SIMULATION FOR DATA 19 STATS 756 4.3 Kyuson Lim Extensions The predicted survival profiles for patients 5, and 12 is modeled. Predicted survival curves for three patients using the penalization Now, the survival analysis is not only restricted to modeling the survival time of patients but also survival time of small and medium size corporation (business) in the market as well. This implementation of the modeling is currently being studied by data scientist in South Korea for the extension of time to event data analysis. By implementation of the cox model in the financial market, we may look forward to have modeling of corporations for various improvement. 4.3.1 Generalized gamma frailty model The paper presents a frailty model using the generalized gamma distribution as the frailty distribution, and lognormal, Weibull frailty model as special cases. Written by Dr. N. Balakrishnan, the BLUP method of this paper is addressed for modeling a new frailty model with generalized gamma distribution that has more parameters to be less parametric and more flexible. Instead of EM algorithm, the Newton-Raphson algorithm is applied to obtain the MLE of parameters. The use of generalized gamma distribution as the frailty distribution in a frailty model has substantially improved the goodness-of-fit of the frailty model. The model is particularly useful in reducing errors in frailty variance estimation. Also, the performance of the likelihood ratio test depends on the cluster size. 20 CHAPTER 4. SIMULATION FOR DATA Chapter 5 Appendix: R codes library(survminer); library(lubridate); library(penalized);library(survival) # MPLE plsimple <- function(beta) { psi <- exp(beta) result <- log(psi) - log(3*psi + 3) log(3*psi + 1) - log(2*psi + 1) result } result <- optim(par=0, fn = plsimple, method = "L-BFGS-B", control=list(fnscale = -1), lower = -3, upper = 1) result$par # survival analysis, plot ggsurvplot(survfit(kfit), data = kidney) # used in report/presentation ggsurvplot(survfit(kfit), pval = F, conf.int = TRUE, risk.table = TRUE, # Add risk table risk.table.col = "strata", # Change risk table color by groups linetype = "strata", # Change line type by groups surv.median.line = "hv", # Specify median survival fun = "pct", data = kidney,legend = "none", ggtheme = theme_bw()) # hazard ratio, confidence interval ggforest(kfitm1, data = kidney, fontsize=1.25) # model diagnostics for events cox.zph(kfit) %>% plot plot(survfit(kfitm1)[1], lty=2, lwd=2, fun="event") # model validation temp <- cox.zph(kfit) print(temp) plot(temp) # display the results # plot curves 21 STATS 756 Kyuson Lim # model validation par(mfrow=c(2,2)) res <- residuals(kfit, type=’martingale’) X <- as.matrix(kidney[,c("age", "sex")]) # matrix of covariates > par(mfrow=c(2,2)) for (j in 1:2) { # residual plots plot(X[,j], res, xlab=c("age", "sex")[j], ylab="residuals") abline(h=0, lty=2) lines(lowess(X[,j], res, iter=0))} b <- coef(kfit)[c(1,2)] # regression coefficients for (j in 1:2) { # partial-residual plots plot(X[,j], b[j]*X[,j] + res, xlab=c("age", "sex")[j], ylab="component+residual") abline(lm(b[j]*X[,j] + res ~ X[,j]), lty=2) lines(lowess(X[,j], b[j]*X[,j] + res, iter=0)) } # influential point dfbeta <- residuals(kfit, type="dfbeta") par(mfrow=c(1,3)) for (j in 1:3) { plot(dfbeta[,j], ylab=names(coef(kfit))[j]) abline(h=0, lty=2) } # prediction attach(kidney) # penalization hepato.opt <- optL1(Surv(time, status), penalized=as.data.frame(kidney[,4:5]), standardize=T, fold=10) set.seed(34) hepato.prof <- profL1(Surv(time, status), penalized=kidney[,4:5], standardize=T, fold=10) hepato.pen <- penalized(Surv(time, status), penalized=kidney[,4:5], standardize=T, lambda1=hepato.opt$lambda) round(coef(hepato.pen, standardize=T), 3) hepato.predict.5 <- predict(hepato.pen, kidney[5,4:5]) hepato.predict.12 <- predict(hepato.pen, kidney[12,4:5]) par(mfrow=c(1,1)) plot(stepfun(hepato.predict.5@time[-1], hepato.predict.5@curves), do.points=F, col="blue", lwd=2, ylim=c(0,1), xlab="Time in months", ylab="Predicted survival probability") plot(stepfun(hepato.predict.12@time[-1], hepato.predict.12@curves), do.points=F, add=T, col="red") legend("bottomleft", legend=c( "Patient 5","Patient 12"), pch=1, col=c("blue", "red")) 22 CHAPTER 5. APPENDIX: R CODES Bibliography [1] McGilchrist, C. A., & Aisbett, C. W. (1991). Regression with frailty in survival analysis. Biometrics, 461-466. https://www.jstor.org/stable/2532138?casa_token=cxuDrkxyJzUAAAAA%3AEnp4ejKDMHcBHgMbROgKulGAA-lUE0Iw16oVqCSqDXPbWGutHjuBeIJ 3D0LUaBnEGd-dVIBW88Bkm6vPgEhEca24&seq=1#metadata_info_tab_contents. [2] Balakrishnan, N., & Peng, Y. (2006). Generalized gamma frailty model. Statistics in medicine, 25(16), 2797-2816. https://pubmed.ncbi.nlm.nih.gov/16220516/ [3] (R) Package ‘survival’ [Terry M. Therneau, et. al.] https://cran.r-project.org/web/packages/survival/survival.pdf [4] Moore, D. F. (2016). Applied survival analysis using R. New York, NY: Springer. https://link.springer.com/book/10.1007/978-3-319-31245-3 [5] McGilchrist, C. A. (1994). Estimation in generalized mixed models. Journal of the Royal Statistical Society: Series B (Methodological), 56(1), 61-69. https://rss.onlinelibrary.wiley.com/doi/abs/10.1111/j.2517-6161.1994.tb01959.x [6] Wienke, A. (2010). Frailty models in survival analysis. CRC press. https://www.routledge.com/Frailty-Models-in-Survival-Analysis/Wienke/p/book/9781420073881 23