| Title: | Weighted Meta-Analysis with Pseudo-Populations |
|---|---|
| Description: | Implementation of integrative weighting approaches for multiple observational studies and causal inferences. The package features three weighting approaches, each representing a special case of the unified weighting framework, introduced by Guha and Li (2024) <doi:10.1093/biomtc/ujae070>, which includes an extension of inverse probability weights for data integration settings. |
| Authors: | Subharup Guha [aut, cre], Mengqi Xu [aut], Chayce Reed [aut], Kashish Priyam [aut], Yi Li [aut] |
| Maintainer: | Subharup Guha <[email protected]> |
| License: | GPL-3 |
| Version: | 1.3.0 |
| Built: | 2026-06-05 14:41:19 UTC |
| Source: | https://github.com/cran/WMAP |
This function calculates balancing weights based on the specified pseudo-population method.
balancing.weights( S, Z, X, method, naturalGroupProp, num.random = 40, gammaMin = 0.001, gammaMax = (1 - 0.001), seed = NULL, verbose = TRUE, suppress_diagnostics = FALSE, nodesize = NULL )balancing.weights( S, Z, X, method, naturalGroupProp, num.random = 40, gammaMin = 0.001, gammaMax = (1 - 0.001), seed = NULL, verbose = TRUE, suppress_diagnostics = FALSE, nodesize = NULL )
S |
Vector of factor levels representing the study memberships. Takes values in {1, ..., J}. |
Z |
Vector of factor levels representing the group memberships. Takes values in {1, ..., K}. |
X |
Covariate matrix of |
method |
Pseudo-population method, i.e., weighting method. Take values in |
naturalGroupProp |
Relevant only for FLEXOR method: a fixed user-specified probability vector |
num.random |
Relevant only for FLEXOR method: number of random starting points of |
gammaMin |
Relevant only for FLEXOR method: Lower bound for each |
gammaMax |
Relevant only for FLEXOR method: Upper bound for each |
seed |
Seed for random number generation. Default is |
verbose |
Logical; Relevant only for FLEXOR method: if |
suppress_diagnostics |
Logical; if TRUE, suppress diagnostic warnings (default: FALSE). Used internally during bootstrapping to avoid console clutter. |
nodesize |
Integer nodesize for the propensity score random forests; if |
An S3 list object with the following components:
empirically normalized sample weights.
Percentage sample effective sample size (ESS) for the pseudo-population.
data(demo) # IC Method weights_ic <- balancing.weights(S, Z, X, method = "IC", naturalGroupProp) summary(weights_ic) # IGO Method weights_igo <- balancing.weights(S, Z, X, method = "IGO", naturalGroupProp) summary(weights_igo) # FLEXOR Method weights_flexor <- balancing.weights(S, Z, X, method = "FLEXOR", naturalGroupProp, num.random = 40) summary(weights_flexor)data(demo) # IC Method weights_ic <- balancing.weights(S, Z, X, method = "IC", naturalGroupProp) summary(weights_ic) # IGO Method weights_igo <- balancing.weights(S, Z, X, method = "IGO", naturalGroupProp) summary(weights_igo) # FLEXOR Method weights_flexor <- balancing.weights(S, Z, X, method = "FLEXOR", naturalGroupProp, num.random = 40) summary(weights_flexor)
This function estimates causal effects based on the specified pseudo-population method. The FLEXOR method involves an iterative two-step procedure.
causal.estimate( S, Z, X, Y, B = 0, method, naturalGroupProp = NULL, num.random = 40, gammaMin = 0.001, gammaMax = (1 - 0.001), seed = NULL, verbose = TRUE, parallel = FALSE, n_cores = NULL, outcome_model = FALSE, crossfit_folds = NULL )causal.estimate( S, Z, X, Y, B = 0, method, naturalGroupProp = NULL, num.random = 40, gammaMin = 0.001, gammaMax = (1 - 0.001), seed = NULL, verbose = TRUE, parallel = FALSE, n_cores = NULL, outcome_model = FALSE, crossfit_folds = NULL )
S |
Vector of factor levels representing the study memberships. Takes values in {1, ..., J}. |
Z |
Vector of factor levels representing the group memberships. Takes values in {1, ..., K}. |
X |
Covariate matrix of |
Y |
Matrix of |
B |
Number of bootstrap samples for variance estimation. Default is 0 (point estimates only). |
method |
Pseudo-population method, i.e., weighting method. Take values in |
naturalGroupProp |
Relevant only for FLEXOR method: a fixed user-specified probability vector |
num.random |
Relevant only for FLEXOR method: number of random starting points of |
gammaMin |
Relevant only for FLEXOR method: Lower bound for each |
gammaMax |
Relevant only for FLEXOR method: Upper bound for each |
seed |
Seed for random number generation. Default is |
verbose |
Logical; if |
parallel |
Logical; if TRUE, use parallel processing for bootstrap (default: FALSE) |
n_cores |
Number of cores to use for parallel bootstrap (default: availableCores() - 1). Only used if parallel = TRUE. |
outcome_model |
Logical; if TRUE, fits a random forest on X, S, Z and substitutes predicted outcomes for observed Y. Default FALSE. |
crossfit_folds |
Integer >= 2 for K-fold cross-fitting of the outcome model, or NULL (default) to fit on the full data. Only used when |
An S3 list object with the following components:
Percentage sample effective sample size (ESS) of the pseudo-population.
An array of dimension , containing:
Estimated means, standard deviations (SDs), and medians (dimension 1),
For groups (dimension 2),
And outcomes (dimension 3).
Estimated mean group differences for outcomes.
An array of dimension , containing:
moments.ar of the th bootstrap sample (dimensions 1–3),
For bootstrap samples (dimension 4).
A matrix of dimension containing:
otherFeatures.v of the th bootstrap sample (dimension 1),
For bootstrap samples (dimension 2).
A vector of length
containing percentage sample ESS for bootstrap samples.
Pseudo-population method, i.e., weighting method.
data(demo) # Point estimates only (no CIs) result <- causal.estimate(S, Z, X, Y, B = 0, method = "IC", naturalGroupProp) summary(result) # Bootstrap CIs set.seed(1) result <- causal.estimate(S, Z, X, Y, B = 100, method = "IC", naturalGroupProp) summary(result) plot(result) # FLEXOR method result <- causal.estimate(S, Z, X, Y, B = 100, method = "FLEXOR", naturalGroupProp, num.random = 40, seed = 1) # Outcome model: substitute RF predictions for observed Y result <- causal.estimate(S, Z, X, Y, B = 0, method = "FLEXOR", naturalGroupProp, outcome_model = TRUE) # Parallel bootstrap result <- causal.estimate(S, Z, X, Y, B = 100, method = "FLEXOR", naturalGroupProp, parallel = TRUE, n_cores = 2)data(demo) # Point estimates only (no CIs) result <- causal.estimate(S, Z, X, Y, B = 0, method = "IC", naturalGroupProp) summary(result) # Bootstrap CIs set.seed(1) result <- causal.estimate(S, Z, X, Y, B = 100, method = "IC", naturalGroupProp) summary(result) plot(result) # FLEXOR method result <- causal.estimate(S, Z, X, Y, B = 100, method = "FLEXOR", naturalGroupProp, num.random = 40, seed = 1) # Outcome model: substitute RF predictions for observed Y result <- causal.estimate(S, Z, X, Y, B = 0, method = "FLEXOR", naturalGroupProp, outcome_model = TRUE) # Parallel bootstrap result <- causal.estimate(S, Z, X, Y, B = 100, method = "FLEXOR", naturalGroupProp, parallel = TRUE, n_cores = 2)
A dataset containing example data for demonstration purposes.
data(demo)data(demo)
An rda object, with 450 observations and the following variables:
A vector of factor levels, representing the study memberships.
A vector of factor levels, representing the group memberships.
A covariate matrix.
An outcome matrix.
The relative group prevalences of the larger natural population. Necessary only for FLEXOR weights; it should be skipped for IC and IGO weights.
Disease subtype names "IDC" or "ILC"
Demo Dataset for WMAP Examples
A demonstration dataset containing multi-site, multi-group observational data for testing WMAP weighting methods. The data simulates a study of breast cancer subtypes across mutliple hospitals.
balancing.weights for computing weights
causal.estimate for estimating causal effects
# Load the demo dataset data(demo) # Examine the structure str(S) # Study memberships str(Z) # Group memberships table(S, Z) # Cross-tabulation of studies and groups # Basic usage with IC method weights <- balancing.weights(S, Z, X, method = "IC", naturalGroupProp) summary(weights) # Full causal analysis results <- causal.estimate(S, Z, X, Y, B = 10, method = "IC", naturalGroupProp) summary(results) plot(results)# Load the demo dataset data(demo) # Examine the structure str(S) # Study memberships str(Z) # Group memberships table(S, Z) # Cross-tabulation of studies and groups # Basic usage with IC method weights <- balancing.weights(S, Z, X, method = "IC", naturalGroupProp) summary(weights) # Full causal analysis results <- causal.estimate(S, Z, X, Y, B = 10, method = "IC", naturalGroupProp) summary(results) plot(results)
Creates a boxplot showing the distribution of effective sample size (ESS) across bootstrap samples for the specified weighting method.
## S3 method for class 'causal_estimates' plot(x, ...)## S3 method for class 'causal_estimates' plot(x, ...)
x |
An object of class 'causal_estimates' returned by |
... |
Additional arguments:
|
A boxplot of percent sample ESS for a specific weighting method (FLEXOR, IC, or IGO
## Not run: data(demo) result <- causal.estimate(S, Z, X, Y, B = 5, method = "FLEXOR", naturalGroupProp) plot(result) plot(result, y_limit = c(0, 100), color = "steelblue") ## End(Not run)## Not run: data(demo) result <- causal.estimate(S, Z, X, Y, B = 5, method = "FLEXOR", naturalGroupProp) plot(result) plot(result, y_limit = c(0, 100), color = "steelblue") ## End(Not run)
Displays a summary of balancing weights including the numnber of weights. their distribution, and the effective sample size.
## S3 method for class 'balancing_weights' summary(object, ...)## S3 method for class 'balancing_weights' summary(object, ...)
object |
An object of class 'balancing_weights' returned by |
... |
Additional arguments (currently unused, reserved for future extensions). |
No return value, called for side effects (prints summary to console)
The total number of weights
Statistical summary of weight values
Percentage sample effective sample size (ESS) for the pseudo-population
data(demo) result <- balancing.weights(S, Z, X, method = "IC", naturalGroupProp) summary(result)data(demo) result <- balancing.weights(S, Z, X, method = "IC", naturalGroupProp) summary(result)
Displays a comprehensive summary of causal estimates including effective sample size, mean differences between groups with confidence intervals, and standard deviation ratios.
## S3 method for class 'causal_estimates' summary(object, ...)## S3 method for class 'causal_estimates' summary(object, ...)
object |
An object of class 'causal_estimates' returned by |
... |
Additional arguments (currently unused, reserved for future extensions). |
No return value, called for side effects (prints summary to console):
Percentage sample effective sample size (ESS) for the pseudo-population
The mean differences between two groups with their corresponding 95
The ratios of standard deviations between two groups with their corresponding 95
data(demo) set.seed(1) result <- causal.estimate(S, Z, X, Y, B = 5, method = "IC", naturalGroupProp) summary(result)data(demo) set.seed(1) result <- causal.estimate(S, Z, X, Y, B = 5, method = "IC", naturalGroupProp) summary(result)