View source: R/transformations.R
transform_matrix | R Documentation |
Function to transform each column of matrix using final FP powers or acd
transform_matrix(
x,
power_list,
center,
acdx,
keep_x_order = FALSE,
acd_parameter_list = NULL,
check_binary = TRUE
)
x |
a matrix with all continuous variables shifted and scaled. |
power_list |
a named list of FP powers to be applied to the columns of
|
center |
a named logical vector specifying whether the columns in |
acdx |
a named logical vector specifying the use of acd transformation. |
keep_x_order |
a logical indicating whether the order of columns
should be kept as in the input matrix |
acd_parameter_list |
a named list. Only required when transformation
are to be applied to new data. Entries must correspond to the entries where
|
check_binary |
passed to |
For details on the transformations see transform_vector_fp()
and
transform_vector_acd()
.
If all elements of power_list
are NA
then this function returns NULL
.
Otherwise a list with three entries: the first x_transformed
is a matrix
with transformed variables as named in power_list
.
The number of columns may possibly be different to the
input matrix due to higher order FP transformations.
The second entry centers
stores the values used to center the variables if
for any variable center = TRUE
(note that usually all variables are
centered, or none of them).
The third entry acd_parameter
stores a named list of estimated
acd_parameters
. May be empty if no ACD transformation is applied.
Generally the original variable names are suffixed with ".i", where
i enumerates the powers for a given variable in power_list
. If a term
uses an acd transformation, then the variable is prefixed with A_
.
x = matrix(1:100, nrow = 10)
colnames(x) = paste0("x", 1:ncol(x))
powx = setNames(replicate(ncol(x), c(1,2), simplify = FALSE), colnames(x))
center = setNames(rep(FALSE, ncol(x)), colnames(x))
acdx = setNames(rep(FALSE, ncol(x)), colnames(x))
transform_matrix(x, powx, center, acdx)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.