mosaic (version 0.14.4)

mm: Construct a model based on groupwise means

Description

Calculate groupwise means, presenting the result as a model in the style of lm.

Usage

mm(formula, data = parent.frame(), fun = mean, drop = TRUE, ...)

Arguments

formula

A formula. The left-hand side specifies the variable over which the mean will be taken. The right-hand side gives the grouping variables, separated by &.

data

A data frame to which the formula variables refer. If not specified, variables will be taken from the current environment.

fun

The function used to calculate the means. Default: mean.

drop

Logical flag indicating whether to drop unoccupied groups. Default TRUE. NOT YET IMPLEMENTED.

Additional arguments to be passed to the fun doing the calculation.

Value

mm returns an object of class groupwiseModel. The functions fitted.values, residuals, coefficients, and summary are useful for extracting various features of the value returned by mm

Details

mm is a sort of training function for lm, meant to provide a basis for discussing inference and introducing resampling in a simple, intuitive setting of groupwise means. lm provides a better, more general facility. When using lm to recreate the results of mm, include all the interaction terms, that is, use * instead of &. See the examples.

See Also

lm, do