Readme.md

SCCM - Single-Case Causal Mediation Analysis

Installation

  1. Install the devtools package.
install.packages("devtools")
  1. Install the sccm package.
devtools::install_github("langenberg/sccm")

Example data

  1. First, load some libraries.
library(tidyverse)
library(openxlsx)
library(sccm)
  1. Next, download the example data by Mayhugh et al. (2018) from DRYAD and extract the zip file.

  2. Read the 29th participant from the data.

dat <- read.xlsx("Level1_RandomUpSleep_1365_PlosOne_Mayhugh_etal.xlsx") %>%
    as_tibble() %>%
    filter(Anom_ID == 29) %>%
    select(d_abstained, Stress, Crave)

Example using code

mod <- sccm(
    X = "d_abstained",
    M = "Stress",
    Y = "Crave",
    dat = dat,
    lag = 1,
    permutation = T,
    perm_reps = 1000
)

# get a summary
summary(mod)

# plot a path diagram (DAG)
plot(mod)

# print lavaan summary
print(mod)

# print lavaan model syntax
cat(mod$syntax)

Example using the GUI

  1. Write the data to a .csv file.
write.csv(dat, "sccm.csv", row.names = F)
  1. Start the GUI.
sccm_gui()

References

Mayhugh, R. E., Rejeski, W. J., Petrie, M. R., Laurienti, P. J., & Gauvin, L. (2018). Differing patterns of stress and craving across the day in moderate-heavy alcohol consumers during their typical drinking routine and an imposed period of alcohol abstinence (Z. C. Lin, Ed.). PLOS ONE, 13(4), e0195063. https://doi.org/10.1371/journal.pone.0195063



langenberg/sccm documentation built on Dec. 21, 2021, 8:50 a.m.