Collapses counts along equal levels of binned covariates.
collapse(v,counts,mu=NULL,bins=NULL)
Either matrix or Matrix of covariates (matches covars
in dmr
).
Either matrix or Matrix of multinomial counts, or a factor (matches counts
in dmr
).
Possible pre-specified fixed effects for dmr
; otherwise they are calculated here.
The number of quantile bins into which we collapse v
. bins=NULL
does no collapsing.
A list containing collapsed and formatted v
, counts
, and nbin
, along with mu = log(rowSums(counts))
, the plug-in fixed effect estimates for dmr.
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.
we8there