View source: R/shift_function_calc.R
shiftdhd | R Documentation |
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
.
shiftdhd( data = df, formula = obs ~ cond, nboot = 200, todo = NULL, doall = FALSE )
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 |
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 |
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.
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
Modified from Rallfun-v32.txt - see https://github.com/nicebread/WRS/.
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.
shifthd
for independent groups.
plot_sf
to plot the results.
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
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.