6  Setting variables for analysis

In an scdf, it is specified which variables represent the measurement time, phase, and dependent variable. If multiple measurement times, phases, or dependent variables are present, they can be switched using helper functions. The function set_dvar changes the dependent variable, set_mvar modifies the measurement-time variable, and set_pvar adjusts the phase variable. The function set_vars serves as a redundant option to set multiple variables at once.

The set_dvar function call

set_dvar(data, dvar)

The set_mvar function call

set_mvar(data, mvar)

The set_pvar function call

set_pvar(data, pvar)

The set_vars function call

set_vars(data, dvar, mvar, pvar)

Assume we have a single-case study and smooth the dependent variable:

scdf <- Huber2014$Berta |> 
  transform(compliance_smooth = local_regression(compliance))

Now we change the dependent variable to compliance_smooth for an analysis:

scdf |> 
  set_dvar("compliance_smooth") |> 
  smd()
Standardized mean differences

                            Berta
mA                          36.97
mB                          18.23
sdA                          8.04
sdB                         10.77
sd cohen                     9.50
sd hedges                    9.94
Glass' delta                -2.33
Hedges' g                   -1.89
Hedges' g correction        -1.83
Hedges' g durlak correction -1.77
Cohen's d                   -1.97


The following variables were used in this analysis:
'compliance_smooth' as dependent variable, 'phase' as phase variable, and 'mt' as measurement-time variable.

If you want to change the variables permanently, replace an scdf with its changed version:

scdf <- set_dvar(scdf, "compliance_smooth")