View source: R/booami_predict.R
| booami_predict | R Documentation |
Minimal, dependency-free predictor for models fitted by
cv_boost_raw, cv_boost_imputed, or a
pooled impu_boost fit. Supports Gaussian (identity)
and logistic (logit) models, returning either the linear predictor
or, for logistic, predicted probabilities.
booami_predict(
object,
X_new,
family = NULL,
type = c("response", "link"),
center_means = NULL
)
object |
A fit returned by |
X_new |
New data (matrix or data.frame) with the same |
family |
Model family; one of |
type |
Prediction type; one of |
center_means |
Optional numeric vector of length |
This function is deterministic and involves no random number generation.
Coefficients are extracted from either $final_model (intercept first,
then coefficients) or from $INT+$BETA (pooled impu_boost).
If X_new has column names and the model has named coefficients, columns
are aligned by name; otherwise they are used in order.
If your training pipeline centered covariates (e.g., center = "auto"),
providing the same center_means here yields numerically consistent
predictions. If not supplied but object$center_means exists, it will
be used automatically. If both are supplied, the explicit center_means
argument takes precedence.
A numeric vector of predictions (length nrow(X_new)). If
X_new has row names, they are propagated to the returned vector.
cv_boost_raw, cv_boost_imputed, impu_boost
# 1) Fit on data WITH missing values
set.seed(123)
sim_tr <- simulate_booami_data(
n = 120, p = 12, p_inf = 3,
type = "gaussian",
miss = "MAR", miss_prop = 0.20
)
X_tr <- sim_tr$data[, 1:12]
y_tr <- sim_tr$data$y
fit <- cv_boost_raw(
X_tr, y_tr,
k = 2, mstop = 50, seed = 123,
impute_args = list(m = 2, maxit = 1, printFlag = FALSE, seed = 1),
quickpred_args = list(method = "spearman", mincor = 0.30, minpuc = 0.60),
show_progress = FALSE
)
# 2) Predict on a separate data set WITHOUT missing values (same p)
sim_new <- simulate_booami_data(
n = 5, p = 12, p_inf = 3,
type = "gaussian",
miss = "MCAR", miss_prop = 0 # <- complete data with existing API
)
X_new <- sim_new$data[, 1:12, drop = FALSE]
preds <- booami_predict(fit, X_new = X_new, family = "gaussian", type = "response")
round(preds, 3)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.