Skip to contents

parfrailty fits shared frailty gamma-Weibull models. It is specifically designed to work with the function standardize_parfrailty, which performs regression standardization in shared frailty gamma-Weibull models.

Usage

parfrailty(formula, data, clusterid, init)

Arguments

formula

an object of class "formula", in the same format as accepted by the coxph function.

data

a data frame containing the variables in the model.

clusterid

a string containing the name of a cluster identification variable.

init

an optional vector of initial values for the model parameters.

Value

An object of class "parfrailty" which is a list containing:

est

the Maximum Likelihood (ML) estimates \(\{\log(\hat{\alpha}),\log(\hat{\eta}), \log(\hat{\phi}),\hat{\beta}\}\).

vcov

the variance-covariance vector of the ML estimates.

score

a matrix containing the cluster-specific contributions to the ML score equations.

Details

parfrailty fits the shared frailty gamma-Weibull model $$\lambda(t_{ij}|C_{ij})=\lambda(t_{ij};\alpha,\eta)U_i\exp\{h(C_{ij};\beta)\},$$ where \(t_{ij}\) and \(C_{ij}\) are the survival time and covariate vector for subject \(j\) in cluster \(i\), respectively. \(\lambda(t;\alpha,\eta)\) is the Weibull baseline hazard function $$\eta t^{\eta-1}\alpha^{-\eta},$$ where \(\eta\) is the shape parameter and \(\alpha\) is the scale parameter. \(U_i\) is the unobserved frailty term for cluster \(i\), which is assumed to have a gamma distribution with scale = 1/shape = \(\phi\). \(h(X;\beta)\) is the regression function as specified by the formula argument, parameterized by a vector \(\beta\). The ML estimates \(\{\log(\hat{\alpha}),\log(\hat{\eta}),\log(\hat{\phi}),\hat{\beta}\}\) are obtained by maximizing the marginal (over \(U\)) likelihood.

Note

If left truncation is present, it is assumed that it is strong left truncation. This means that even if the truncation time may be subject-specific, the whole cluster is unobserved if at least one subject in the cluster dies before his/her truncation time. If all subjects in the cluster survive beyond their subject-specific truncation times, then the whole cluster is observed (Van den Berg and Drepper, 2016).

References

Dahlqwist E., Pawitan Y., Sjölander A. (2019). Regression standardization and attributable fraction estimation with between-within frailty models for clustered survival data. Statistical Methods in Medical Research 28(2), 462-485.

Van den Berg G.J., Drepper B. (2016). Inference for shared frailty survival models with left-truncated data. Econometric Reviews, 35(6), 1075-1098.

Author

Arvid Sjölander and Elisabeth Dahlqwist.

Examples



require(survival)
#> Loading required package: survival

# simulate data
set.seed(5)
n <- 200
m <- 3
alpha <- 1.5
eta <- 1
phi <- 0.5
beta <- 1
id <- rep(1:n, each = m)
U <- rep(rgamma(n, shape = 1 / phi, scale = phi), each = m)
X <- rnorm(n * m)
# reparameterize scale as in rweibull function
weibull.scale <- alpha / (U * exp(beta * X))^(1 / eta)
T <- rweibull(n * m, shape = eta, scale = weibull.scale)

# right censoring
C <- runif(n * m, 0, 10)
D <- as.numeric(T < C)
T <- pmin(T, C)

# strong left-truncation
L <- runif(n * m, 0, 2)
incl <- T > L
incl <- ave(x = incl, id, FUN = sum) == m
dd <- data.frame(L, T, D, X, id)
dd <- dd[incl, ]

