View source: R/predict_lucid_all.R
| predict_lucid | R Documentation |
Predict cluster assignment and outcome using new data on G, Z, and optional Y.
If g_computation = TRUE, prediction uses only the G-to-X path from the
fitted model and returns counterfactual-style predictions under modified G.
This function can also be used to extract latent cluster assignments when using
the training data as input.
predict_lucid(
model,
lucid_model = c("early", "parallel", "serial"),
G,
Z = NULL,
Y = NULL,
CoG = NULL,
CoY = NULL,
response = TRUE,
g_computation = FALSE,
verbose = FALSE
)
model |
A model fitted and returned by |
lucid_model |
Specifying LUCID model, "early" for early integration, "parallel" for LUCID in parallel, and "serial" for LUCID in serial. |
G |
Exposures, a numeric vector, matrix, or data frame. Categorical variable should be transformed into dummy variables. If a matrix or data frame, rows represent observations and columns correspond to variables. |
Z |
Omics data. If "early", an N by M matrix. If "parallel", a list, each
element i is a matrix with N rows and P_i features. If "serial", a list, each
element i is a matrix with N rows and p_i features (or a list with two or more
matrices with N rows and a certain number of features). For
|
Y |
Outcome, a numeric vector. Categorical variable is not allowed. Binary outcome should be coded as 0 and 1. |
CoG |
Optional, covariates to be adjusted for estimating the latent cluster. A numeric vector, matrix or data frame. Categorical variable should be transformed into dummy variables. |
CoY |
Optional, covariates to be adjusted for estimating the association between latent cluster and the outcome. A numeric vector, matrix or data frame. Categorical variable should be transformed into dummy variables. |
response |
If |
g_computation |
If |
verbose |
A flag indicates whether detailed information is printed in console. Default is FALSE. |
A list containing:
inclusion.p |
Posterior inclusion probabilities for latent clusters (a matrix for "early"; a list by layer for "parallel" and "serial"). |
pred.x |
Predicted latent-cluster labels (a numeric vector for "early"; a list by layer for "parallel" and "serial"). |
pred.y |
Predicted outcome values. For binary outcomes, this is class
labels when |
pred.z |
Predicted omics means under g-computation mode
( |
# prepare data
G <- sim_data$G
Z <- sim_data$Z
Y_normal <- sim_data$Y_normal
# fit lucid model
fit1 <- estimate_lucid(G = G, Z = Z, Y = Y_normal, lucid_model = "early", K = 2, family = "normal")
# prediction on training set
pred1 <- predict_lucid(model = fit1, G = G, Z = Z, Y = Y_normal, lucid_model = "early")
pred2 <- predict_lucid(model = fit1, G = G, Z = Z, lucid_model = "early")
# g-computation style prediction using only G
pred_g <- predict_lucid(model = fit1, G = G, Z = NULL, g_computation = TRUE, lucid_model = "early")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.