[R] Help with polychoric correlation in psych library

Simon Kiss sjkiss at gmail.com
Mon Jun 2 22:49:08 CEST 2014


Hello I have a data.frame of 32 variables, all are ordered factors. str(dat) returns the following
'data.frame':	32 obs. of  43 variables:
 $ q1a: Ord.factor w/ 6 levels "Strongly Disagree"<..: 3 4 2 5 NA NA 5 5 3 5 ...
 $ q1b: Ord.factor w/ 6 levels "Strongly Disagree"<..: 3 NA 4 NA NA NA NA 5 4 4 ...
 $ q1c: Ord.factor w/ 6 levels "Strongly Disagree"<..: NA NA 5 5 NA 4 NA 5 NA 5 ...
 $ q1d: Ord.factor w/ 6 levels "Strongly Disagree"<..: 5 NA 5 NA NA 5 NA 5 NA 4 ...
 $ q1e: Ord.factor w/ 6 levels "Strongly Disagree"<..: 5 NA NA 5 5 NA NA 5 5 NA ...
 $ q1f: Ord.factor w/ 6 levels "Strongly Disagree"<..: 4 5 5 5 5 5 5 4 5 5 ...

I'm trying to come up with a polychoric correlation matrix for these, and so I convert them to numeric values:
'data.frame':	32 obs. of  43 variables:
 $ q1a: num  3 4 2 5 NA NA 5 5 3 5 ...
 $ q1b: num  3 NA 4 NA NA NA NA 5 4 4 ...
 $ q1c: num  NA NA 5 5 NA 4 NA 5 NA 5 ...
 $ q1d: num  5 NA 5 NA NA 5 NA 5 NA 4 ...

and try: 
library(psych)
polychoric(values, na.rm=TRUE), but this returns the following error


The items do not have an equal number of response alternatives, global set to FALSE
Error in poly[1, ] : incorrect number of dimensions
In addition: Warning message:
In mclapply(seq_len(n), do_one, mc.preschedule = mc.preschedule,  :
  all scheduled cores encountered errors in user code

Can anyone provide any guidance?
Thanks, Simon Kiss

*********************************
Simon J. Kiss, PhD
Assistant Professor, Wilfrid Laurier University
73 George Street
Brantford, Ontario, Canada
N3T 2C9
Cell: +1 905 746 7606



More information about the R-help mailing list