# Categorize data
basic_categorized <- apply(
basic_smallworld, 2, categorize, categories = 5
)
# Compute polychoric correlation matrix
correlations <- polychoric_matrix(basic_categorized)
# Randomly assign missing data
basic_categorized[sample(1:length(basic_categorized), 1000)] <- NA
# Compute polychoric correlation matrix with pairwise missing
pairwise_correlations <- polychoric_matrix(
basic_categorized, na_data = "pairwise"
)
# Compute polychoric correlation matrix with listwise missing
pairwise_correlations <- polychoric_matrix(
basic_categorized, na_data = "listwise"
)
Run the code above in your browser using DataLab