Skip to contents

The autocorr function calculates autocorrelations within each phase and across all phases.

Usage

autocorr(data, dvar, pvar, mvar, lag_max = 3, lag.max, ...)

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.

lag_max, lag.max

The lag up to which autocorrelations will be computed.

...

Further arguments passed to the acf() function

Value

A data frame containing separate autocorrelations for each phase and for all phases (for each single-case). If lag_max exceeds the length of a phase minus one, NA is returned for this cell.

See also

acf()

Other regression functions: corrected_tau(), hplm(), mplm(), plm(), trend()

Author

Juergen Wilbert

Examples

## Compute autocorrelations for a list of four single-cases up to lag 2.
autocorr(Huber2014, lag_max = 2)
#> Autocorrelations
#> 
#> Adam 
#>  Phase Lag 1 Lag 2
#>      A  0.18 -0.40
#>      B  0.00 -0.16
#>    all  0.26 -0.02
#> 
#> Berta 
#>  Phase Lag 1 Lag 2
#>      A  0.08 -0.52
#>      B  0.07 -0.36
#>    all  0.30 -0.01
#> 
#> Christian 
#>  Phase Lag 1 Lag 2
#>      A -0.07 -0.24
#>      B  0.53  0.40
#>    all  0.64  0.55
#> 
#> David 
#>  Phase Lag 1 Lag 2
#>      A -0.40 -0.25
#>      B  0.27  0.35
#>    all  0.45  0.47
#>