shifthd: Shift function for two independent groups (pbse method)

View source: R/shift_function_calc.R

shifthdR Documentation

Shift function for two independent groups (pbse method)

Description

shifthd returns a shift function for two independent groups or multiple shift functions for pairs of independent groups. shifthd works exclusively with deciles and with alpha = 0.05, so that only 95% confidence intervals can be computed. To use other quantiles and other alpha levels, see shifthd_pbci. Plot the shift function using plot_sf.

Usage

shifthd(data = df, formula = obs ~ gr, nboot = 200, todo = NULL, doall = FALSE)

Arguments

data

A data frame in long format. One column is a factor describing the groups; another column contains the values/observations for each group. A properly formatted data frame can be created using mkt2. Missing values are not allowed.

formula

A formula with format response variable ∼ predictor variable, where ~ (tilde) means "is modeled as a function of".

nboot

The number of bootstrap samples - default = 200.

todo

A list of comparisons to perform - default = NULL.

doall

Set to TRUE to compute all comparisons - default = FALSE. Not executed if a todo list is provided.

Details

A shift function shows the difference between the quantiles of two groups as a function of the quantiles of one group. For inferences, the function returns a confidence interval for each quantile difference. The confidence intervals are computed using a percentile bootstrap estimation of the standard error of the difference between quantiles. The confidence intervals are corrected for multiple comparisons so that the simultaneous probability coverage is .95.

The deciles are estimated using the Harrell-Davis quantile estimator of the qth quantile. The default number of bootstrap samples is nboot = 200. Independent bootstrap samples are used for each quantile and for each group.

Value

A list of data frames, one data frame per comparison. Each data frame has one row per decile. The columns are:

  • Column 1 = quantiles - seq(0.1, 0.9, 0.1)

  • Column 2 = deciles for group 1

  • Column 3 = deciles for group 2

  • Column 4 = differences (column 1 - column 2)

  • Column 5 = lower bounds of the confidence intervals

  • Column 6 = upper bounds of the confidence intervals

Note

Modified from Rallfun-v32.txt - see https://github.com/nicebread/WRS/.

References

Harrell, F.E. & Davis, C.E. (1982) A new distribution-free quantile estimator. Biometrika, 69, 635-640.

Wilcox, R.R. (1995) Comparing Two Independent Groups Via Multiple Quantiles. Journal of the Royal Statistical Society. Series D (The Statistician), 44, 91-99.

See Also

shiftdhd for dependent groups.

plot_sf to plot the results.

Examples

set.seed(21) # generate data
n <- 100 # sample size
df <- tibble(gr = factor(c(rep("group1",n),rep("group2",n),rep("group3",n))),
             obs= c(rnorm(n)+6, rnorm(n)+4, rnorm(n)*1.5+6)) # make tibble

out <- shifthd(df, obs ~ gr) # use the default parameters
out <- shifthd(df, obs ~ gr, nboot = 500) # specify the number of bootstrap samples
out <- shifthd(df, obs ~ gr, todo = list(c("g1","g2"),c("g3","g1"))) # specify list of comparisons
out <- shifthd(df, doall = TRUE) # compute all comparisons


GRousselet/rogme documentation built on Nov. 12, 2022, 4:38 a.m.