collapse: Data checking and binning

View source: R/collapse.R

collapseR Documentation

Data checking and binning

Description

Collapses counts along equal levels of binned covariates.

Usage

collapse(v,counts,mu=NULL,bins=NULL)

Arguments

v

Either matrix or Matrix of covariates (matches covars in dmr).

counts

Either matrix or Matrix of multinomial counts, or a factor (matches counts in dmr).

mu

Possible pre-specified fixed effects for dmr; otherwise they are calculated here.

bins

The number of quantile bins into which we collapse v. bins=NULL does no collapsing.

Details

For each column of v, aggregates the observations into bins defined by their average value. Both v and counts are then collapsed according to levels of the interaction across implied bin-factors, and the number of observations in each bin is recorded as n. Look at the code of the dmr function to see collapse used in practice.

Value

A list containing collapsed and formatted v, counts, and nbin, along with mu = log(rowSums(counts)), the plug-in fixed effect estimates for dmr.

Author(s)

Matt Taddy mataddy@gmail.com

See Also

we8there


TaddyLab/distrom documentation built on April 6, 2022, 3:47 p.m.