In one call, 1) clean single-case design data for treatment reversal and multiple baseline designs, 2) fit a multi-level model using restricted maximum likelihood estimation, and 3) estimate a standardized mean difference effect size.

calc_BCSMD(
  design,
  case,
  phase,
  session,
  outcome,
  cluster = NULL,
  series = NULL,
  center = 0,
  round_session = TRUE,
  treatment_name = NULL,
  FE_base = 0,
  RE_base = 0,
  RE_base_2 = NULL,
  FE_trt = 0,
  RE_trt = NULL,
  RE_trt_2 = NULL,
  corStruct = "AR1",
  varStruct = "hom",
  A = NULL,
  B = NULL,
  D = NULL,
  cover = 95,
  bound = 35,
  symmetric = TRUE,
  summary = TRUE,
  data = NULL,
  ...
)

Arguments

design

Character string to specify whether data comes from a treatment reversal ("TR"), multiple baseline across participants ("MBP"), replicated multiple baseline across behaviors ("RMBB"), or clustered multiple baseline across participants ("CMB").

case

vector of case indicators or name of a character or factor vector within data indicating unique cases.

phase

vector of treatment indicators or name of a character or factor vector within data indicating unique treatment phases.

session

vector of measurement occasions or name of numeric vector within data of measurement times.

outcome

vector of outcome data or name of numeric vector of outcome data within data.

cluster

(Optional) vector of cluster indicators or name of a character or factor vector within data indicating clusters.

series

(Optional) vector of series indicators or name of a character or factor vector within data indicating series.

center

Numeric value for the centering value for session. Default is 0.

round_session

Logical indicating whether to round session to the nearest integer. Defaults to TRUE.

treatment_name

(Optional) character string corresponding to the name of the treatment phase.

FE_base

Vector of integers specifying which fixed effect terms to include in the baseline phase. Setting FE_base = 0 includes only a level. Setting FE_base = c(0,1) includes a level and a linear time trend.

RE_base

Vector of integers specifying which random effect terms to include in the baseline phase. Setting RE_base = 0 includes only levels (i.e., random intercepts). Setting RE_base = c(0,1) includes random levels and random linear trends.

RE_base_2

Vector of integers specifying which random effect terms to include in the baseline phase for the cluster level in clustered multiple baseline design across participants or for the case level in replicated multiple baseline across behaviors. Setting RE_base_2 = 0 includes only levels (i.e., random intercepts). Setting RE_base_2 = c(0,1) includes random levels and random linear trends.

FE_trt

Vector of integers specifying which fixed effect terms to include in the treatment phase. Setting FE_trt = 0 includes only a change in level. Setting FE_trt = c(0,1) includes a change in level and a treatment-by-linear time trend.

RE_trt

Vector of integers specifying which random effect terms to include in the treatment phase. Setting RE_trt = 0 includes only random changes in level. Setting RE_trt = c(0,1) includes random changes in level and random treatment-by-linear time trends.

RE_trt_2

Vector of integers specifying which random effect terms to include in the treatment phase for the cluster level in clustered multiple baseline design across participants or for the case level in replicated multiple baseline across behaviors. Setting RE_trt_2 = 0 includes only random changes in level. Setting RE_trt_2 = c(0,1) includes random changes in level and random treatment-by-linear time trends.

corStruct

(Optional) character string indicating the correlation structure of session-level errors. Options are "AR1" (default), "MA1", or "IID".

varStruct

(Optional) character string indicating the heteroscedasticity structure of session-level errors. Options are "hom" (default) or "het", which allows for the session-level error variances to differ by phase.

A

The time point immediately before the start of treatment in the hypothetical between-group design.

B

The time point at which outcomes are measured in the hypothetical between-group design.

D

Numerical indicating the treatment duration across cases. Note that B = A + D and it is not allowed to specify both B and D.

cover

Confidence level.

bound

Numerical tolerance for non-centrality parameter in qt.

symmetric

If TRUE (the default), use a symmetric confidence interval. If FALSE, use a non-central t approximation to obtain an asymmetric confidence interval.

summary

