makeBiVarData: Takes typical long-format time-nested-in-person data, and...

View source: R/biVar.R

makeBiVarDataR Documentation

Takes typical long-format time-nested-in-person data, and stacks two user-chosen observed variables on top of each other so they can be treated as "bivariate" within person. In other words, two time-series variables from each person are stacked on top of each other, forming a bivariate pair of variables within person (e.g., time in variable in person).

Description

The resulting data can either: 1) be used with many of the other rties functions (a number of the preparatory functions and plotting will work in this way), but instead of "dyad" being the highest nesting variable, "person" is and should be substituted instead of dyad wherever you would otherwise use dyad, or 2) the data can be reformated again with the "dataPrep" function in rties (see overview_data_prep vignette for information on how to do this), with the resulting data in a format that can be used with any of the other rties functions.

Usage

makeBiVarData(
  basedata,
  personId,
  time_name,
  obs1_name,
  obs2_name,
  labels,
  idConvention
)

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.

time_name

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

obs1_name

The name of the column in the dataframe that has the first time-series variable to be stacked. #' @param obs2_name The name of the column in the dataframe that has the second time-series variable to be stacked.

labels

A string vector with the names of the variables that are being stacked.

idConvention

A value that will be added to the varId of the first variable to get the varId for the second variable. It should be a larger value than the highest personId. This varId will then be used by rties in a way similar to personId when partners are nested in dyads.

Value

A dataframe that contains the original data, plus the following columns: 1) var: the names of the stacked variables (taken from "labels"). 2) obs: the stacked observed variable scores, 3) dist: a zero/one distinguishing variable, and 4) varId: a variable ID that is similar to personId for use with rties. The varId for the first stacked variable is the same as the personId, with the varId for the second stacked variable being personId + idConvention.


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