hsf: Hierarchical shift function for one group, two dependent...

View source: R/hsf_calc.R

hsfR Documentation

Hierarchical shift function for one group, two dependent conditions

Description

hsf returns a hierarchical shift function for one group of participants, tested in two dependent conditions (see vignette on github). Full distributions of measurements must be available for each participant and condition. First, quantiles are computed for the distribution of measurements from each condition and each participant. Second, the quantiles are subtracted in each participant. Third, a trimmed mean is computed across participants for each quantile. Confidence intervals and p values are also computed. Correction for multiple comparisons across quantiles is achieved using Hochberg's 1988 procedure. Plot the shift function using plot_hsf.

Usage

hsf(
  data = df,
  formula = obs ~ cond + id,
  qseq = seq(0.1, 0.9, 0.1),
  tr = 0.2,
  alpha = 0.05,
  qtype = 8,
  todo = c(1, 2),
  null.value = 0,
  adj_method = "hochberg"
)

Arguments

data

A data frame in long format. Missing values are not allowed.

formula

A formula with format response variable ∼ predictor variable + id, where ~ (tilde) means "is modeled as a function of" and '+ id' indicates the variable containing the participants' id number.

qseq

Quantiles to estimate - default = deciles.

tr

Percentage of trimming, value between 0 and 1 - default = 0.2 = 20%. Set to zero to get results for the mean.

alpha

Alpha level - default 0.05.

qtype

Type of quantile estimation algorithm to pass to quantile - default = 8.

todo

Order of the groups to compare - default = 1 minus 2.

null.value

Null value to compute P values for the quantile differences - default = 0.

adj_method

Name of method to adjust for multiple quantile comparisons, passed to p.adjust - default = "hochberg".

Value

A list of 8 results:

  1. comparison: names of two conditions being compared.

  2. individual_sf: shift functions for every participant.

  3. group_differences: group quantile differences.

  4. ci: group confidence intervals for quantile differences.

  5. pvalues: P values for every difference.

  6. adjusted_pvalues: P values adjusted for multiple comparisons.

  7. null_value: null value used to compute P values.

  8. quantiles: quantiles estimated in each participant and condition.

References

Rousselet, G. A., & Wilcox, R. R. (2019, January 17). Reaction times and other skewed distributions: problems with the mean and the median. https://doi.org/10.31234/osf.io/3y54r

Hochberg, Y. (1988). A sharper Bonferroni procedure for multiple tests of significance. Biometrika, 75(4), 800-802.

See Also

plot_hsf to plot the results.

Examples

set.seed(22) # subset random sample of participants from the French Lexicon Project
id <- unique(flp$participant)
df <- subset(flp, flp$participant %in% sample(id, 50, replace = FALSE))
out <- hsf(df, rt ~ condition + participant) # use the default parameters
plot_hsf(out) # plot results. Shift functions are overall negative, as
participants tend to be faster in the Word condition than in the Non-Word
condition.

out <- hsf(df, rt ~ condition + participant, qseq = c(.25, .5, .75)) # estimate quartiles only

out <- hsf(df, rt ~ condition + participant, todo = c(2,1)) # reverse comparison


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