Using R within SPSS to obtain polychoric correlations
Thanks to Jarlath Quinn of SPSS for the syntax below. You need SPSS version 16 or above to use this syntax and follow [attachment:RinSPSS.pdf these guidelines] for using R code in SPSS. You can alternatively run the R code in R. The example data file is [attachment:polydat.sav given here.]
GET
FILE='C:\SE demos\Assess\demo dataset v4.sav'.
DATASET NAME $DataSet WINDOW=FRONT.
begin program r.
library(polycor)
casedata <- spssdata.GetDataFromSPSS(variables=c(9,10,11,12))
satcat<-as.factor(casedata$satcat)
sat <- casedata$sat
perf_2 <- casedata$perf_2
perf_3 <- casedata$perf_3
res <- hetcor(satcat, sat, perf_2, perf_3, ML = FALSE,std.err = FALSE, bins=4)
spsspivottable.Display(res$correlations,
title="Correlation Matrix",
rowdim=" ",
coldim="col",
format=formatSpec.Correlation)
end program.