Re: [R] Polychoric Principal Component Analysis (pPCA)

2014-04-10 Thread William R Revelle
Peter,
I am not sure if anyone answered your question about doing biplots using 
polychoric output and PCA.

The biplot.psych  example # 3 shows how to do this

library(psych)
 responses - table2df(bock.table[,2:6],count=bock.table[,7],
 labs= paste (lsat6.,1:5,sep=”))

 W - polychoric(responses, smooth=TRUE,global=TRUE,polycor=F, 
 ML = FALSE,  std.err=FALSE,progress=TRUE) 
#this returns an object with both the correlations and the difficulties

#get the object returned by principal  (see biplot.psych  example 3)

p3 - principal(r = W$rho, nfactors = 3, rotate = Promax) # works if you 
actually give it the matrix

p3$scores - factor.scores(responses,p3)   #find the scores from the response 
data set with the p3 pca solution
 biplot.psych(p3)

Bill




On Dec 17, 2013, at 2:18 PM, Peter Maclean pmaclean2...@yahoo.com wrote:

 I have data set with binary responses. I would like to
 conduct polychoric principal component analysis (pPCA). I know there are 
 several packages used in PCA but I could not find one that directly estimate 
 pPCA and graph the individuals and variables maps. I will appreciate any help 
 that expand these reproducible scripts.
 #How to conduct polychoric principal component analysis pPCA using 
 #either of these packages
 library(psych) 
 library(FactoMineR)
 library(nsprcomp)
 
 #Bock and Liberman (1970) data set of 1000 observations of the LSAT
 #from psych
 
 data(bock)
 responses - table2df(bock.table[,2:6],count=bock.table[,7],
 labs= paste (lsat6.,1:5,sep=))
 fix(responses) 
 describe(responses)
 #Estimate the polychoric correlation matrix to be used in 
 #PCA using psych 
 W - polychoric(responses, smooth=TRUE,global=TRUE,polycor=F, 
 ML = FALSE,  std.err=FALSE,progress=TRUE) 
 #Regular PCA using stat, psych and FactoMiner, respectively
 #There is no option for including the matrix
 princomp(responses, cor=TRUE) #What kind of correlation is used here?
  
 principal(r = responses, nfactors = 3, rotate = Promax)
 principal(r = W, nfactors = 3, rotate = Promax) #Do not work
 
 PCA(responses, scale.unit=TRUE, ncp=3, graph=T) 
 #How to conduct polychoric principal component analysis using either of #the 
 above package and producing individual and variable factor maps as #above
 
 Peter Maclean
 Department of Economics
 UDSM
 
 __
 R-help@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 Revellehttp://personality-project.org/revelle.html
Professor  http://personality-project.org
Department of Psychology   http://www.wcas.northwestern.edu/psych/
Northwestern Universityhttp://www.northwestern.edu/
Use R for psychology http://personality-project.org/r
It is 5 minutes to midnighthttp://www.thebulletin.org

__
R-help@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.


Re: [R] Polychoric Principal Component Analysis (pPCA)

2013-12-17 Thread Peter Maclean
I have data set with binary responses. I would like to
conduct polychoric principal component analysis (pPCA). I know there are 
several packages used in PCA but I could not find one that directly estimate 
pPCA and graph the individuals and variables maps. I will appreciate any help 
that expand these reproducible scripts.
#How to conduct polychoric principal component analysis pPCA using 
#either of these packages
library(psych) 
library(FactoMineR)
library(nsprcomp)

#Bock and Liberman (1970) data set of 1000 observations of the LSAT
#from psych

data(bock)
responses - table2df(bock.table[,2:6],count=bock.table[,7],
    labs= paste (lsat6.,1:5,sep=))
fix(responses) 
describe(responses)
#Estimate the polychoric correlation matrix to be used in 
#PCA using psych 
W - polychoric(responses, smooth=TRUE,global=TRUE,polycor=F, 
    ML = FALSE,  std.err=FALSE,progress=TRUE) 
#Regular PCA using stat, psych and FactoMiner, respectively
#There is no option for including the matrix
princomp(responses, cor=TRUE) #What kind of correlation is used here?
 
principal(r = responses, nfactors = 3, rotate = Promax)
principal(r = W, nfactors = 3, rotate = Promax) #Do not work

PCA(responses, scale.unit=TRUE, ncp=3, graph=T) 
#How to conduct polychoric principal component analysis using either of #the 
above package and producing individual and variable factor maps as #above

Peter Maclean
Department of Economics
UDSM

__
R-help@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.