Learn R Programming

LikertMakeR (version 1.3.0)

makeRepeated: Reproduce Repeated-Measures Data from ANOVA Summary Statistics

Description

Constructs a synthetic dataset and inter-timepoint correlation matrix from a repeated-measures ANOVA result, based on reported means, standard deviations, and an F-statistic. This is useful when only summary statistics are available from published studies.

Usage

makeRepeated(
  n,
  k,
  means,
  sds,
  f_stat,
  df_between = k - 1,
  df_within = (n - 1) * (k - 1),
  structure = c("cs", "ar1", "toeplitz"),
  names = paste0("time_", 1:k),
  items = 1,
  lowerbound = 1,
  upperbound = 5,
  return_corr_only = FALSE,
  diagnostics = FALSE,
  ...
)

Value

A named list with components:

data

A data frame of simulated repeated-measures responses (unless return_corr_only = TRUE).

correlation_matrix

The estimated inter-timepoint correlation matrix.

structure

The correlation structure assumed.

achieved_f

The F-statistic produced by the estimated rho value (if diagnostics = TRUE).

feasible_f_range

Minimum and maximum achievable F-values under the chosen structure (shown if diagnostics are requested).

recommended_f

Conservative, moderate, and strong F-statistic suggestions for similar designs.

effect_size_raw

Unstandardised effect size across timepoints.

effect_size_standardised

Effect size standardised by average variance.

Arguments

n

Integer. Sample size used in the original study.

k

Integer. Number of repeated measures (timepoints).

means

Numeric vector of length k. Mean values reported for each timepoint.

sds

Numeric vector of length k. Standard deviations reported for each timepoint.

f_stat

Numeric. The reported repeated-measures ANOVA F-statistic for the within-subjects factor.

df_between

Degrees of freedom between conditions (default: k - 1.

df_within

Degrees of freedom within-subjects (default: (n - 1) * (k - 1)).

structure

Character. Correlation structure to assume: "cs", "ar1", or "toeplitz" (default = "cs").

names

Character vector of length k. Variable names for each timepoint (default: "time_1" to "time_k").

items

Integer. Number of items used to generate each scale score (passed to lfast).

lowerbound,

Integer. Lower bounds for Likert-type response scales (default: 1).

upperbound,

Integer. upper bounds for Likert-type response scales (default: 5).

return_corr_only

Logical. If TRUE, return only the estimated correlation matrix.

diagnostics

Logical. If TRUE, include diagnostic summaries such as feasible F-statistic range and effect sizes.

...

Reserved for future use.

Details

This function estimates the average correlation between repeated measures by matching the reported F-statistic, under one of three assumed correlation structures:

  • "cs" (Compound Symmetry): The Default. Assumes all timepoints are equally correlated. Common in standard RM-ANOVA settings.

  • "ar1" (First-Order Autoregressive): Assumes correlations decay exponentially with time lag.

  • "toeplitz" (Linearly Decreasing): Assumes correlation declines linearly with time lag - a middle ground between "cs" and "ar1".

The function then generates a data frame of synthetic item-scale ratings using lfast, and adjusts them to match the estimated correlation structure using lcor.

Set return_corr_only = TRUE to extract only the estimated correlation matrix.

See Also

lfast, lcor

Examples

Run this code

set.seed(42)

out1 <- makeRepeated(
  n = 64,
  k = 3,
  means = c(3.1, 3.5, 3.9),
  sds = c(1.0, 1.1, 1.0),
  items = 4,
  f_stat = 4.87,
  structure = "cs",
  diagnostics = FALSE
)

head(out1$data)
out1$correlation_matrix

out2 <- makeRepeated(
  n = 32, k = 4,
  means = c(2.75, 3.5, 4.0, 4.4),
  sds = c(0.8, 1.0, 1.2, 1.0),
  f_stat = 16,
  structure = "ar1",
  items = 5,
  lowerbound = 1, upperbound = 7,
  return_corr_only = FALSE,
  diagnostics = TRUE
)

print(out2)


out3 <- makeRepeated(
  n = 64, k = 4,
  means = c(2.0, 2.25, 2.75, 3.0),
  sds = c(0.8, 0.9, 1.0, 0.9),
  items = 4,
  f_stat = 24,
  # structure = "toeplitz",
  diagnostics = TRUE
)

str(out3)

Run the code above in your browser using DataLab