Posterior Frailty Estimates
post_frailty_est.RdFunction for computing the posterior frailty estimates of the time-dependent shared frailty Cox model.
Recalling the structure of the frailty \(Z_{jk} = \alpha_j + \epsilon_{jk}, \forall j,k\) with \(k=1,\dots,L\) and \(j=1,\dots,N\) as being composed by the sum of two independent gamma distributions:
\(\alpha_j \sim gamma(\mu_1/\nu, 1/\nu), \forall j\)
\(\epsilon_{jk} \sim gamma(\mu_2/\gamma_k, 1/\gamma_k), \forall j,k\)
The posterior frailty estimate is \(\hat{Z}_{jk} = \hat{\alpha}_{j}/\hat{\alpha}_{max} + \hat{\epsilon}_{jk}/\hat{\epsilon}_{max}\). This function allows to get either the entire posterior frailty estimate \(\hat{Z}_{jk}\) or its time-independent \(\frac{\hat{\alpha}_{j}}{\hat{\alpha}_{\text{max}}}\) or time-dependent \(\frac{\hat{\epsilon}_{jk}}{\hat{\epsilon}_{\text{max}}}\) components. The user can control which components to display using the flag_eps and flag_alpha parameters. Only one of these flags can be set to TRUE at a time.
Arguments
- object
S3 object of class 'AdPaik' returned by the main model output, that contains all the information for the computation of the frailty standard deviation.
- flag_eps
Logical flag indicating whether to extract only the time-dependent posterior frailty estimates. Default is FALSE.
- flag_alpha
Logical flag indicating whether to extract only the time-independent posterior frailty estimates. Default is FALSE.
Value
Vector or matrix of posterior frailty estimates, depending on the flag_eps and flag_alpha values. Specifically:
It is a vector of length equal to the N containing posterior frailty estimates for \(\alpha_j, \forall j\). In this case the flag_eps must be FALSE and the flag_alpha must be TRUE.
Matrix of dimension (N, L) containing posterior frailty estimates for \(\epsilon_{jk}, \forall j,k\). In this case the flag_eps must be TRUE and the flag_alpha must be FALSE.
Matrix of dimension (N, L) containing posterior frailty estimates for \(Z_{jk} = \alpha_j + \epsilon_{jk}, \forall j,k\). In this case the flag_eps must be FALSE and the flag_alpha must be FALSE.
Examples
# Consider the 'Academic Dropout dataset'
data(data_dropout)
# Define the variables needed for the model execution
formula <- time_to_event ~ Gender + CFUP + cluster(group)
time_axis <- c(1.0, 1.4, 1.8, 2.3, 3.1, 3.8, 4.3, 5.0, 5.5, 5.8, 6.0)
eps <- 1e-10
categories_range_min <- c(-8, -2, eps, eps, eps)
categories_range_max <- c(-eps, 0, 1 - eps, 1, 10)
# \donttest{
# Call the main model
result <- AdPaikModel(formula, data_dropout, time_axis,
categories_range_min, categories_range_max)
post_frailty_est(result)
#> [,1] [,2] [,3] [,4] [,5] [,6] [,7]
#> [1,] 1.1048085 1.108777 1.1474602 1.1059493 1.1023940 0.9904685 1.0244148
#> [2,] 0.8379022 0.783925 0.6487758 0.8449009 0.8444895 0.8022552 0.7888697
#> [3,] 1.1625679 1.132693 1.1164254 1.1623126 1.1654964 1.1567719 1.1361883
#> [4,] 1.4271719 1.568560 1.6006538 1.4236222 1.4622335 1.4087045 1.3630460
#> [5,] 1.0151242 1.010792 0.8952016 1.0126740 1.0077738 0.9719522 0.9590418
#> [6,] 1.1586249 1.137413 1.2133184 1.1713022 1.1852622 1.0503534 1.1159619
#> [7,] 1.5066882 1.523511 1.4942502 1.5035653 1.4868928 1.4476774 1.4707293
#> [8,] 1.1898418 1.165315 1.1408163 1.1802794 1.1676254 1.1581884 1.2267366
#> [9,] 1.2029309 1.202929 1.1728428 1.2033433 1.2188223 1.1907881 1.1795102
#> [10,] 1.2415553 1.279428 1.2640997 1.2343051 1.2156396 1.2301255 1.4222374
#> [11,] 1.3800660 1.363964 1.5389832 1.3763733 1.3666861 1.3816941 1.3479990
#> [12,] 1.3800401 1.447068 1.5676166 1.3933855 1.4089594 1.6238976 1.4235880
#> [13,] 1.4914552 1.450030 1.6247048 1.4920578 1.4806455 1.5839689 1.6188156
#> [14,] 1.2537551 1.208663 1.2219560 1.2492629 1.2451419 1.4184826 1.2740300
#> [15,] 1.2117185 1.197532 1.1892678 1.2103572 1.2043657 1.2365946 1.2591644
#> [16,] 1.1414458 1.137667 1.1241100 1.1360563 1.1440807 1.1523439 1.0931559
#> [,8] [,9] [,10]
#> [1,] 1.0215709 1.1045161 1.1116208
#> [2,] 0.7205031 0.8418765 0.8501202
#> [3,] 1.0399472 1.1603833 1.1567357
#> [4,] 1.3158059 1.4271725 1.4399600
#> [5,] 1.0479819 1.0123384 1.0156051
#> [6,] 1.1145681 1.1678654 1.1733473
#> [7,] 1.5770100 1.4959632 1.5102805
#> [8,] 1.3905460 1.1823130 1.1862520
#> [9,] 1.2793400 1.2046677 1.2139525
#> [10,] 1.1758845 1.2370967 1.2456170
#> [11,] 1.4289069 1.3807856 1.3819686
#> [12,] 1.2935085 1.3915439 1.4073167
#> [13,] 1.9939477 1.4888391 1.5011494
#> [14,] 1.1674313 1.2563313 1.2909260
#> [15,] 1.3057423 1.2090982 1.2080804
#> [16,] 0.9903570 1.1384490 1.1518937
# }