mcPBclassifier: Multivariable Isotonic Classification using Projective Bayes...

View source: R/fun.R

mcPBclassifierR Documentation

Multivariable Isotonic Classification using Projective Bayes with Parallel Computing

Description

A parallel computing wrapper for PBclassifier that runs the down-up ("DU") and up-down ("UD") algorithms simultaneously in parallel and returns the result of whichever finishes first. Since both algorithms are guaranteed to achieve the same maximum log posterior gain, i.e. the same logH (Cheung and Kuhn in press), this approach reduces elapsed time without sacrificing optimality.

Usage

mcPBclassifier(X, y, a0 = 0.5, b0 = 0.5, t0 = 0.5)

Arguments

X

a numeric matrix of observed feature combinations, one row per observation, where repeated rows are expected. Each column represents a feature (e.g., a dose component or experimental factor) and each row represents the feature combination observed for one unit.

y

a binary numeric vector of length nrow(X) indicating the observed outcome for each observation (1 = event, 0 = no event).

a0

a positive numeric value specifying the shape1 hyperparameter of the Beta prior in the Beta-Binomial conjugate model. Defaults to 0.5 (Jeffreys prior).

b0

a positive numeric value specifying the shape2 hyperparameter of the Beta prior in the Beta-Binomial conjugate model. Defaults to 0.5 (Jeffreys prior).

t0

a numeric value in (0,1) specifying the threshold on the response rate used to classify each feature combination as event or no-event. Defaults to 0.5.

Details

Before calling this function, the user must set up a parallel plan using future::plan. The recommended plan is future::multisession which works across all platforms including Windows. The future package must be installed separately (install.packages("future")). After the analysis is complete, it is good practice to restore the default sequential plan using future::plan(future::sequential).

Note that parallel overhead may outweigh the benefit for small datasets. This function is most effective when the number of unique feature combinations K is large (typically K > 500) and when run from a terminal rather than RStudio, where future::multicore (forking) is available. In RStudio, future::multisession is used automatically but incurs higher overhead due to session launching costs.

Value

A list of class "pbc" containing the same components as PBclassifier, based on whichever of the "DU" or "UD" algorithm finishes first.

References

Cheung YK, Diaz KM. Monotone response surface of multi-factor condition: estimation and Bayes classifiers. J R Stat Soc Series B Stat Methodol. 2023 Apr;85(2):497-522. doi: 10.1093/jrsssb/qkad014. Epub 2023 Mar 22. PMID: 38464683; PMCID: PMC10919322.

Cheung YK, Kuhn L. Evaluating multiplex diagnostic test using partially ordered Bayes classifier. Ann Appl Stat. In press.

Examples

## Not run: 
# install.packages("future")  # if not already installed
future::plan(future::multisession)  # set up parallel plan first
A <- as.matrix(expand.grid(rep(list(0:1), 6)))
set.seed(2025)
X <- A[sample(nrow(A), size=500, replace=TRUE),]
y <- as.numeric(rowSums(X) >= 3)
fit <- mcPBclassifier(X, y)
future::plan(future::sequential)  # restore default plan when done

## End(Not run)

McMiso documentation built on April 4, 2026, 1:07 a.m.