get_affine_transform: Get affine transformation

get_affine_transformR Documentation

Get affine transformation

Description

Get affine transformation for a set of 'cues' in 'data'. Returns a linear transformation of form 'f(x) = SCALE * (x + shift)', the inverse of that transformation, and all relevant transformation parameters. The transformation function and its inverse take data sets as input, and return a new 'data.frame' with only the (inverse) transformed 'cue' columns. The transformation parameters can be helpful when one wants to apply the affine transform to transform, for instance, covariance matrices.

Usage

get_affine_transform(
  data,
  cues,
  type = c("identity", "center", "scale", "PCA whiten", "ZCA whiten")[1]
)

Arguments

data

A 'tibble' or 'data.frame'.

cues

A character vector of column names in 'data' that should be transformed.

type

The type of transformation to apply. Can be one of "identity", "center", "standardize", "PCA whiten", or "ZCA whiten". Except for the identity transform, all transforms center. Standardize additionally divides by the standard deviations. PCA whitening rotates the data into the space of the principal components, followed by scaling along each principal axis to achieve unit variance. ZCA whitening also achieves unit variance along all dimensions, and—like PCA whitening—decorrelates the data but it aims to maintain the original orientation of the data as close as possible. If 'cue' is a single cue, whitening reduces to standardization. (default : "identity")

return

Value

A list with the following elements: * 'type': A character vector of length 1, containing the type of transformation. * 'transform.parameters': A list with the following elements: * 'cue.labels': A character vector of cue labels for ease of recovery. * 'shift' is a vector of 'length(cues)' * 'SCALE' is a 'length(cues)' x 'length(cues)' invertible square matrix. For types "identity" and "center", this is an identity matrix. For type "standardize", it is the identity matrix multiplied by the inverse of the vector of standard deviations of the cues. * 'INV_SCALE' is the inverse of the 'SCALE' matrix. * 'transform.function': A function f(data, return_type). The function applies the affine transformation to the columns of 'data' specified in 'cues'. The 'return_type' argument determines what is returned. Can be one of "replace", "add", or "cues only". If "replace", the input data will be returned in full but with the cue columns replaced by the transformed cues. If "add", the input data will be returned with additional columns for the cues (labeled "*_transformed"). If "cues only", a new data frame with only the transformed cues will be returned. (default: "replace") * 'untransform.function': Same as the 'transform.function' but return the inverse transformed data.


hlplab/MVBeliefUpdatr documentation built on July 5, 2025, 6:42 a.m.