R_K {HQM} | R Documentation |
Bandwidth selection score R
Description
Calculates a part for the K-fold cross validation score.
Usage
R_K(h_xt_mat_list, int_X, size_X_grid, Yi, Ni, n)
Arguments
h_xt_mat_list |
A list of matrices for all cross validation data sets. Each matrix contains the estimator with the future conditional hazard rate for all values |
int_X |
Vector of the position of the observed marker values in the grid for marker values. |
size_X_grid |
Numeric value indicating the number of grid points for marker values. |
Yi |
A matrix made by |
Ni |
A matrix made by |
n |
Number of individuals. |
Details
The function implements the estimator
\hat{R}_K = \sum_{j = 1}^K\sum_{i \in I_j} \int_0^T g^{-I_j}_i(t) dN_i(t),
where \hat{g}^{-I_j}_i(t) = \int_0^t Z_i(s) \hat{h}^{-I_j}_{X_i(s)}(t-s) ds,
and \hat{h}^{-I_j}
is estimated without information from all counting processes i
with i \in I_j
.
This function estimates
R = \sum_{i = 1}^N \int_0^T \int_s^T Z_i(t)Z_i(s)\hat{h}_{X_i(s)}(t-s) h_{X_i(s)}(t-s) dt ds .
where \hat{h}
is the hqm estimator, Z
the exposure and X
the marker.
Value
A matrix with \hat{g}^{-I_j}_i(t)
for all individuals i
and time grid points t
.
See Also
Examples
pbc2_id = to_id(pbc2)
n = max(as.numeric(pbc2$id))
b = 1.5
I = 104
h_xt_mat_list = prep_cv(pbc2, pbc2_id, 'serBilir', 'years', 'year', 'status2', n, I, b)
size_s_grid <- size_X_grid <- 100
s = pbc2$year
X = pbc2$serBilir
br_s = seq(0, max(s), max(s)/( size_s_grid-1))
br_X = seq(min(X), max(X), (max(X)-min(X))/( size_X_grid-1))
ss <- pbc2_id$years
delta <- pbc2_id$status2
X_lin = lin_interpolate(br_s, pbc2_id$id, pbc2$id, X, s)
int_X <- findInterval(X_lin, br_X)
int_s = rep(1:length(br_s), n)
Yi <- make_Yi(pbc2, pbc2_id, X_lin, br_X, br_s,
size_s_grid, size_X_grid, int_s, int_X, 'years', n)
Ni <- make_Ni(br_s, size_s_grid, ss, delta, n)
R = R_K(h_xt_mat_list, int_X, size_X_grid, Yi, Ni, n)
R