Learn R Programming

polycor (version 0.5)

polyserial: Polyserial Correlation

Description

Computes the polyserial correlation between a quantitative variable and an ordinal variables, based on the assumption that the joint distribution of the quantitative variable and a latent continuous variable underlying the ordinal variable is bivariate normal. Either the maximum-likelihood estimator or a quicker ``two-step'' approximation are available. For the ML estimator the estimates of the thresholds and the covariance matrix of the estimates are also available.

Usage

polyserial(x, y, ML = FALSE, control = list(), std.err = FALSE)

Arguments

x
a numerical variable.
y
an ordered categorical variable; can be numeric, a factor, or an ordered factor, but if a factor, its levels should be in proper order.
ML
if TRUE, compute the maximum-likelihood estimate; if FALSE, the default, compute a quicker ``two-step'' approximation.
control
optional arguments to be passed to the optim function, which computes the ML estimate; for ML=TRUE only.
std.err
if TRUE, return the estimated covariance matrix of the correlation and thresholds; used only if ML=TRUE; the default is FALSE.

Value

  • If ML and std.err are both TRUE, returns an object of class "polycor" with the following components:
  • typeset to "polyserial".
  • rhothe polyserial correlation.
  • cutsestimated thresholds for the ordinal variable (y).
  • varthe estimated covariance matrix of the correlation and thresholds.
  • nthe number of observations on which the correlation is based.
  • Othewise, returns the polyserial correlation.

References

Drasgow, F. (1986) Polychoric and polyserial correlations. Pp. 68--74 in S. Kotz and N. Johnson, eds., The Encyclopedia of Statistics, Volume 7. Wiley.

See Also

hetcor, polychor, print.polycor, optim

Examples

Run this code
data <- rmvnorm(1000, c(0, 0), matrix(c(1, .5, .5, 1), 2, 2))
x <- data[,1]
y <- data[,2]
cor(x, y)  # sample correlation
y <- cut(y, c(-Inf, -1, .5, 1.5, Inf))
polyserial(x, y)  # 2-step estimate
polyserial(x, y, ML=TRUE, std.err=TRUE) # ML estimate

Run the code above in your browser using DataLab