Learn R Programming

rcompanion (version 1.0.1)

groupwiseMedian: Groupwise medians and confidence intervals

Description

Calculates medians and confidence intervals for groups.

Usage

groupwiseMedian(data, group, var, conf = 0.95, R = 5000, boot = FALSE, pseudo = FALSE, basic = FALSE, normal = FALSE, percentile = FALSE, bca = TRUE, wilcox = FALSE, exact = FALSE, digits = 3, ...)

Arguments

data
The data frame to use.
group
The grouping variable to use. The name is in double quotes. Multiple names are listed as a vector. (See example.)
var
The measurement variable to use. The name is in double quotes.
conf
The confidence interval to use.
R
The number of bootstrap replicates to use for bootstrapped statistics.
boot
If TRUE, includes the mean of the bootstrapped medians. This can be used as an estimate of the median for the group.
pseudo
If TRUE, includes the pseudo median from wilcox.test.
basic
If TRUE, includes the basic confidence intervals for the group means by bootstrap. See boot.ci.
normal
If TRUE, includes the normal confidence intervals for the group means by bootstrap. See boot.ci.
percentile
If TRUE, includes the percentile confidence intervals for the group means by bootstrap. See boot.ci.
bca
If TRUE, includes the BCa confidence intervals for the group means by bootstrap. See boot.ci.
wilcox
If TRUE, includes the wilcox confidence intervals from wilcox.test.
exact
If TRUE, includes the "exact" confidence intervals from MedianCI.
digits
The number of significant figures to use in output.
...
Other arguments passed to the boot function.

Value

A data frame of requested statistics by group.

Details

With some options, the function may not handle missing values well. This seems to happen particularly with bca = TRUE.

References

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

See Also

groupwiseMean, groupwiseHuber groupwiseGeometric

Examples

Run this code
data(Catbus)
groupwiseMedian(data         = Catbus,
                 var         = "Steps",
                 group       = c("Teacher", "Sex"),
                 bca         = FALSE,
                 percentile  = TRUE)
                      

Run the code above in your browser using DataLab