4

I am a newbie, so my question is probably basic. I'm trying to use cor.ci for to obtain polychoric correlations with significance tests. I came across this code but I've been struggling all day to apply it to my data:

library(psych)
poly.example <- cor.ci(sim.poly(nvar = 10,n = 100)$items,n.iter = 10,poly = TRUE)
poly.example
print(corr.test(poly.example$rho), short=FALSE)

My question is, where do I place my variables? I have a total of 13 variables in my dataset and I'd like to produce a correlation matrix for all of them. I'd be grateful if someone could walk me through the process. Thanks!

========

UPDATES:

Following suggestions, I used the code below - which now contains reference to mydata in place of sim.poly - but it did not work:

install.packages("Hmisc")
library(Hmisc)
mydata <- spss.get("S-IAT for R.sav", use.value.labels=TRUE)

install.packages('psych')
library(psych)
poly.example <- cor.ci(mydata(nvar = 10,n = 100)$items,n.iter = 10,poly = TRUE)
poly.example
print(corr.test(poly.example$rho), short=FALSE)

Here is the error message it gives:

library(psych)
poly.example <- cor.ci(mydata(nvar = 10,n = 100)$items,n.iter = 10,poly = TRUE)
Error in cor.ci(mydata(nvar = 10, n = 100)$items, n.iter = 10, poly = TRUE) :
could not find function "mydata"
poly.example
Error: object 'poly.example' not found
print(corr.test(poly.example$rho), short=FALSE) Error in is.data.frame(x) : object 'poly.example' not found

How can I make it recognize mydata and/or select certain variables from my dataset for the analysis? Thanks!

Ali
  • 53
  • 1
  • 5
  • 3
    you should include some sample data so people will be able to help you better. Please proivde a reproducible example as described here: http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example I.e. use `dput()` or create random sample data. – maRtin May 16 '15 at 22:21
  • Thanks Martin. I actually found this code from this link: http://stackoverflow.com/questions/19506180/polychoric-correlation-matrix-with-significance-in-r - I'm asking whether you could suggest how to handle this code and apply it to another dataset. Do I replace something with my variables, for example? – Ali May 16 '15 at 22:53
  • From `?cor.ci`, it appears that the first argument to `cor.ci` is your data. – josliber May 16 '15 at 23:03

0 Answers0