Maximum A Posteriori estimation
MAP.estimation.Rd
MAP.estimation
function is used (in local centers) to compute Maximum A Posterior (MAP) estimators of the parameters for Generalized Linear Models (GLM) and Survival models.
Usage
MAP.estimation(y,
X,
family = c("gaussian", "binomial", "survival"),
Lambda,
intercept = TRUE,
initial = NULL,
basehaz = c("weibul", "exp", "gomp", "poly", "pwexp"),
alpha = 0.1,
max_order = 2,
n_intervals = 4,
min_max_times,
center_zero_sample = FALSE,
zero_sample_cov,
refer_cat,
zero_cat,
control = list())
Arguments
- y
response vector. If the “
binomial
” family is used, this argument is a vector with entries 0 (failure) or 1 (success). Alternatively, for this family, the response can be a matrix where the first column is the number of “successes” and the second column is the number of “failures”. For the “survival
” family, the response is a matrix where the first column is the survival time, named “time”, and the second column is the censoring indicator, named “status”, with 0 indicating censoring time and 1 indicating event time.- X
design matrix of dimension \(n \times p\), where \(p\) is the number of covariates or predictors. Note that the order of the covariates must be the same across the centers; otherwise, the output estimates of bfi() will be incorrect.
- family
a description of the error distribution. This is a character string naming a family of the model. In the current version of the package, the family of model can be
"gaussian"
(withidentity
link function),"binomial"
(withlogit
link function), or"survival"
. Can be abbreviated. By default thegaussian
family is used. In case of a linear regression model,family = "gaussian"
, there is an extra model parameter for the variance of measurement error. While in the case of survival model,family = "survival"
, the number of the model parameters depend on the choice of baseline hazard functions, see ‘Details’ for more information.- Lambda
the inverse variance-covariance matrix of the Gaussian distribution that is used as prior distribution for the model parameters. The dimension of the matrix depends on the number of columns of
X
, type of the covariates (continuous / dichotomous or categorical),family
, and whether anintercept
is included (if applicable). However,Lambda
can be easily created byinv.prior.cov()
. Seeinv.prior.cov
for more information.- intercept
logical flag for fitting an intercept. If
intercept=TRUE
(the default), the intercept is fitted, i.e., it is included in the model, and ifintercept=FALSE
it is set to zero, i.e., it's not in the model. This argument is not used iffamily = "survival"
.- initial
a vector specifying initial values for the parameters to be optimized over. The length of
initial
is equal to the number of model parameters and thus, is equal to the number of rows or columns ofLambda
. Since the'L-BFGS-B'
method is used in the algorithm, these values should always be finite. Default is a vector of zeros, except for thesurvival
family with thepoly
function, where it is a vector with the first \(p\) elements as zeros for coefficients (\(\boldsymbol{\beta}\)) and -0.5 for the remaining parameters (\(\boldsymbol{\omega}\)). For thegaussian
family, the last element of theinitial
vector could also be considered negative, because the Gaussian prior was applied to \(log(\sigma^2)\).- basehaz
a character string representing one of the available baseline hazard functions;
exponential
("exp"
),Weibull
("weibul"
, the default),Gompertz
("gomp"
),exponentiated polynomial
("poly"
), andpiecewise constant exponential
("pwexp"
). Can be abbreviated. It is only used whenfamily = "survival"
. If local sample size is large and the shape of the baseline hazard function is completely unknown, the “exponentiated polynomial” and “piecewise exponential” hazard functions would be preferred above the lower dimensional alternatives. However, if the local samples size is low, one should be careful using the “piecewise exponential” hazard function with many intervals.- alpha
a significance level used in the chi-squared distribution (with one degree of freedom and 1-\(\alpha\) representing the upper quantile) to conduct a likelihood ratio test for obtaining the order of the exponentiated polynomial baseline hazard function. It is only used when
family = "survival"
andbasehaz = "poly"
. Default is 0.1. See ‘Details’.- max_order
an integer representing the maximum value of
q_l
, which is the order/degree minus 1 of the exponentiated polynomial baseline hazard function. This argument is only used whenfamily = "survival"
andbasehaz = "poly"
. Default is 2.- n_intervals
an integer representing the number of intervals in the piecewise exponential baseline hazard function. This argument is only used when
family = "survival"
andbasehaz = "pwexp"
. Default is 4.- min_max_times
a scalar representing the minimum of the maximum event times observed in the centers. The value of this argument should be defined by the central server (which has access to the maximum event times of all the centers) and is only used when
family = "survival"
andbasehaz = "pwexp"
.- center_zero_sample
logical flag indicating whether the center has a categorical covariate with no observations/individuals in one of the categories. Default is
center_zero_sample = FALSE
.- zero_sample_cov
either a character string or an integer representing the categorical covariate that has no samples/observations in one of its categories. This covariate should have at least two categories, one of which is the reference. It is used when
center_zero_sample = TRUE
.- refer_cat
a character string representing the reference category. The category with no observations (the argument
zero_cat
) cannot be used as the reference in the argumentrefer_cat
. It is used whencenter_zero_sample = TRUE
.- zero_cat
a character string representing the category with no samples/observations. It is used when
center_zero_sample = TRUE
.- control
a list of control parameters. See ‘Details’.
Value
MAP.estimation
returns a list containing the following components:
- theta_hat
the vector corresponding to the maximum a posteriori (MAP) estimates of the parameters. For the
gaussian
family, the last element of this vector is \(\sigma^2\);- A_hat
minus the curvature (or Hessian) matrix around the point
theta_hat
. The dimension of the matrix is the same as the argumentLambda
;- sd
the vector of standard deviation of the MAP estimates in
theta_hat
, that issqrt(diag(solve(A_hat)))
;- Lambda
the inverse variance-covariance matrix of the Gaussian distribution that is used as prior distribution for the parameters. It's exactly the same as the argument
Lambda
;- formula
the formula applied;
- names
the names of the model parameters;
- n
sample size;
- np
the number of coefficients;
- q_l
the order/degree minus 1 of the exponentiated polynomial baseline hazard function determined for the current center by the likelihood ratio test. This output argument,
q_l
, is only shown whenfamily = "survival"
andbasehaz = "poly"
, and will be used in the functionbfi()
;- theta_A_poly
an array where the first component is a matrix with columns representing the MAP estimates of the parameters for different
q_l
's, i.e.,q_l
,q_l
+1, ...,max_order
. The other components are minus the curvature matrices for differentq_l
's, i.e.,q_l
,q_l
+1, ...,max_order
. Therefore, the first non-NA curvature matrix is equal to the output argumentA_hat
. This output argument,theta_A_poly
, is only shown iffamily = "survival"
andbasehaz = "poly"
, and will be used in the functionbfi()
;- lev_no_ref_zer
a vector containing the names of the levels of the categorical covariate that has no samples/observations in one of its categories. The name of the category with no samples and the name of the reference category are excluded from this vector. This argument is shown when
family = "survival"
andbasehaz = "poly"
, and will be used in the functionbfi()
;- zero_sample_cov
the categorical covariate that has no samples/observations in one of its categories. It is shown when
center_zero_sample = TRUE
, and can be used in the functionbfi()
;- refer_cat
the reference category. It is shown when
center_zero_sample = TRUE
, and can be used in the functionbfi()
;- zero_cat
the category with no samples/observations. It is shown when
center_zero_sample = TRUE
, and can be used in the functionbfi()
;- value
the value of minus the log-likelihood posterior density evaluated at
theta_hat
;- family
the
family
used;- basehaz
the baseline hazard function used;
- intercept
logical flag used to fit an intercept if
TRUE
, or set to zero ifFALSE
;- convergence
an integer value used to encode the warnings and the errors related to the algorithm used to fit the model. The values returned are:
- 0
algorithm has converged;
- 1
maximum number of iterations ('
maxit
') has been reached;- 2
Warning from the 'L-BFGS-B' method. See the message after this value;
- control
the list of control parameters used to compute the MAP estimates.
Details
MAP.estimation
function finds the Maximum A Posteriori (MAP) estimates of the model parameters by maximizing the log-posterior density with respect to the parameters, i.e., the estimates equal the values for which the log-posterior density is maximal (the posterior mode).
In other words, MAP.estimation()
optimizes the log-posterior density with respect to the parameter vector to obtain its MAP estimates.
In addition to the model parameters (i.e., coefficients (\(\boldsymbol{\beta}\)) and variance error (\(\sigma^2_e\)) for gaussian
or the parameters of the baseline hazard (\(\boldsymbol{\omega}\)) for survival
), the curvature matrix (Hessian of the log-posterior) is estimated around the mode.
The MAP.estimation
function returns an object of class `bfi
`. Therefore, summary()
can be used for the object returned by MAP.estimation()
.
For the case where family = "survival"
and basehaz = "poly"
, we assume that in all centers the \(q_\ell\)'s are equal.
However, the order of the estimated polynomials may vary across the centers so that each center can have different number of parameters, say \(q_\ell\)+1.
After obtaining the estimates within the local centers (by using MAP.estimation()
) and having all estimates in the central server, we choose the order of the polynomial approximation for the combined data to be the maximum of the orders of the local polynomial functions, i.e., \(\max \{q_1, \ldots, q_L \}\), to approximate the global baseline hazard (exponentiated polynomial) function more accurately. This is because the higher-order polynomial approximation can capture more complex features and details in the combined data. Using the higher-order approximation ensures that we account for the higher-order moments and features present in the data while maintaining accuracy.
As a result, all potential cases are stored in the theta_A_poly
argument to be used in bfi()
by the central server.
For further information on the survival
family, refer to the 'References' section.
To solve unconstrained and bound-constrained optimization problems, the MAP.estimation
function utilizes an optimization algorithm called Limited-memory Broyden-Fletcher-Goldfarb-Shanno with Bound Constraints (L-BFGS-B), Byrd et. al. (1995).
The L-BFGS-B algorithm is a limited-memory “quasi-Newton” method that iteratively updates the parameter estimates by approximating the inverse Hessian matrix using gradient information from the history of previous iterations. This approach allows the algorithm to approximate the curvature of the posterior distribution and efficiently search for the optimal solution, which makes it computationally efficient for problems with a large number of variables.
By default, the algorithm uses a relative change in the objective function as the convergence criterion. When the change in the objective function between iterations falls below a certain threshold (`factr
`) the algorithm is considered to have converged.
The convergence can be checked with the argument convergence
in the output. See ‘Value’.
In case of convergence issue, it may be necessary to investigate and adjust optimization parameters to facilitate convergence. It can be done using the initial
and control
arguments. By the argument initial
the initial points of the interative optimization algorithm can be changed, and the argument control
is a list that can supply any of the following components:
maxit
:is the maximum number of iterations. Default is 150;
factr
:controls the convergence of the
'L-BFGS-B'
method. Convergence occurs when the reduction in the objective is within this factor of the machine tolerance. Default forfactr
is 1e7, which gives a tolerance of about 1e-9. The exact tolerance can be checked by multiplying this value by.Machine$double.eps
;pgtol
:helps to control the convergence of the
'L-BFGS-B'
method. It is a tolerance on the projected gradient in the current search direction, i.e., the iteration will stop when the maximum component of the projected gradient is less than or equal topgtol
, wherepgtol
\(\geq 0\). Default is zero, when the check is suppressed;trace
:is a non-negative integer. If positive, tracing information on the progress of the optimization is produced. Higher values may produce more tracing information: for the method
'L-BFGS-B'
there are six levels of tracing. To understand exactly what these do see the source code ofoptim
function in the stats package;REPORT
:is the frequency of reports for the
'L-BFGS-B'
method if'control$trace'
is positive. Default is every 10 iterations;lmm
:is an integer giving the number of
BFGS
updates retained in the'L-BFGS-B'
method. Default is 5.
References
Jonker M.A., Pazira H. and Coolen A.C.C. (2024). Bayesian federated inference for estimating statistical models based on non-shared multicenter data sets, Statistics in Medicine, 43(12): 2421-2438. <https://doi.org/10.1002/sim.10072>
Pazira H., Massa E., Weijers J.A.M., Coolen A.C.C. and Jonker M.A. (2024). Bayesian Federated Inference for Survival Models, arXiv. <https://arxiv.org/abs/2404.17464>
Jonker M.A., Pazira H. and Coolen A.C.C. (2024b). Bayesian Federated Inference for regression models with heterogeneous multi-center populations, arXiv. <https://arxiv.org/abs/2402.02898>
Byrd R.H., Lu P., Nocedal J. and Zhu C. (1995). A limited memory algorithm for bound constrained optimization. SIAM Journal on Scientific Computing, 16, 1190-1208. <https://doi.org/10.1137/0916069>
Author
Hassan Pazira and Marianne Jonker
Maintainer: Hassan Pazira hassan.pazira@radboudumc.nl
See also
bfi
, inv.prior.cov
and summary.bfi
Examples
###--------------###
### y ~ Gaussian ###
###--------------###
# Setting a seed for reproducibility
set.seed(11235)
# model parameters: coefficients and sigma2 = 1.5
theta <- c(1, 2, 2, 2, 1.5)
#----------------
# Data Simulation
#----------------
n <- 30 # sample size
p <- 3 # number of coefficients without intercept
X <- data.frame(matrix(rnorm(n * p), n, p)) # continuous variables
# linear predictor:
eta <- theta[1] + theta[2] * X$X1 + theta[3] * X$X2 + theta[4] * X$X3
# inverse of the link function ( g^{-1}(\eta) = \mu ):
mu <- gaussian()$linkinv(eta)
y <- rnorm(n, mu, sd = sqrt(theta[5]))
# Load the BFI package
library(BFI)
#-----------------------------------------------
# MAP estimations for theta and curvature matrix
#-----------------------------------------------
# MAP estimates with 'intercept'
Lambda <- inv.prior.cov(X, lambda = c(0.1, 1), family = "gaussian")
(fit <- MAP.estimation(y, X, family = "gaussian", Lambda))
#> $theta_hat
#> (Intercept) X1 X2 X3 sigma2
#> 1.341258 2.236391 2.071001 2.164002 1.054571
#>
#> $A_hat
#> (Intercept) X1 X2 X3 sigma2
#> (Intercept) 28.5475747 1.9315730 -7.7385763 6.2804549 -0.2682462
#> X1 1.9315730 20.4369223 -2.2127254 4.5673270 -0.4472059
#> X2 -7.7385763 -2.2127254 49.3206700 3.1359341 -0.4141474
#> X3 6.2804549 4.5673270 3.1359341 24.3657850 -0.4327445
#> sigma2 -0.2682462 -0.4472059 -0.4141474 -0.4327445 64.2183745
#>
#> $sd
#> (Intercept) X1 X2 X3 sigma2
#> 0.1982976 0.2269483 0.1476575 0.2153269 0.1248065
#>
#> $Lambda
#> (Intercept) X1 X2 X3 sigma2
#> (Intercept) 0.1 0.0 0.0 0.0 0
#> X1 0.0 0.1 0.0 0.0 0
#> X2 0.0 0.0 0.1 0.0 0
#> X3 0.0 0.0 0.0 0.1 0
#> sigma2 0.0 0.0 0.0 0.0 1
#>
#> $formula
#> [1] y ~ X1 + X2 + X3
#>
#> $names
#> [1] "(Intercept)" "X1" "X2" "X3" "sigma2"
#>
#> $n
#> [1] 30
#>
#> $np
#> [1] 4
#>
#> $zero_sample_cov
#> NULL
#>
#> $refer_cat
#> NULL
#>
#> $zero_cat
#> NULL
#>
#> $value
#> [1] 35.28046
#>
#> $family
#> [1] "gaussian"
#>
#> $basehaz
#> [1] "weibul" "exp" "gomp" "poly" "pwexp"
#>
#> $intercept
#> [1] TRUE
#>
#> $convergence
#> [1] 0
#>
#> $control
#> $control$maxit
#> [1] 100
#>
#>
#> attr(,"class")
#> [1] "bfi"
class(fit)
#> [1] "bfi"
summary(fit, cur_mat = TRUE)
#>
#> Summary of the local model:
#>
#> Formula: y ~ X1 + X2 + X3
#> Family: ‘gaussian’
#> Link: ‘identity’
#>
#> Coefficients:
#>
#> Estimate Std.Dev CI 2.5% CI 97.5%
#> (Intercept) 1.3413 0.1983 0.9526 1.7299
#> X1 2.2364 0.2269 1.7916 2.6812
#> X2 2.0710 0.1477 1.7816 2.3604
#> X3 2.1640 0.2153 1.7420 2.5860
#>
#> Dispersion parameter (sigma2): 1.055
#> log Lik Posterior: -35.28
#> Convergence: 0
#>
#> Minus the Curvature Matrix:
#>
#> (Intercept) X1 X2 X3 sigma2
#> (Intercept) 28.5476 1.9316 -7.7386 6.2805 -0.2682
#> X1 1.9316 20.4369 -2.2127 4.5673 -0.4472
#> X2 -7.7386 -2.2127 49.3207 3.1359 -0.4141
#> X3 6.2805 4.5673 3.1359 24.3658 -0.4327
#> sigma2 -0.2682 -0.4472 -0.4141 -0.4327 64.2184
# MAP estimates without 'intercept'
Lambda <- inv.prior.cov(X, lambda = c(0.1, 1), family = 'gaussian', intercept = FALSE)
(fit1 <- MAP.estimation(y, X, family = 'gaussian', Lambda, intercept = FALSE))
#> $theta_hat
#> X1 X2 X3 sigma2
#> 2.241637 1.832740 2.525235 2.496099
#>
#> $A_hat
#> X1 X2 X3 sigma2
#> X1 8.6921038 -0.9348497 1.9296405 -0.4483243
#> X2 -0.9348497 20.8951379 1.3248942 -0.3665339
#> X3 1.9296405 1.3248942 10.3520007 -0.5050368
#> sigma2 -0.4483243 -0.3665339 -0.5050368 69.9843284
#>
#> $sd
#> X1 X2 X3 sigma2
#> 0.3478802 0.2205610 0.3192969 0.1195753
#>
#> $Lambda
#> X1 X2 X3 sigma2
#> X1 0.1 0.0 0.0 0
#> X2 0.0 0.1 0.0 0
#> X3 0.0 0.0 0.1 0
#> sigma2 0.0 0.0 0.0 1
#>
#> $formula
#> [1] y ~ X1 + X2 + X3
#>
#> $names
#> [1] "X1" "X2" "X3" "sigma2"
#>
#> $n
#> [1] 30
#>
#> $np
#> [1] 3
#>
#> $zero_sample_cov
#> NULL
#>
#> $refer_cat
#> NULL
#>
#> $zero_cat
#> NULL
#>
#> $value
#> [1] 63.9101
#>
#> $family
#> [1] "gaussian"
#>
#> $basehaz
#> [1] "weibul" "exp" "gomp" "poly" "pwexp"
#>
#> $intercept
#> [1] FALSE
#>
#> $convergence
#> [1] 0
#>
#> $control
#> $control$maxit
#> [1] 100
#>
#>
#> attr(,"class")
#> [1] "bfi"
summary(fit1, cur_mat = TRUE)
#>
#> Summary of the local model:
#>
#> Formula: y ~ X1 + X2 + X3
#> Family: ‘gaussian’
#> Link: ‘identity’
#>
#> Coefficients:
#>
#> Estimate Std.Dev CI 2.5% CI 97.5%
#> X1 2.2416 0.3479 1.5598 2.9235
#> X2 1.8327 0.2206 1.4004 2.2650
#> X3 2.5252 0.3193 1.8994 3.1510
#>
#> Dispersion parameter (sigma2): 2.496
#> log Lik Posterior: -63.91
#> Convergence: 0
#>
#> Minus the Curvature Matrix:
#>
#> X1 X2 X3 sigma2
#> X1 8.6921 -0.9348 1.9296 -0.4483
#> X2 -0.9348 20.8951 1.3249 -0.3665
#> X3 1.9296 1.3249 10.3520 -0.5050
#> sigma2 -0.4483 -0.3665 -0.5050 69.9843
###-----------------###
### Survival family ###
###-----------------###
# Setting a seed for reproducibility
set.seed(112358)
#-------------------------
# Simulating Survival data
#-------------------------
n <- 40
beta <- 1:4
p <- length(beta)
X <- data.frame(matrix(rnorm(n * p), n, p)) # continuous (normal) variables
## Simulating survival data from Weibull with a predefined censoring rate of 0.3
y <- surv.simulate(Z = list(X), beta = beta, a = 5, b = exp(1.8), u1 = 0.1,
cen_rate = 0.3, gen_data_from = "weibul")$D[[1]][, 1:2]
##
## MAP estimations with "weibul" function
##
Lambda <- inv.prior.cov(X, lambda = c(0.1, 1), family = 'survival', basehaz = "weibul")
fit2 <- MAP.estimation(y, X, family = 'survival', Lambda = Lambda, basehaz = "weibul")
fit2
#> $theta_hat
#> X1 X2 X3 X4 omega_1 omega_2
#> 1.022608 1.923233 2.658896 3.033005 1.199592 1.560015
#>
#> $A_hat
#> X1 X2 X3 X4 omega_1 omega_2
#> X1 32.285644 5.767152 -3.5607948 -3.11069513 2.53101341 -21.77443
#> X2 5.767152 24.867161 -7.1800119 -2.12615479 9.93044276 -25.70815
#> X3 -3.560795 -7.180012 25.9879789 -4.46109728 -0.82453629 -31.24050
#> X4 -3.110695 -2.126155 -4.4610973 22.38799938 0.08080909 -45.70763
#> omega_1 2.531013 9.930443 -0.8245363 0.08080909 33.80041453 -45.88800
#> omega_2 -21.774426 -25.708151 -31.2405030 -45.70763145 -45.88799582 371.85632
#>
#> $sd
#> X1 X2 X3 X4 omega_1 omega_2
#> 0.2049384 0.2700345 0.3192750 0.3702427 0.2115831 0.1097131
#>
#> $Lambda
#> X1 X2 X3 X4 omega_1 omega_2
#> X1 0.1 0.0 0.0 0.0 0 0
#> X2 0.0 0.1 0.0 0.0 0 0
#> X3 0.0 0.0 0.1 0.0 0 0
#> X4 0.0 0.0 0.0 0.1 0 0
#> omega_1 0.0 0.0 0.0 0.0 1 0
#> omega_2 0.0 0.0 0.0 0.0 0 1
#>
#> $formula
#> [1] "Survival(time, status) ~ X1 + X2 + X3 + X4"
#>
#> $names
#> [1] "X1" "X2" "X3" "X4" "omega_1" "omega_2"
#>
#> $n
#> [1] 40
#>
#> $np
#> [1] 4
#>
#> $zero_sample_cov
#> NULL
#>
#> $refer_cat
#> NULL
#>
#> $zero_cat
#> NULL
#>
#> $value
#> [1] -11.22305
#>
#> $family
#> [1] "survival"
#>
#> $basehaz
#> [1] "weibul"
#>
#> $intercept
#> [1] FALSE
#>
#> $convergence
#> [1] 0
#>
#> $control
#> $control$maxit
#> [1] 100
#>
#>
#> attr(,"class")
#> [1] "bfi"
fit2$theta_hat
#> X1 X2 X3 X4 omega_1 omega_2
#> 1.022608 1.923233 2.658896 3.033005 1.199592 1.560015
##
## MAP estimations with "poly" function
##
Lambda <- inv.prior.cov(X, lambda = c(0.1, 1), family = 'survival', basehaz = 'poly')
fit3 <- MAP.estimation(y, X, family = "survival", Lambda = Lambda, basehaz = "poly")
# Degree of the exponentiated polynomial baseline hazard
fit3$q_l + 1
#> [1] 3
# theta_hat for (beta_1, ..., beta_p, omega_0, ..., omega_{q_l})
fit3$theta_A_poly[,,1][,fit3$q_l+1] # equal to fit3$theta_hat
#> X1 X2 X3 X4 omega_0 omega_1 omega_2
#> 0.3215329 1.2037173 1.0405380 1.2693381 -1.2389571 1.7395803 0.4144363
# A_hat
fit3$theta_A_poly[,,fit3$q_l+2] # equal to fit3$A_hat
#> [,1] [,2] [,3] [,4] [,5] [,6]
#> X1 39.808689 12.2009785 6.9910434 7.4263062 2.6009837 -7.262528
#> X2 12.200979 32.9625712 2.4257004 0.6537674 10.0024752 -3.077053
#> X3 6.991043 2.4257004 34.6638475 -2.4049047 -0.6626546 -7.620654
#> X4 7.426306 0.6537674 -2.4049047 38.3051057 0.2572066 -10.431489
#> omega_0 2.600984 10.0024752 -0.6626546 0.2572066 45.2390197 19.915636
#> omega_1 -7.262528 -3.0770530 -7.6206543 -10.4314888 19.9156360 35.751712
#> omega_2 -14.604789 -12.1610483 -11.8935671 -16.6172308 26.7517116 43.916983
#> [,7]
#> X1 -14.60479
#> X2 -12.16105
#> X3 -11.89357
#> X4 -16.61723
#> omega_0 26.75171
#> omega_1 43.91698
#> omega_2 79.89797
summary(fit3, cur_mat = TRUE)
#>
#> Summary of the local model:
#>
#> Formula: Survival(time, status) ~ X1 + X2 + X3 + X4
#> Family: ‘survival’
#> Baseline: ‘poly’
#>
#> Coefficients:
#>
#> Estimate Std.Dev CI 2.5% CI 97.5%
#> X1 0.3215 0.1760 -0.0235 0.6665
#> X2 1.2037 0.2073 0.7973 1.6101
#> X3 1.0405 0.1808 0.6862 1.3948
#> X4 1.2693 0.1792 0.9181 1.6205
#> omega_0 -1.2390 0.1936 -1.6184 -0.8595
#> omega_1 1.7396 0.3078 1.1362 2.3429
#> omega_2 0.4144 0.2148 -0.0065 0.8354
#>
#> log Lik Posterior: -2.402
#> Convergence: 0
#>
#> Minus the Curvature Matrix:
#>
#> X1 X2 X3 X4 omega_0 omega_1 omega_2
#> X1 39.8087 12.2010 6.9910 7.4263 2.6010 -7.2625 -14.6048
#> X2 12.2010 32.9626 2.4257 0.6538 10.0025 -3.0771 -12.1610
#> X3 6.9910 2.4257 34.6638 -2.4049 -0.6627 -7.6207 -11.8936
#> X4 7.4263 0.6538 -2.4049 38.3051 0.2572 -10.4315 -16.6172
#> omega_0 2.6010 10.0025 -0.6627 0.2572 45.2390 19.9156 26.7517
#> omega_1 -7.2625 -3.0771 -7.6207 -10.4315 19.9156 35.7517 43.9170
#> omega_2 -14.6048 -12.1610 -11.8936 -16.6172 26.7517 43.9170 79.8980
##
## MAP estimations with "pwexp" function with 3 intervals
##
# Assume we have 4 centers
Lambda <- inv.prior.cov(X, lambda = c(0.1, 1), family = 'survival',
basehaz = 'pwexp', n_intervals = 3)
# For this baseline hazard ("pwexp"), we need to know
# maximum survival times of the 3 other centers:
max_times <- c(max(rexp(30)), max(rexp(50)), max(rexp(70)))
# Minimum of the maximum values of the survival times of all 4 centers is:
min_max_times <- min(max(y$time), max_times)
fit4 <- MAP.estimation(y, X, family = "survival", Lambda = Lambda, basehaz = "pwexp",
n_intervals = 3, min_max_times=max(y$time))
#>
#> No. observations in the intervals : 21 15 4
#>
summary(fit4, cur_mat = TRUE)
#>
#> Summary of the local model:
#>
#> Formula: Survival(time, status) ~ X1 + X2 + X3 + X4
#> Family: ‘survival’
#> Baseline: ‘pwexp’
#>
#> Coefficients:
#>
#> Estimate Std.Dev CI 2.5% CI 97.5%
#> X1 0.2487 0.1986 -0.1405 0.6379
#> X2 0.9223 0.2488 0.4347 1.4099
#> X3 0.8142 0.2130 0.3966 1.2317
#> X4 0.9903 0.2212 0.5568 1.4239
#> omega_1 -0.4971 0.2939 -1.0732 0.0789
#> omega_2 0.8749 0.4030 0.0850 1.6648
#> omega_3 1.9182 0.6030 0.7363 3.1001
#>
#> log Lik Posterior: -11.42
#> Convergence: 0
#>
#> Minus the Curvature Matrix:
#>
#> X1 X2 X3 X4 omega_1 omega_2 omega_3
#> X1 28.7140 7.4845 3.1246 3.2991 4.2573 -0.4782 -1.1707
#> X2 7.4845 24.1520 -1.2192 -0.2741 9.6072 1.6478 -1.2245
#> X3 3.1246 -1.2192 25.4085 -0.8338 2.9585 -3.3194 -0.2792
#> X4 3.2991 -0.2741 -0.8338 26.4068 5.4940 -3.1502 -2.0586
#> omega_1 4.2573 9.6072 2.9585 5.4940 17.4972 0.0000 0.0000
#> omega_2 -0.4782 1.6478 -3.3194 -3.1502 0.0000 7.1251 0.0000
#> omega_3 -1.1707 -1.2245 -0.2792 -2.0586 0.0000 0.0000 3.0818