The trend()
function provides an overview of linear trends in single case
data. By default, it provides the intercept and slope of a linear and
quadratic regression of measurement time on scores. Models are calculated
separately for each phase and across all phases. For more advanced use, you
can add regression models using the R-specific formula class.
Arguments
- data
A single-case data frame. See
scdf()
to learn about this format.- dvar
Character string with the name of the dependent variable. Defaults to the attributes in the scdf file.
- pvar
Character string with the name of the phase variable. Defaults to the attributes in the scdf file.
- mvar
Character string with the name of the measurement time variable. Defaults to the attributes in the scdf file.
- offset
(Deprecated. Please use first_mt). An offset for the first measurement-time of each phase. If
offset = 0
, the phase measurement is handled as MT 1. Default isoffset = -1
, setting the first value of MT to 0.- first_mt
A numeric setting the value for the first measurement-time. Default = 0.
- model
A string or a list of (named) strings each depicting one regression model. This is a formula expression of the standard R class. The parameters of the model are
values
,mt
andphase
.
Value
- trend
A matrix containing the results (Intercept, B and beta) of separate regression models for phase A, phase B, and the whole data.
- offset
Numeric argument from function call (see arguments section).
See also
Other regression functions:
autocorr()
,
corrected_tau()
,
hplm()
,
mplm()
,
plm()
Examples
## Compute the linear and squared regression for a random single-case
design <- design(slope = 0.5)
matthea <- random_scdf(design)
trend(matthea)
#> Trend for each phase
#>
#> Intercept B Beta
#> Linear.ALL 38.979 4.359 0.971
#> Linear.A 52.090 -0.620 -0.578
#> Linear.B 54.536 5.100 0.981
#> Quadratic.ALL 52.497 0.226 0.990
#> Quadratic.A 51.719 -0.145 -0.563
#> Quadratic.B 66.393 0.352 0.983
#>
#> Note. Measurement-times start at 0 for each phase
## Besides the linear and squared regression models compute two custom models:
## a) a cubic model, and b) the values predicted by the natural logarithm of the
## measurement time.
design <- design(slope = 0.3)
ben <- random_scdf(design)
trend(ben, offset = 0, model = c("Cubic" = values ~ I(mt^3), "Log Time" = values ~ log(mt)))
#> Trend for each phase
#>
#> Intercept B Beta
#> Linear.ALL 40.300 2.781 0.909
#> Linear.A 49.455 1.125 0.376
#> Linear.B 46.354 3.588 0.918
#> Quadratic.ALL 50.513 0.132 0.935
#> Quadratic.A 51.488 0.122 0.249
#> Quadratic.B 57.271 0.215 0.906
#> Cubic.ALL 54.820 0.007 0.922
#> Cubic.A 52.304 0.012 0.126
#> Cubic.B 61.600 0.014 0.875
#> Log Time.ALL 32.875 17.302 0.777
#> Log Time.A 49.518 3.458 0.465
#> Log Time.B 39.477 19.128 0.856
#>
#> Note. Measurement-times start at 1 for each phase