reproduce_analysis_sim: Simulate the Analysis for Longitudinal Illusory Truth Study

Description Usage Arguments Details Examples

View source: R/reproduce.R

Description

Runs the main analysis for \insertCiteHenderson_Simons_Barr_2021;textualtruthiness on simulated data.

Usage

1
2
3
4
5
6
7
reproduce_analysis_sim(
  path,
  outfile = "analysis.html",
  recipe = FALSE,
  parallel = TRUE,
  infile = NULL
)

Arguments

path

Path to a subdirectory containing the preprocessed anonymized (simulated) data files (see simulate_resp_files).

outfile

Path to the HTML output file.

recipe

Include instructions on how to reproduce the analysis.

parallel

Whether to fit models using a single CPU processing core (FALSE) or multiple cores (TRUE, the default).

infile

Path to the R Markdown script; NULL to use the built-in script.

Details

Runs R Markdown script on the data in the provided subdirectory and renders the HTML report to outfile. The master R Markdown script can be accessed using:

rmarkdown::draft("analysis.Rmd", "illusory-truth-analysis-sim", "truthiness")

Note that this script can take *very* long to run, depending on the size of the simulated dataset, the number of processing cores, and the computational power of the hardware.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
td_raw <- tempfile()  # temp dir for raw data
td_anon <- tempfile() # temp dir for preprocessed data

## simulate data and preprocess it

set.seed(62)
simulate_resp_files(32, path = td_raw, overwrite = TRUE)


## temporary files 
tf1 <- tempfile(fileext = ".html")
tf2 <- tempfile(fileext = ".html")

## run the built-in R Markdown preprocessing script
pp_report <- preprocess_simulated(path = td_raw, outpath = td_anon,
                                  report = tf1)

## run the built-in R Markdown analysis script
## this can take very long due to the CLMM fits
a_report <- reproduce_analysis_sim(path = td_anon,
                                   outfile = tf2,
                                   parallel = FALSE)

browseURL(a_report)

## clean up
file.remove(pp_report)
file.remove(a_report)


## clean up
unlink(td_raw, TRUE, TRUE)
unlink(td_anon, TRUE, TRUE)

truthiness documentation built on May 24, 2021, 9:07 a.m.