lisa_stuff/setup_iat.R

library(pipeline)

setwd("lisa_stuff/")

H1 <- list(
  desc = "Mean RT will be significantly slower in the incongruent condition compared to the congruent condition.",
  criteria = list(
    list(
      analysis = "H1_ttest",
      result = "p.value",
      direction = "<",
      comparator = .05
    ),
    list(
      analysis = "H1_ttest",
      result = "estimate",
      direction = ">",
      comparator = 0
    )
  ),
  evaluation = "&"
)

H2 <- list(
  desc = "Reaction times for congruent and incongruent trials will be signifiantly and positively correlated.",
  criteria = list(
    list(
      analysis = "H2_cor",
      result = "p.value",
      direction = "<",
      comparator = 0.05
    ),
    list(
      analysis = "H2_cor",
      result = "estimate",
      direction = ">",
      comparator = 0
    )
  ),
  evaluation = "&"
)

A1 <- list(
  name = "H1_ttest",
  func = "t.test",
  params = list(
    x = ".data$incongruent",
    y = ".data$congruent",
    alternative = "two.sided",
    paired = TRUE,
    var.equal = FALSE,
    conf.level = 0.95
  )
)

A2 <- list(
  name = "H2_cor",
  func = "cor.test",
  params = list(
    x = ".data$congruent",
    y = ".data$incongruent",
    alternative = "two.sided",
    method = "pearson",
    conf.level = 0.95
  )
)

n_sub <- 50
dat <- faux::rnorm_multi(n_sub, 2, .5, c(500, 750), 250, c("congruent", "incongruent"))
dat$sub_id = 1:n_sub

readr::write_csv(dat, "iat.csv")

processed_data_desc <- list(
  name = "IAT Data",
  description = "This is an example dataset for pipeline",
  schemaVersion = "Psych-DS 0.1.0",
  variableMeasured = list(
    list(
      unitText = "Subject ID",
      name = "sub_id",
      description = "Identity of each subject. Provides a unique rowid in this dataset.",
      naValues = "NA"
    ),
    list(
      unitText ="Congruent RT",
      name = "congruent",
      description = "The mean reaction time to congruent trials, in milliseconds",
      minValue = "0",
      naValues = "NA"
    ),
    list(
      unitText = "Incongruent RT",
      name = "incongruent",
      description = "The mean reaction time to incongruent trials, in milliseconds",
      minValue = "0",
      naValues = "NA"
    )
  ),
  data = dat
)





study <- setup_pipeline(
  name = "IAT Example",
  hypotheses = list(H1, H2),
  data = list(processed_data_desc),
  analyses = list(A1, A2)
)

save_pipeline(study, "iat.json")
debruine/pipeline documentation built on May 8, 2019, 8:59 a.m.