transform_comp: Transform compositional variables to ilr (pivot), alr or clr...

View source: R/transform_comp.R

transform_compR Documentation

Transform compositional variables to ilr (pivot), alr or clr coordinates

Description

Takes a dataset with a set of labelled compositional columns and returns a dataset with transformed variables added. The current behaviour also returns compositional columns rescaled to be on the unitless scale, and with zeroes imputed if rounded_zeroes is TRUE.

Usage

transform_comp(
  data,
  comp_labels,
  transformation_type = "ilr",
  rounded_zeroes = TRUE,
  det_limit = NULL,
  comparison_part = NULL,
  part_1 = NULL
)

Arguments

data

Dataset to have the transformation applied to.

comp_labels

The labels of the compositional columns.

transformation_type

The type of transformation desired. Should be "ilr", "alr" or "clr".

rounded_zeroes

Are zeroes rounded zeroes?

det_limit

Detection limit if zeroes are to be imputed. This is needed when rounded_zeroes is TRUE. It should be the minimum measurable value in the compositional columns of data, and should be on the same scale as the (input) compositional columns. If rounded_zeroes is TRUE and there are zero values in the data, it throws an error. If the compositional columns do not have a constant sum, it also throws an error, as it cannot be automatically rescaled. Embedded zero imputation is for convenience only. It may be advisable to perform zero imputation prior to working with the data, particularly in more complex cases.

comparison_part

Only needed for alr transformation. Should be an element of comp_labels. Name of part that all other parts will be compared to.

part_1

Used with ilr-pivot coordinate transformation to specify which should be first part. Passed to alter_order_comp_labels unless NULL.

Value

data with transformed compositional columns.

Examples

transform_comp(data = simdata,
comp_labels = c("vigorous", "moderate", "light", "sedentary", "sleep"),
transformation_type = "ilr",
det_limit = 0.00119)


OxWearables/epicoda documentation built on Dec. 7, 2022, 9:07 p.m.