shiftdhd: Shift function for two dependent groups (pbse methods)

View source: R/shift_function_calc.R

shiftdhdR Documentation

Shift function for two dependent groups (pbse methods)

Description

shiftdhd returns a shift function for two dependent groups or multiple shift functions for pairs of dependent groups. shiftdhd 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 shiftdhd_pbci. Plot the shift function using plot_sf.

Usage

shiftdhd(
  data = df,
  formula = obs ~ cond,
  nboot = 200,
  todo = NULL,
  doall = FALSE
)

Arguments

data

A data frame in long format. One column is a factor describing the conditions; another column contains the values/observations for each condition. A properly formatted data frame can be created using link{mkt2} or link{mkt2d}. 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. The same 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. (2012) Introduction to robust estimation and hypothesis testing. Academic Press, San Diego, CA.

See Also

shifthd for independent groups.

plot_sf to plot the results.

Examples

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

out <- shiftdhd(df, obs ~ cond) # use the default parameters
out <- shiftdhd(df, obs ~ cond, nboot = 500) # specify the number of bootstrap samples
out <- shiftdhd(df, obs ~ cond, todo = list(c("C1","C2"),c("C3","C1"))) # specify list of comparisons
out <- shiftdhd(df, doall = TRUE) # compute all comparisons


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