[R] Help with polychoric correlation in psych library

William Revelle lists at revelle.net
Tue Jun 3 02:29:54 CEST 2014


Simon,
As is usually the case with problems with a package, if you write the author/maintainer, you are more likely to get an answer.

In this case, I just happened to be readiing R-help (t is the end of the term and I am relaxing).

I am happy to look at this if you would send me the data set.

What version of the psych package are you using?



Bill

On Jun 2, 2014, at 3:49 PM, Simon Kiss <sjkiss at gmail.com> wrote:

> 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
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 

William Revelle		           http://personality-project.org/revelle.html
Professor			           http://personality-project.org
Department of Psychology   http://www.wcas.northwestern.edu/psych/
Northwestern University	   http://www.northwestern.edu/
Use R for psychology             http://personality-project.org/r
It is 5 minutes to midnight	   http://www.thebulletin.org



More information about the R-help mailing list