# Load data (ensure matrix for missing data example)
wmt <- as.matrix(wmt2[,7:24])
# Compute polychoric correlation matrix
correlations <- polychoric.matrix(wmt)
# Randomly assign missing data
wmt[sample(1:length(wmt), 1000)] <- NA
# Compute polychoric correlation matrix
# with pairwise missing
pairwise_correlations <- polychoric.matrix(
wmt, na.data = "pairwise"
)
# Compute polychoric correlation matrix
# with listwise missing
pairwise_correlations <- polychoric.matrix(
wmt, na.data = "listwise"
)
Run the code above in your browser using DataLab