makeCrossCorBiVar: Takes typical time-series wide-format data (e.g., multiple...

View source: R/biVar.R

makeCrossCorBiVarR Documentation

Takes typical time-series wide-format data (e.g., multiple time-varying variables for each person in wide format) and calculates cross-correlations for two user-specified variables within a specified maximum number of lags. It returns a dataframe with the largest absolute cross-correlation and its lag added for each person (e.g., it returns either the most negative or most positive cross-correlation, whichever is larger in absolute terms – the sign is retained).

Description

Takes typical time-series wide-format data (e.g., multiple time-varying variables for each person in wide format) and calculates cross-correlations for two user-specified variables within a specified maximum number of lags. It returns a dataframe with the largest absolute cross-correlation and its lag added for each person (e.g., it returns either the most negative or most positive cross-correlation, whichever is larger in absolute terms – the sign is retained).

Usage

makeCrossCorBiVar(basedata, personId, obs1_name, obs2_name, maxLag)

Arguments

basedata

The original dataframe provided by the user that includes at least two time-series variables nested within-person

personId

The name of the column in the dataframe that has the person-level identifier.

obs1_name

The name of the column in the dataframe that has the first time-series variable to be stacked.

obs2_name

The name of the column in the dataframe that has the second time-series variable to be stacked.

time_name

The name of the column in the dataframe that indicates sequential temporal observations.

Value

A cross-sectional version of the original dataframe with maximal absolute-value cross-correlations and their lags added for each person.


ebmtnprof/rties documentation built on Aug. 25, 2022, 7:47 p.m.