transform_cues: Transform and untransform cues by applying or undoing PCA,...

View source: R/basics.R

transform_cuesR Documentation

Transform and untransform cues by applying or undoing PCA, centering, and/or scaling.

Description

If the 'transform.parameters' argument is specified, the transforms in that object will be applied. This can be useful when the goal is to transform one data set (e.g., test data) based on the statistics of the another data set (e.g., exposure data). If no 'transform.parameters' are specified, then the transformations specified by the 'center', 'scale', and 'pca' flags will be applied. The transform and untransform functions can also return functions that perform their actions for the specific cues. This can be helpful if one wants to store those functions. For example, the transform function can return both the transform and untransform functions necessary to perform the specified centering, scaling, and/or pca and to undo those transformations.

Usage

transform_cues(
  data,
  cues,
  center = if (pca) T else F,
  scale = F,
  pca = F,
  attach = T,
  transform.parameters = NULL,
  return.transformed.data = T,
  return.transform.parameters = F,
  return.transform.function = F,
  return.untransform.function = F
)

untransform_cues(
  data,
  cues,
  uncenter = NULL,
  unscale = NULL,
  unpca = NULL,
  attach = T,
  transform.parameters = NULL,
  return.untransformed.data = T,
  return.untransform.function = F
)

Arguments

data

'tibble' or 'data.frame'.

cues

Vector of characters with names of cue variables.

center, uncenter

Should the data be (un)centered? (default: 'TRUE' unless 'pca = TRUE')

scale, unscale

Should the data be (un)standardized? (default: 'TRUE' unless 'pca = TRUE')

pca, unpca

Should the data be transformed into/back from orthogonal principal components? If 'TRUE' then center and scale are default to 'FALSE'. If PCA is applied, it is applied after centering and/or scaling. (default: 'FALSE')

attach

Should the transformed cues be attached to data or should just the transformed cues be returned? (default: 'TRUE')

transform.parameters

List of transforms (default: 'NULL')

return.transformed.data, return.transformed.data

Should the (un)transformed data be returned? (default: 'TRUE')

return.transform.parameters

Should the list of transforms be returned? (default: 'FALSE')

return.transform.function, return.untransform.function

Should a function that applies the (un)transform be returned? (default: 'FALSE')

Value

By default a data.frame. If 'return.transform.parameters = TRUE', a list of parameters. If 'return.transform.function = TRUE' or 'return.untransform.function = TRUE' a function. If more than one of these flags is 'TRUE' then a list in which the data element has name "data", the transform parameters have name "transform.parameters" and the (un)transform function(s) have the name "(un)transform.function".


hlplab/MVBeliefUpdatr documentation built on March 29, 2025, 10:42 p.m.