Skip to content

Instantly share code, notes, and snippets.

>med(data=rfe, iv = "SOQsos", dv = "MBASo", mv="REIappear", cv="AGE", reps=1000)
Independent Variable: SOQsos
Dependent Variable: MBASo
Mediator Variable: REIappear
IV (and CVs) on DV
Estimate SE Pr(>|z|) LL UL Beta
(Intercept) 3.69132749 0.199476668 3.154675e-40 3.300353220 4.082301760 NA
SOQsos 0.01914967 0.005112734 2.578910e-04 0.009128709 0.029170628 0.2940897
require(boot)
require(car)
require(MASS)
require(QuantPsyc) # lm.beta() function
#---- Bootstrap Mediation Function ----
boot.med <- function(data, formula.m, formula.y, iv, mv, i) {
data.resamp <- data[i,]
reg.m <- lm(formula.m, data=data.resamp)
>qol.scores <- c(45, 80, 70, 70) # QoL data
>single.case(qol.scores, baseline = 1, level = .05) # Time.1 is baseline
Single-case data analysis
x dx z dz Sig
Time.1 45 Baseline -1.42 Baseline Baseline
Time.2 80 -35 0.92 -2.34 *
Time.3 70 -25 0.25 -1.67 *
Time.4 70 -25 0.25 -1.67 *
# =================================================================
#
# Analysis of repeated single-case data
#
# Mueser, K. T., Yarnold, P. R., & Foy, D. W. (1991).
# Statistical Analysis for Single-Case Designs Evaluating Outcome
# of Imaginal Exposure Treatment of Chronic PTSD.
# Behavior Modification, 15(2), 134-155.
#
# Coded by: Sam Mancuso