polycormat {robcat} | R Documentation |
Robust estimation of polychoric correlation matrix
Description
A useful wrapper of polycor
to robustly estimate a polychoric correlation matrix by calculating all unique pairwise polychoric correlation coefficients.
Usage
polycormat(
data,
c = 0.6,
parallel = FALSE,
num_cores = 1L,
return_polycor = TRUE,
variance = TRUE,
constrained = TRUE,
method = ifelse(constrained, "Nelder-Mead", "L-BFGS-B"),
maxcor = 0.999,
tol_thresholds = 0.01
)
Arguments
data |
Data matrix or |
c |
tuning constant that governs robustness; takes values in |
parallel |
Logical. Shall parallelization be used? Default is |
num_cores |
Number of cores to be used, only relevant if |
return_polycor |
Logical. Shall the individual |
variance |
Shall an estimated asymptotic covariance matrix be returned? Default is |
constrained |
Shall strict monotonicity of thresholds be explicitly enforced by linear constraints? |
method |
Numerical optimization method. |
maxcor |
Maximum absolute correlation (to ensure numerical stability). |
tol_thresholds |
Minimum distance between consecutive thresholds (to enforce strict monotonicity); only relevant if |
Value
If return_polycor = TRUE
, returns a list with a polychoric correlation matrix and list of "polycor"
objects. If return_polycor = FALSE
, then only a correlation matrix is returned.
Examples
## example data
set.seed(123)
data <- matrix(sample(c(1,2,3), size = 3*100, replace = TRUE), nrow = 100)
polycormat(data) # robust
polycormat_mle(data) # non-robust MLE