View source: R/difference_asymmetry_calc.R
asymdhd | R Documentation |
asymdhd
computes a difference asymmetry function for one or more
distributions. The difference asymmetry function provides perspective on the
degree a distribution is symmetric about zero, by quantifying the sum of q
and 1-q quantiles. If the groups do not differ, then
the difference scores should be symmetric about zero. In particular, the sum
of q and 1-q quantiles should be zero. If the distribution is symmetric the
function should be approximately a horizontal line. If in addition the median
of the difference scores is zero, the horizontal line will intersect the
y-axis at zero. Confidence intervals and p values are returned for each
quantile sum. The FWE is controlled via Hochberg's method, which is used to
determine critical p values based on the argument alpha. To plot the results
use plot_diff_asym
.
asymdhd( data = df, formula = obs ~ gr, qseq = seq(5, 40, 5)/100, alpha = 0.05, nboot = 1000, todo = NULL, doall = FALSE )
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 |
formula |
A formula with format response variable ∼ predictor variable, where ~ (tilde) means "is modeled as a function of". |
alpha |
Expected long-run type I error rate - default = 0.05. |
nboot |
Number of bootstrap samples - default = 1000. |
todo |
A list of comparisons to perform - default = NULL. |
doall |
Set to TRUE to compute all comparisons - default = FALSE. Not
executed if a |
q |
Quantiles to estimate - default = 0.05:0.05:.4 - must be <.5. |
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 of differences
Column 3 = 1 - quantiles of differences
Column 4 = sum of quantiles
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
This function combines Rand Wilcox's difQpci and Dqdif R functions, from Rallfun-v32.txt - see https://github.com/nicebread/WRS/, http://dornsife.usc.edu/labs/rwilcox/software/.
Wilcox, R.R. & Erceg-Hurn, D.M. (2012) Comparing two dependent groups via quantiles. J Appl Stat, 39, 2655-2664.
hd
asymhd
for independent groups
set.seed(21) # generate data n <- 100 # sample size per condition C1 <- rnorm(n) # condition 1 C2 <- C1 + rnorm(n) + 2 # condition 2 # Data with 3 independent groups and 2 dependent conditions per group library(tibble) df <- tibble(gr = factor(c(rep("group1",n),rep("group2",n),rep("group3",n))), cond1 = c(C1, C1+rnorm(n), C1+rnorm(n)), cond2 = c(C2, C2 + 1, C2 + 3) ) # make tibble library(dplyr) df <- mutate(df, diff = cond1 - cond2) out <- asymdhd(df, diff ~ gr) # use the default parameters out <- asymdhd(df, diff ~ gr, alpha = .90) # specify alpha out <- asymdhd(df, diff ~ gr, nboot = 500) # specify the number of bootstrap samples out <- asymdhd(df, diff ~ gr, todo = list("group1", "group2")) # specify list of comparisons out <- asymdhd(df, diff ~ gr, q = seq(.1,.4,.1)) # specify the quantiles out <- asymdhd(df, diff ~ gr, doall = TRUE) # compute all tests
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.