agg_binomial {holiglm}R Documentation

Aggregate Binomial Data

Description

A simple function for aggregating binomial data, from a form where y contains only 0 and 1 and X could contain duplicated rows, into a format where y is the matrix of counted successes and failures and X does not contain duplicates. If X contains factor variables, the model matrix corresponding to X will be returned.

Usage

agg_binomial(formula, data, as_list = TRUE)

Arguments

formula

a formula object defining the aggregation.

data

a data.frame to be aggregated.

as_list

a logical giving if the return value should be a list. If FALSE the return value is a data.frame.

Value

A list (or data.frame) containing aggregated binomial data with counted successes and failures.

Examples

set.seed(12345)
data <- data.frame(y = rbinom(50, 1, 0.7),
                   a = factor(sample(c(1, 2), 50, TRUE)),
                   b = factor(sample(c(1, 2, 3), 50, TRUE)))
agg_binomial(y ~ ., data)

[Package holiglm version 1.0.0 Index]