cor.poly: Polychoric Correlation Matrix

View source: R/cor.poly.R

cor.polyR Documentation

Polychoric Correlation Matrix

Description

This function computes a polychoric correlation matrix, which is the estimated Pearson product-moment correlation matrix between underlying normally distributed latent variables which generate the ordinal scores.

Usage

cor.poly(x, smooth = TRUE, global = TRUE, weight = NULL, correct = 0,
         progress = TRUE, na.rm = TRUE, delete = TRUE,
         tri = c("both", "lower", "upper"), digits = 2, as.na = NULL,
         check = TRUE, output = TRUE)

Arguments

x

a matrix or data frame of discrete values.

smooth

logical: if TRUE and if the polychoric matrix is not positive definite, a simple smoothing algorithm using cor.smooth() function is applied.

global

logical: if TRUE, the global values of the tau parameter is used instead of the local values.

weight

a vector of length of the number of observations that specifies the weights to apply to each case. The NULL case is equivalent of weights of 1 for all cases.

correct

a numeric value indicating the correction value to use to correct for continuity in the case of zero entry. Note that unlike in the polychoric() function in the psych the default value is 0.

progress

logical: if TRUE, the progress bar is shown.

na.rm

logical: if TRUE, missing data are deleted.

delete

logical: if TRUE, cases with no variance are deleted with a warning before proceeding.

tri

a character string indicating which triangular of the matrix to show on the console, i.e., both for upper and lower triangular, lower (default) for the lower triangular, and upper for the upper triangular.

digits

an integer value indicating the number of decimal places to be used for displaying correlation coefficients.

as.na

a numeric vector indicating user-defined missing values, i.e. these values are converted to NA before conducting the analysis.

check

logical: if TRUE, argument specification is checked.

output

logical: if TRUE, output is shown on the console.

Value

Returns an object of class misty.object, which is a list with following entries:

call

function call

type

type of analysis

data

matrix or data frame specified in x

args

specification of function arguments

result

result table

Note

This function is based on the polychoric() function in the psych package by William Revelle.

Author(s)

William Revelle

References

Revelle, W. (2018) psych: Procedures for personality and psychological research. Northwestern University, Evanston, Illinois, USA, https://CRAN.R-project.org/package=psych Version = 1.8.12.

Examples

dat <- data.frame(x1 = c(1, 1, 3, 2, 1, 2, 3, 2, 3, 1),
                  x2 = c(1, 2, 1, 1, 2, 2, 2, 1, 3, 1),
                  x3 = c(1, 3, 2, 3, 3, 1, 3, 2, 1, 2))

# Polychoric correlation matrix
cor.poly(dat)

misty documentation built on Nov. 15, 2023, 1:06 a.m.

Related to cor.poly in misty...