[R] Grouping binary data

Prof Brian Ripley ripley at stats.ox.ac.uk
Thu Jun 19 14:54:10 CEST 2003


On Thu, 19 Jun 2003, Henric Nilsson wrote:

> Dear all,
> 
> I'm analyzing a binary outcome using glm() with a binomial distribution and 
> a logit link, and have now reached the point where I'd like to do some 
> model checking. Since my data are in binary form I'd like to collapse over 
> the cross-classification of the factors before the model checking.
> 
> Are there any nice and simple ways doing this? If so, how? If not, I'd be 
> grateful for receiving some hints on how this can be accomplished.

Look at loglm1.data.frame in package MASS, or xtabs: each work by setting 
up a suitable call to table.

If you want to sum up over cases with the same factors (not what is 
usually meant by collapsing), take a look at multinom (package nnet) which 
has options to do this for multinomials (and Bernoulli is a special case).

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595




More information about the R-help mailing list