groupwisePercentile.RdCalculates percentiles and confidence intervals for groups.
groupwisePercentile(
formula = NULL,
data = NULL,
var = NULL,
group = NULL,
conf = 0.95,
tau = 0.5,
type = 7,
R = 5000,
boot = FALSE,
basic = FALSE,
normal = FALSE,
percentile = FALSE,
bca = TRUE,
digits = 3,
...
)A formula indicating the measurement variable and the grouping variables. e.g. y ~ x1 + x2.
The data frame to use.
If no formula is given, the measurement variable to use. The name is in double quotes.
The grouping variable to use. The name is in double quotes. Multiple names are listed as a vector. (See example.)
The confidence interval to use.
The percentile to use, expressed as a quantile, e.g. 0.5 for median, 0.25 for 25th percentile.
The type value passed to the quantile function.
The number of bootstrap replicates to use for bootstrapped statistics.
If TRUE, includes the mean of the bootstrapped percentile.
This can be used as an estimate of the percentile for
the group.
If TRUE, includes the basic confidence
intervals for the group means by bootstrap.
See boot.ci.
If TRUE, includes the normal confidence
intervals for the group means by bootstrap.
See boot.ci.
If TRUE, includes the percentile confidence
intervals for the group means by bootstrap.
See boot.ci.
If TRUE, includes the BCa confidence
intervals for the group means by bootstrap.
See boot.ci.
The number of significant figures to use in output.
Other arguments passed to the boot function.
A data frame of requested statistics by group
The input should include either formula and data;
or data, var, and group. (See examples).
With some options, the function may not handle missing values well.
This seems to happen particularly with bca = TRUE.
The parsing of the formula is simplistic. The first variable on the left side is used as the measurement variable. The variables on the right side are used for the grouping variables.
Results for ungrouped (one-sample) data can be obtained by either
setting the right side of the formula to 1, e.g. y ~ 1, or by
setting group=NULL.
### Example with formula notation
data(Catbus)
groupwisePercentile(Steps ~ Teacher + Gender,
data = Catbus,
tau = 0.25,
bca = FALSE,
percentile = TRUE,
R = 1000)
#> Teacher Gender n tau Percentile Conf.level Percentile.lower Percentile.upper
#> 1 Catbus female 6 0.25 7250 0.95 6000 8250
#> 2 Catbus male 4 0.25 6500 0.95 5000 8500
#> 3 Satsuki female 4 0.25 8000 0.95 8000 9000
#> 4 Satsuki male 3 0.25 6500 0.95 6000 8000
#> 5 Totoro female 5 0.25 8000 0.95 6000 9000
#> 6 Totoro male 4 0.25 6750 0.95 6000 7750
### Example with variable notation
data(Catbus)
groupwisePercentile(data = Catbus,
var = "Steps",
group = c("Teacher", "Gender"),
tau = 0.25,
bca = FALSE,
percentile = TRUE,
R = 1000)
#> Teacher Gender n tau Percentile Conf.level Percentile.lower Percentile.upper
#> 1 Catbus female 6 0.25 7250 0.95 6000 8250
#> 2 Catbus male 4 0.25 6500 0.95 5000 8500
#> 3 Satsuki female 4 0.25 8000 0.95 8000 9000
#> 4 Satsuki male 3 0.25 6500 0.95 6000 8000
#> 5 Totoro female 5 0.25 8000 0.95 6000 9000
#> 6 Totoro male 4 0.25 6750 0.95 6000 7750