shifthd_pbci: Shift function for two independent groups (pbci method)

View source: R/shift_function_calc.R

shifthd_pbciR Documentation

Shift function for two independent groups (pbci method)

Description

shifthd_pbci returns a shift function for two independent groups or multiple shift functions for pairs of independent groups. It uses the Harrell-Davis quantile estimator in conjunction with a percentile bootstrap approach. Unlike shifthd:

  • The confidence intervals are calculated using a percentile bootstrap of the quantiles, instead of a percentile bootstrap of the standard error of the difference of the quantiles.

  • The quantiles can be specified and are not limited to the deciles.

  • Tied values are allowed.

Examples of quantile sequences, from sparse to dense:

  • q = c(.25,.5,.75)

  • q = c(.1,.25,.5,.75,.9)

  • q = seq(.1, .9, .1)

  • q = seq(.05, .95, .05)

Usage

shifthd_pbci(
  data = df,
  formula = obs ~ gr,
  q = seq(0.1, 0.9, 0.1),
  nboot = 2000,
  alpha = 0.05,
  adj_ci = TRUE,
  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".

q

Quantiles to estimate - default = deciles 0.1:0.1:.9.

nboot

Number of bootstrap samples - default = 2000

alpha

Expected long-run type I error rate - default = 0.05

adj_ci

Adjust confidence intervals & p values for multiple comparisons - default = TRUE

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.

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

  • Column 2 = quantiles for group 1

  • Column 3 = quantiles for group 2

  • Column 4 = quantile differences (column 4 - column 5)

  • Column 5 = lower bounds of the confidence intervals

  • Column 6 = upper bounds of the confidence intervals

  • Column 7 = critical p_values based on Hochberg's method

  • Column 8 = p_values (based on Hochberg's method if adj_ci = TRUE)

Note

Adaptation of Rand Wilcox's 'qcomhd' & 'pb2gen' R functions (http://dornsife.usc.edu/labs/rwilcox/software/). From Rallfun-v32.txt - see https://github.com/nicebread/WRS/.

References

Wilcox, R.R., Erceg-Hurn, D.M., Clark, F. & Carlson, M. (2014) Comparing two independent groups via the lower and upper quantiles. J Stat Comput Sim, 84, 1543-1551.

See Also

hd

shifthd for the pbse method for independent groups,

shiftdhd_pbci for dependent groups

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_pbci(df, obs ~ gr) # use the default parameters
out <- shifthd_pbci(df, obs ~ gr, nboot = 500) # specify the number of bootstrap samples
out <- shifthd_pbci(df, obs ~ gr, todo = list(c("group1","group2"),c("group3","group1"))) # specify list of comparisons
out <- shifthd_pbci(df, obs ~ gr, q = c(.1,.25,.5,.75,.9)) # specify the quantiles
out <- shifthd_pbci(df, doall = TRUE) # compute all comparisons


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