Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Screeplot and Parallel Analysis after Polychoric Correlation Matrix based PCA

    I am using Stata 12. My dataset contains around 50 categorical (ordinal) variables. I am trying to develop a scale. Since my variables are categorical, instead of Person Correlation I was trying to do polychoric correlation based principle components analysis. I typed .polychoric [varnames] and received output of correlation matrix and PCA output with Eigenvalues, proportion explained, etc- which are all fine. But, next I was trying to get screeplot and then do parallel analysis (by using .fapara command; I already downloaded the app). But when I gave the command .screeplot I received the following response:

    screeplot only valid after manova, canon, ca, and estimation commands with
    e(property) eigen
    r(321);

    Then I tried .polychoricpca command, but it also came up with the same response while trying screeplot.

    Then I tried .pcamat r(R), n(sample size) command; which came up with the following response:
    r(R) not positive (semi)definite
    r(506)

    Can anybody help me with the following queries:
    1) What would be correct way of doing PCA with polychoric correlation matrix, i.e. the command?
    2) Is it possible to obtain screeplot after doing the PCA? How?
    3) Is it possible to do parallel analysis? How?
    4) Please also educate me on the factor analysis as I will be doing that next.

    Thanks.

  • #2
    Cross-posted at http://stackoverflow.com/questions/2...trix-based-pca

    Please see comments there before replying. Also, Taufique: please read our policy on cross-posting in the FAQ.

    Comment


    • #3
      As far as I know there is no built in procedure in Stata for Polychoric correlation, for that you may use the user written program polychoric as suggested here​ (which you already installed). Although you can't plot the scree plot directly, but you can find in the output all you need for doing that. Attached below an example for how to plot the results. This will help you with the first two questions.

      Code:
      clear
      sysuse auto
      polychoricpca foreign mpg rep78
      mat eigen= r(eigenvalues)'
      matlist eigen
      clear
      svmat eigen
      gsort -eigen
      g component=_n
      twoway (line eigen1 component, sort), ytitle(Eigenvalues) yline(1, lwidth(medium) lcolor(red)) xtitle(Number of components) title(Scree plot of eigenvalues after pca)

      Comment


      • #4
        Thanks a lot Oded. It was very helpful. Can anyone suggest how to proceed with the factor analysis?

        Comment


        • #5
          Oded gave very good advice, but his code can be simplified. So long as the number of components is not greater than the number of observations, you can put the eigenvalues in a new variable in the same dataset. It's not aligned with the rest of the data, but that need not be a problem.

          I find svmat a bit awkward in its presumptions, for example, that you are extracting columns. An alternative technique is just to use matrix subscripts directly.

          Code:
          clear
          sysuse auto
          polychoricpca foreign mpg rep78
          mat eigen = r(eigenvalues)
          gen eigen = eigen[1,_n]
          g component=_n
          twoway line eigen component in 1/3, xla(1/3) sort ytitle(Eigenvalues) yline(1, lwidth(medium) lcolor(red)) xtitle(Number of components) title(Scree plot of eigenvalues after pca)
          Last edited by Nick Cox; 25 Jan 2015, 08:10.

          Comment


          • #6
            Thanks for the advice Nick. I also do not like the svmat.
            As always your inputs are wise and make the work easier.

            Comment

            Working...
            X