fit <- parfrailty(formula = Surv(L, T, D) ~ X, data = dd, clusterid = "id")
print(fit)
#> $formula
#> Surv(L, T, D) ~ X
#> <environment: 0x63e9453a3990>
#> 
#> $data
#>              L          T D            X  id
#> 4   1.78722376 3.03496785 1  0.634371955   2
#> 5   0.87593944 3.43397538 0 -0.231192902   2
#> 6   1.36879064 1.62048311 0 -1.368194204   2
#> 13  1.93077359 3.88018888 1 -0.869256130   5
#> 14  1.77243226 7.36242205 1 -1.332288341   5
#> 15  1.56056491 2.34032225 0  0.070562870   5
#> 19  1.22215738 9.84817895 0 -2.334691775   7
#> 20  1.21702364 5.95522302 0 -1.730891047   7
#> 21  1.49315787 2.32677008 1  0.825009586   7
#> 34  0.05522163 0.07623505 0  1.806258708  12
#> 35  0.46919068 5.65551975 0 -1.912519898  12
#> 36  0.60892023 0.64452417 0  0.199282075  12
#> 64  0.63330686 1.58382458 1  0.744600427  22
#> 65  1.19372559 8.92000775 0 -0.690190218  22
#> 66  1.57970257 2.76014646 1 -0.791411761  22
#> 67  1.81702192 3.16249173 1 -0.262081191  23
#> 68  0.48221653 7.21706324 0 -0.407917108  23
#> 69  0.18189881 0.28269222 1  0.201311056  23
#> 94  1.87380979 2.72313373 1 -0.454146942  32
#> 95  1.11637152 3.55521551 1  0.194874583  32
#> 96  0.24535298 3.02099790 1  0.031498073  32
#> 109 0.90027766 4.55355698 0 -1.515531972  37
#> 110 0.76864173 1.05942131 1  0.266538188  37
#> 111 0.05512638 2.86769961 1  0.291532260  37
#> 118 1.42239958 1.89974406 1 -0.394103521  40
#> 119 0.47835233 8.89930612 0 -1.510240230  40
#> 120 1.12377144 1.83634274 1  0.005989837  40
#> 127 0.69530126 8.08615804 0 -0.017375770  43
#> 128 1.82338834 1.94208484 0  0.541082912  43
#> 129 0.08598422 5.68351861 0 -0.540041112  43
#> 130 0.51413870 1.38826341 0 -0.080849396  44
#> 131 1.67780447 2.02832169 1 -0.029633958  44
#> 132 0.17971137 3.31347489 0 -0.145250484  44
#> 136 0.51457090 8.44363529 0 -1.154205453  46
#> 137 1.93562494 9.85561167 0  0.422597786  46
#> 138 1.77824194 7.14841753 0 -0.386989726  46
#> 139 1.87523751 5.23743428 0 -1.240525985  47
#> 140 1.81141152 3.71216593 0  0.456962145  47
#> 141 1.03691251 6.76273142 0 -1.410793353  47
#> 166 0.56609081 1.35006822 0  0.757933789  56
#> 167 0.33184205 0.37859500 1  0.359560263  56
#> 168 0.61275686 2.24092552 1 -0.829235675  56
#> 169 0.06145601 0.94865387 1 -0.445752122  57
#> 170 0.53187267 7.37740149 0 -0.670912047  57
#> 171 1.11085148 7.33086430 0 -0.800916902  57
#> 175 0.33909702 0.41699230 1  1.289449757  59
#> 176 1.97795961 5.06034775 1 -0.143912736  59
#> 177 0.17176757 0.67997250 0 -2.288008838  59
#> 250 0.10938821 3.22209051 0 -0.680978405  84
#> 251 0.50699914 6.26629895 0 -2.794959603  84
#> 252 1.25613561 3.98106755 0 -1.084586126  84
#> 259 1.52728552 6.91797197 0 -1.017287856  87
#> 260 1.25885725 1.91230933 1  1.014988922  87
#> 261 1.50238017 7.78931048 0 -0.651507685  87
#> 262 0.58556676 4.63435814 1  0.038215849  88
#> 263 0.96045975 2.80293191 1  0.184078667  88
#> 264 0.15020993 1.11106961 1  0.451722586  88
#> 274 0.18629962 0.90293922 0 -0.335845291  92
#> 275 1.92073994 2.92865786 1 -0.010529493  92
#> 276 0.32608739 1.05008773 1 -0.139135003  92
#> 286 0.73120809 2.17042107 1  0.126737533  96
#> 287 0.62003899 1.88088515 1 -0.485950257  96
#> 288 0.39135693 8.31694088 0 -1.003831691  96
#> 289 0.73954127 8.36045880 0  1.784203198  97
#> 290 0.70089152 1.28215405 1 -0.867144559  97
#> 291 0.54075855 8.57589681 0 -0.970574785  97
#> 298 0.27611811 0.82661051 1 -0.873557167 100
#> 299 0.15071073 0.49972060 1  0.111954035 100
#> 300 0.27641701 0.67741073 1  1.514231380 100
#> 316 0.92415468 5.11869150 0  0.082773252 106
#> 317 1.18738138 4.50767761 0 -1.585977289 106
#> 318 0.11445318 0.93428980 0 -1.529555425 106
#> 358 1.90755391 2.36375300 0 -0.628017639 120
#> 359 1.85712558 5.53994832 1  0.253333621 120
#> 360 1.67931147 2.57420883 0 -0.025188786 120
#> 394 0.71279878 1.32882429 1  0.460090646 132
#> 395 0.42105843 0.85011831 1 -0.218147958 132
#> 396 1.33021640 2.55882491 1  1.323011066 132
#> 403 1.20056311 5.05213969 0 -0.127865246 135
#> 404 1.10080783 8.38274394 0 -0.890580307 135
#> 405 0.26320789 1.16477906 1  0.896985420 135
#> 406 0.13875032 0.33482656 1  1.350929367 136
#> 407 1.88179018 6.89945541 0 -1.032052945 136
#> 408 0.57307729 1.69205188 1  0.513654664 136
#> 424 0.38881144 3.35369691 0 -0.966578842 142
#> 425 0.27245622 0.63939907 1  0.375867015 142
#> 426 1.36902177 6.59952559 0 -2.020810170 142
#> 427 0.19699762 1.46133286 1  0.244792596 143
#> 428 0.14960346 1.54345792 1  0.024357435 143
#> 429 0.43622702 6.56075123 0 -0.937410840 143
#> 445 0.57758966 4.79877953 0 -1.654511931 149
#> 446 1.86685356 8.30339929 0 -1.984728500 149
#> 447 0.47436808 6.92532206 1 -0.514325863 149
#> 448 1.77473551 3.51203199 0 -1.963281412 150
#> 449 1.85746704 4.18200700 0  0.303169082 150
#> 450 0.64277312 0.86599516 0  0.613763724 150
#> 469 0.16195196 0.44779638 1  0.354026642 157
#> 470 1.21458744 3.67393086 1 -0.764599960 157
#> 471 1.12302965 1.65112343 1 -0.509099170 157
#> 529 0.48063096 0.80881503 1  1.249536805 177
#> 530 1.28349557 3.27313504 0  0.496885618 177
#> 531 1.33671206 2.47686403 1 -0.309076753 177
#> 571 0.38581986 6.00508764 0 -0.913394120 191
#> 572 0.82877988 0.93946968 0  1.225612645 191
#> 573 1.85757261 4.85840462 0 -1.153224135 191
#> 589 0.70452328 1.60237702 0 -1.441137171 197
#> 590 0.22542309 0.72176056 1  1.638578200 197
#> 591 1.73939423 3.62888657 0 -1.923365406 197
#> 598 0.62471978 1.17165533 0 -0.453984276 200
#> 599 1.52603893 2.83751867 0 -0.097612023 200
#> 600 0.21336639 2.14748748 1 -0.337073721 200
#> 
#> $clusterid
#> [1] "id"
#> 
#> $ncluster
#> [1] 37
#> 
#> $n
#> [1] 111
#> 
#> $X
#>                X
#> 4    0.634371955
#> 5   -0.231192902
#> 6   -1.368194204
#> 13  -0.869256130
#> 14  -1.332288341
#> 15   0.070562870
#> 19  -2.334691775
#> 20  -1.730891047
#> 21   0.825009586
#> 34   1.806258708
#> 35  -1.912519898
#> 36   0.199282075
#> 64   0.744600427
#> 65  -0.690190218
#> 66  -0.791411761
#> 67  -0.262081191
#> 68  -0.407917108
#> 69   0.201311056
#> 94  -0.454146942
#> 95   0.194874583
#> 96   0.031498073
#> 109 -1.515531972
#> 110  0.266538188
#> 111  0.291532260
#> 118 -0.394103521
#> 119 -1.510240230
#> 120  0.005989837
#> 127 -0.017375770
#> 128  0.541082912
#> 129 -0.540041112
#> 130 -0.080849396
#> 131 -0.029633958
#> 132 -0.145250484
#> 136 -1.154205453
#> 137  0.422597786
#> 138 -0.386989726
#> 139 -1.240525985
#> 140  0.456962145
#> 141 -1.410793353
#> 166  0.757933789
#> 167  0.359560263
#> 168 -0.829235675
#> 169 -0.445752122
#> 170 -0.670912047
#> 171 -0.800916902
#> 175  1.289449757
#> 176 -0.143912736
#> 177 -2.288008838
#> 250 -0.680978405
#> 251 -2.794959603
#> 252 -1.084586126
#> 259 -1.017287856
#> 260  1.014988922
#> 261 -0.651507685
#> 262  0.038215849
#> 263  0.184078667
#> 264  0.451722586
#> 274 -0.335845291
#> 275 -0.010529493
#> 276 -0.139135003
#> 286  0.126737533
#> 287 -0.485950257
#> 288 -1.003831691
#> 289  1.784203198
#> 290 -0.867144559
#> 291 -0.970574785
#> 298 -0.873557167
#> 299  0.111954035
#> 300  1.514231380
#> 316  0.082773252
#> 317 -1.585977289
#> 318 -1.529555425
#> 358 -0.628017639
#> 359  0.253333621
#> 360 -0.025188786
#> 394  0.460090646
#> 395 -0.218147958
#> 396  1.323011066
#> 403 -0.127865246
#> 404 -0.890580307
#> 405  0.896985420
#> 406  1.350929367
#> 407 -1.032052945
#> 408  0.513654664
#> 424 -0.966578842
#> 425  0.375867015
#> 426 -2.020810170
#> 427  0.244792596
#> 428  0.024357435
#> 429 -0.937410840
#> 445 -1.654511931
#> 446 -1.984728500
#> 447 -0.514325863
#> 448 -1.963281412
#> 449  0.303169082
#> 450  0.613763724
#> 469  0.354026642
#> 470 -0.764599960
#> 471 -0.509099170
#> 529  1.249536805
#> 530  0.496885618
#> 531 -0.309076753
#> 571 -0.913394120
#> 572  1.225612645
#> 573 -1.153224135
#> 589 -1.441137171
#> 590  1.638578200
#> 591 -1.923365406
#> 598 -0.453984276
#> 599 -0.097612023
#> 600 -0.337073721
#> 
#> $fit
#> $fit$par
#> [1]  0.3746027 -0.2732453 -1.0648873  1.2779566
#> 
#> $fit$value
#> [1] -111.5306
#> 
#> $fit$counts
#> function gradient 
#>       45       16 
#> 
#> $fit$convergence
#> [1] 0
#> 
#> $fit$message
#> NULL
#> 
#> 
#> $est
#>     log(α)     log(η)     log(ϕ)          X 
#>  0.3746027 -0.2732453 -1.0648873  1.2779566 
#> 
#> $score
#>             log(α)      log(η)      log(ϕ)           X
#>  [1,]  0.013953486  0.20289224 -0.11965534  0.37373130
#>  [2,] -0.497884032  2.52001507 -0.46772296 -1.42384130
#>  [3,] -0.069007646  0.27713823 -0.23097814  0.66557460
#>  [4,]  0.137859989 -0.14641165  0.11013129  0.08105783
#>  [5,] -0.093520015  0.33405218 -0.30480286 -0.05516350
#>  [6,] -0.146292463 -1.03889812 -0.30025772  0.56123686
#>  [7,] -0.290499183  2.16086109 -0.47596378 -0.38636190
#>  [8,]  0.011099791  0.79398549 -0.21691275  0.29200148
#>  [9,] -0.535543940  1.18487038 -0.42506246  0.44181409
#> [10,]  0.472335268 -1.88851477  1.03243696  0.46707458
#> [11,]  0.095094051  0.20316653 -0.06270845  0.11113571
#> [12,]  0.608980969 -2.91764013  1.55679132 -0.03715771
#> [13,]  0.347705224 -1.22974595  0.54900599  0.16346613
#> [14,] -0.367475159  0.77234663 -0.45571856 -1.15674320
#> [15,]  0.425117806 -1.67705538  0.05311604  0.62175200
#> [16,] -0.398640488  1.06649391 -0.57673102  0.65703311
#> [17,]  0.511627932 -0.79298325  0.18290053  0.62054930
#> [18,]  0.053590571 -0.51220966 -0.03847510  1.12121813
#> [19,] -0.079267003  1.46932616 -0.33441943  0.13383099
#> [20,] -0.486755926  1.62765783 -0.44031649  0.01347658
#> [21,] -0.137988012  0.44503587 -0.27985220  0.45230331
#> [22,]  0.497364950 -4.91200778  2.74404636 -3.73290563
#> [23,] -0.495455064  1.69041058 -0.59856851 -2.12530681
#> [24,]  0.644289075 -1.65400943  0.56131700  0.08090285
#> [25,]  0.062392090  0.16838772 -0.04211771  0.04566587
#> [26,] -0.282676261  1.14737959 -0.90297310 -1.35697090
#> [27,]  0.387083643 -1.36082538  0.33269226  0.72348819
#> [28,] -0.139397789  0.18403258 -0.34557360  0.97437992
#> [29,] -0.077711350 -0.26019634 -0.16042625  0.90063440
#> [30,]  0.111303122  0.43070182 -0.18646515  0.65027345
#> [31,]  0.297062945 -0.01523354 -0.05276062  0.60089034
#> [32,]  0.258589968 -0.99229482  0.45701684 -0.06569007
#> [33,] -1.050040656  2.42648364 -0.34545708 -0.40334180
#> [34,] -0.155333955  0.63706623 -0.49576788 -0.24783674
#> [35,]  0.180210992 -0.77083636  0.34050852  0.53482735
#> [36,]  0.191151851  0.01906961  0.08256861 -0.21955355
#> [37,] -0.003373936  0.40771967 -0.14288170 -0.07758479
#> 
#> $vcov
#>             log(α)     log(η)      log(ϕ)          X
#> log(α)  0.38182395 0.09552250 -0.02123094 0.01369009
#> log(η)  0.09552250 0.08284338  0.11211763 0.04021393
#> log(ϕ) -0.02123094 0.11211763  0.32410342 0.07514008
#> X       0.01369009 0.04021393  0.07514008 0.07210706
#> 
#> $call
#> parfrailty(formula = Surv(L, T, D) ~ X, data = dd, clusterid = "id")
#> 
#> attr(,"class")
#> [1] "parfrailty"