shiftdhd_pbci: Shift function for two depend groups (pbci method)

View source: R/shift_function_calc.R

shiftdhd_pbciR Documentation

Shift function for two depend groups (pbci method)

Description

shiftdhd_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 shiftdhd:

  • 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.

The confidence intervals are not corrected for multiple comparisons, the p values are. 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

shiftdhd_pbci(
  data = df,
  formula = obs ~ gr,
  q = seq(0.1, 0.9, 0.1),
  nboot = 1000,
  alpha = 0.05,
  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 = 1000

alpha

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

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 3 - column 4)

  • 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

Note

Adaptation of Rand Wilcox's 'Dqcomhd', 'bootdpci' & 'rmmcppb' 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. (2012) Comparing two dependent groups via quantiles. J Appl Stat, 39, 2655-2664.

See Also

hd

shiftdhd for the pbse method for dependent groups

shifthd_pbci for independent groups

Examples

set.seed(21) # generate data
n <- 100 # sample size
C1 <- rnorm(100)
df2 <- tibble(cond = factor(c(rep("C1",n),rep("C2",n),rep("C3",n))),
              obs = c(C1+6, C1+rnorm(n)+4, C1+rnorm(n))) # make tibble

out <- shiftdhd_pbci(df, obs ~ cond) # use the default parameters
out <- shiftdhd_pbci(df, obs ~ cond, nboot = 500) # specify the number of bootstrap samples
out <- shiftdhd_pbci(df, obs ~ cond, todo = list(c("C1","C2"),c("C3","C1"))) # specify list of comparisons
out <- shiftdhd_pbci(df, obs ~ cond, q = c(.1,.25,.5,.75,.9)) # specify the quantiles
out <- shiftdhd_pbci(df, doall = TRUE) # compute all comparisons

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