chances {binda} | R Documentation |
chances
estimates Bernoulli parameters (=chances) from a binary matrix and associated class labels.
chances(X, L, lambda.freqs, verbose=TRUE)
X |
data matrix (columns correspond to variables, rows to samples). |
L |
factor containing the class labels, one for each sample (row). |
lambda.freqs |
shrinkage parameter for class frequencies (if not specified it is estimated). |
verbose |
report shrinkage intensity and other information. |
The class-specific chances are estimated using the empirical means over the 0s and 1s in each class. For estimating the pooled mean the class-specific means are weighted using the
estimated class frequencies. Class frequencies are estimated using freqs.shrink
.
chances
returns a list with the following components:
samples
: the samples in each class,
regularization
: the shrinkage intensity used to estimate the class frequencies,
freqs
: the estimated class frequencies,
means
: the estimated chances (parameters of Bernoulli distribution, expectations of 1s) for each variable conditional on class, as well as the marginal changes (pooled means).
Sebastian Gibb and Korbinian Strimmer (https://strimmerlab.github.io).
# load binda library
library("binda")
# example binary matrix with 6 variables (in columns) and 4 samples (in rows)
Xb = matrix(c(1, 1, 0, 1, 0, 0,
1, 1, 1, 1, 0, 0,
1, 0, 0, 0, 1, 1,
1, 0, 0, 0, 1, 1), nrow=4, byrow=TRUE)
colnames(Xb) = paste0("V", 1:ncol(Xb))
# Test for binary matrix
is.binaryMatrix(Xb) # TRUE
L = factor(c("Treatment", "Treatment", "Control", "Control") )
chances(Xb, L)