Learn R Programming

LikertMakeR (version 1.0.0)

makePaired: Synthesise a dataset from paired-sample t-test summary statistics

Description

makePaired() generates a dataset from paired-sample t-test summary statistics.

makePaired() generates correlated values so the data replicate rating scales taken, for example, in a before and after experimental design.

The function is effectively a wrapper function for lfast() and lcor() with the addition of a t-statistic from which the between-column correlation is inferred.

Paired t-tests apply to observations that are associated with each other. For example: the same people before and after a treatment; the same people rating two different objects; ratings by husband & wife; etc.

The t-test for paired data is given by:

  • t = mean(D) / (sd(D) / sqrt(n))

where:

  • D = differences in values,

  • mean(D) = mean of the differences,

  • sd(D) = standard deviation of the differences, where

    • sd(D)^2 = sd(X_before)^2 + sd(X_after)^2 - 2 * cov(X_before, X_after)

A paired-sample t-test thus requires an estimate of the covariance between the two sets of observations. makePaired() rearranges these formulae so that the covariance is inferred from the t-statistic.

Usage

makePaired(
  n,
  means,
  sds,
  t_value,
  lowerbound,
  upperbound,
  items = 1,
  precision = 0
)

Value

a dataframe approximating user-specified conditions.

Arguments

n

(positive, integer) sample size

means

(real) 1:2 vector of target means for two before/after measures

sds

(real) 1:2 vector of target standard deviations

t_value

(real) desired paired t-statistic

lowerbound

(integer) lower bound (e.g. '1' for a 1-5 rating scale)

upperbound

(integer) upper bound (e.g. '5' for a 1-5 rating scale)

items

(positive, integer) number of items in the rating scale. Default = 1

precision

(positive, real) relaxes the level of accuracy required. Default = 0

Examples

Run this code

n <- 20
pair_m <- c(2.5, 3.0)
pair_s <- c(1.0, 1.5)
lower <- 1
upper <- 5
k <- 6
t <- -2.5

pairedDat <- makePaired(
  n = n, means = pair_m, sds = pair_s,
  t_value = t,
  lowerbound = lower, upperbound = upper, items = k
)

str(pairedDat)
cor(pairedDat) |> round(2)

t.test(pairedDat$V1, pairedDat$V2, paired = TRUE)

Run the code above in your browser using DataLab