t_test_mf: t_test_mf

View source: R/t_test_mf.R

t_test_mfR Documentation



Basic function for running the frequentist's t-tests included in the main analyses


  group = NULL,
  na.rm = FALSE,
  paired = TRUE,
  quanz = c(0.05, 0.95),
  meta.effect = "d_to_eta2",
  phase = "acquisition",
  dv = "scr",
  exclusion = "full data",
  cut_off = "full data"



The column name(s) of the conditioned responses for the first conditioned stimulus


The column name(s) of the conditioned responses for the second conditioned stimulus


A data frame containing all the relevant columns for the analyses


The name of the column including the participant numbers. Unique numbers are expected


the name of the group, if included, default to NULL


Whether NAs should be removed, default to FALSE


Whether the t-test refers to dependent (i.e., paired) or to independent sample(s). Default to TRUE


Quantiles for the meta-analytic effect sizes. Default to .05 (lower) and.95 (upper)


How the meta-analytic effect should be computed, Default to "d_to_eta2" (see details for more information)


The conditioned phase that the analyses refer to. Accepted values are acquisition, acq, extinction, or ext


name of the measured conditioned response. Default to "SCR"


Name of the data reduction procedure used. Default to full data


cut off Name of the cut_off applied. Default to full data


Given the correct names for the cs1, cs2, subj, and data, the function will run one- and two-sided frequentist's t-tests. In case cs1 or cs2 refer to multiple columns, the mean – per row – for each one of these variables will be computed first before running the t-test. Please note that cs1 is implicitly referred to the cs that is reinforced, and cs2 to the cs that is not reinforced. Depending on whether the data refer to an acquisition or extinction phase (as defined in the phase argument), the function will return a positive one sided, or negative one-sided, respectively t-test in addition to the two-sided t-test. The returned effect size is Hedge's g in the column effect size. For the meta-analytic effect size (effect.size.ma), the returned effect size is eta-squared.

The function by default runs a Welch t-test, meaning it assumes unequal variances. This is due to calls that such a test should be preferred over Student's t-test, at least for paired samples t-test. Please note that if we let R decide which test to run – this is done by default in stats::t.test, then for some test there would be a Student t-test whereas in some others not. There are two different ways to compute the meta-analytic effect sizes but the results may differ. The option "t_to_eta2" computes the eta squared via the t values whereas the "d_to_eta2" the eta squared is computed via the Cohen's d value.


A tibble with the following column names:

x: the name of the independent variable (e.g., cs)

y: the name of the dependent variable as this defined in the dv argument exclusion: see exclusion argument

model: the model that was run (e.g., t-test)

controls: ignore this column for this test

method: the model that was run

p.value: the p-value of the test

effect.size: the estimated effect size

effect.size.ma: the estimated effect size for the meta-analytic plots. Here we used eta squared

effect.size.ma.lci: low confidence intervals for the meta-analytic effect size

effect.size.ma.hci: high confidence intervals for the meta-analytic effect size

estimate: the estimate of the test run. For the t-test is the mean of the differences

statistic: the t-value

conf.low: the lower confidence interval for the estimate

conf.high: the higher confidence interval for the estimate

framework: were the data analysed within a NHST or Bayesian framework?

data_used: a list with the data used for the specific test


# Load example data

# Paired sample t-tests
t_test_mf(cs1 = "CSP1", cs2 = "CSM1", subj = "id", data = example_data)

# Independent  sample t-tests
t_test_mf(cs1 = "CSP1", cs2 = "CSM1", subj = "id",  group = "group", data = example_data)

multifear documentation built on Sept. 24, 2023, 1:06 a.m.