Learn R Programming

rcompanion (version 1.4.0)

groupwiseGeometric: Groupwise geometric means and confidence intervals

Description

Calculates geometric means and confidence intervals for groups.

Usage

groupwiseGeometric(formula = NULL, data = NULL, var = NULL, group = NULL, conf = 0.95, na.rm = TRUE, digits = 3, ...)

Arguments

formula
A formula indicating the measurement variable and the grouping variables. e.g. y ~ x1 + x2.
data
The data frame to use.
var
The measurement variable to use. The name is in double quotes.
group
The grouping variable to use. The name is in double quotes. Multiple names are listed as a vector. (See example.)
conf
The confidence interval to use.
na.rm
If TRUE, removes NA values in the measurement variable.
digits
The number of significant figures to use in output.
...
Other arguments. Not currently useful.

Value

A data frame of geometric means, standard deviations, standard errors, and confidence intervals.

Details

The input should include either formula and data; or data, var, and group. (See examples).

The function computes means, standard deviations, standard errors, and confidence intervals on log-transformed values. Confidence intervals are calculated in the traditional manner with the t-distribution. These statistics assume that the data are log-normally distributed. For data not meeting this assumption, medians and confidence intervals by bootstrap may be more appropriate.

References

http://rcompanion.org/handbook/C_03.html

See Also

groupwiseMean, groupwiseMedian groupwiseHuber

Examples

Run this code
### Example with formula notation 
data(Catbus)
groupwiseGeometric(Steps ~ Sex + Teacher,
                   data   = Catbus)

### Example with variable notation                                              
data(Catbus)
groupwiseGeometric(data   = Catbus,
                   var    = "Steps",
                   group  = c("Sex", "Teacher"))
                      

Run the code above in your browser using DataLab