change_cor_mat: Draw a changed correlation matrix

Description Usage Arguments Value

View source: R/change_handlers.R

Description

Changes an input correlation matrix in the way specified by a vector indicating which dimensions are affected and functions that draws changes to the standard deviations and correlations separately. If the correlations should be changed (draw_cor != NULL), all combinations of the indices in affected_dims have their correlations changed.

Usage

1
2
change_cor_mat(cor_mat, affected_dims, do_nearPD = TRUE,
  draw_cor = NULL, draw_sd = NULL)

Arguments

cor_mat

A correlation matrix to be changed.

affected_dims

A vector specifying which dimensions should be changed.

do_nearPD

A logical indicating whether the Matrix::nearPD function should be run on the changed correlation matrix to find the closest positve definite matrix to it. Highly recommended, as the changes in correlation are not guaranteed to result in a valid correlation matrix.

draw_cor

A function to draw n (any natural number) changes in correlation from.

draw_sd

A function to draw n (any natural number) changes in standard deviation from.

Value

A changed correlation matrix, guaranteed to be positive definite if do_nearPD = TRUE.


Tveten/tpca documentation built on June 10, 2021, 8:43 p.m.