hsf_pb: Percentile bootstrap hierarchical shift function for one...

View source: R/hsf_calc.R

hsf_pbR Documentation

Percentile bootstrap hierarchical shift function for one group, two dependent conditions

Description

hsf_pb returns a percentile bootstrap 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 are computed using the percentile bootstrap. This function focuses on estimation, so there is no correction for multiple comparisons and no p values. Plot the shift function using plot_hsf_pb or plot_hsf_pb_dist.

Usage

hsf_pb(
  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),
  nboot = 1000
)

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.

nboot

Number of boostrap samples - default = 1000.

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. hdi: group highest density intervals for quantile differences.

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

  7. boot_samples: bootstrap differences for each quantile.

  8. nboot: number of bootstrap samples.

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

See Also

plot_hsf_pb to plot the results. plot_hsf_pb_dist to plot the distributions of bootstrap samples.

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_pb(df, rt ~ condition + participant) # use the default parameters
plot_hsf_pb(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_pb(df, rt ~ condition + participant, qseq = c(.25, .5, .75)) # estimate quartiles only

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


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