Logical indicating whether to return a data frame with effect size estimates and other information. If TRUE (default), return a data.frame containing the effect size estimate, standard error, confidence interval, and other information. If FALSE, return a list with effect size estimate, degrees of freedom, and other information.

data

(Optional) dataset to use for analysis. Must be a data.frame.

...

further arguments.

Value

If summary == TRUE, a data frame containing the design-comparable effect size estimate, standard error, confidence interval, and other information. If summary == FALSE, a list containing all elements of a `g_mlm()` object, plus the fitted `lme()` model.

Examples

data(Laski)

# Change-in-levels model with fixed treatment effect
calc_BCSMD(design = "MBP",
           case = case, phase = treatment,
           session = time, outcome = outcome,
           FE_base = 0, RE_base = 0, FE_trt = 0,
           data = Laski)
#>   BC-SMD estimate Std. Error 95% CI (lower) 95% CI (upper) Degrees of freedom
#> 1        1.404887  0.2863249      0.8046221       2.005152            18.5524
#>   Auto-correlation Variance parameter Intra-class correlation
#> 1        0.2527692                 NA               0.5606065
#>   Initial treatment time Follow-up time Converged
#> 1                      4             13       Yes

# Model with linear time trends in baseline and treatment phases,
# random baseline slopes, fixed treatment effects
calc_BCSMD(design = "MBP",
           case = case, phase = treatment,
           session = time, outcome = outcome, center = 4,
           FE_base = c(0,1), RE_base = c(0,1), 
           FE_trt = c(0,1),
           data = Laski)
#> Warning: nlminb problem, convergence error code = 1
#>   message = iteration limit reached without convergence (10)
#>   BC-SMD estimate Std. Error 95% CI (lower) 95% CI (upper) Degrees of freedom
#> 1        1.885295  0.5846749       0.675189         3.0954           22.79118
#>   Auto-correlation Variance parameter Intra-class correlation
#> 1        0.1313209                 NA               0.7188766
#>   Initial treatment time Follow-up time Converged
#> 1                      4             13        No


data(Anglesea)
calc_BCSMD(design = "TR",
           case = case, phase = condition,
           session = session, outcome = outcome,
           treatment_name = "treatment",
           FE_base = 0, RE_base = 0, 
           FE_trt = 0,
           data = Anglesea)
#>   BC-SMD estimate Std. Error 95% CI (lower) 95% CI (upper) Degrees of freedom
#> 1        1.490965  0.9876571      -1.470357       4.452286           3.359203
#>   Auto-correlation Variance parameter Intra-class correlation
#> 1        0.4978687                 NA               0.7260842
#>   Initial treatment time Follow-up time Converged
#> 1                     NA             NA       Yes


data(Thiemann2001)
calc_BCSMD(design = "RMBB",
           case = case, series = series, phase = treatment,
           session = time, outcome = outcome,
           FE_base = 0, RE_base = 0, RE_base_2 = 0, 
           FE_trt = 0,
           data = Thiemann2001)
#>   BC-SMD estimate Std. Error 95% CI (lower) 95% CI (upper) Degrees of freedom
#> 1        1.598701  0.1803463       1.239027       1.958375           70.16912
#>   Auto-correlation Variance parameter    Intra-class correlation
#> 1          0.19949                 NA Level2:0.322  Level3:0.109
#>   Initial treatment time Follow-up time Converged
#> 1                      9             15       Yes


data(Bryant2018)
calc_BCSMD(design = "CMB",
           cluster = group, case = case, phase = treatment,
           session = session, outcome = outcome, center = 49,
           treatment_name = "treatment",
           FE_base = c(0,1), RE_base = 0, RE_base_2 = 0,
           FE_trt = c(0,1), RE_trt = NULL, RE_trt_2 = NULL,
           data = Bryant2018)
#>   BC-SMD estimate Std. Error 95% CI (lower) 95% CI (upper) Degrees of freedom
#> 1       -2.245586  0.5876192      -3.425588      -1.065584           50.45912
#>   Auto-correlation Variance parameter Intra-class correlation
#> 1        0.6305068                 NA  Level2:0.771  Level3:0
#>   Initial treatment time Follow-up time Converged
#> 1                      5             54       Yes