Announcement

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

  • How to export polychoric matrix results

    Hello everyone

    I have now searched far and wide for an answer to this question. I am using polychoric matrices in a paper that I am working on and want to include the results of the matrices in my paper (in a matrix format). I cannot find a way to export the matrices in a way that is easily formatted in a Word or Excel document (or even a text document for that matter).

    Are there any suggestions on how I can do this, please? I usually use the estpost/estout commands when using the normal corr matrices, but it does not seem to work with polychoric correlation matrices.

    Kind regards
    Odile

  • #2
    I've never heard of this, so you're gonna need to show a data example using dataex and show the precise syntax you've tried so far

    Comment


    • #3
      One can assign to a regular Stata matrix the r(R) return matrix that the user-written command -polychoric- creates, and I'd presume that -estout- (which I don't happen to use) would allow export of it in some form like -estout matrix(YourMatrix)-. (Note that -estout- apparently doesn't like working with matrices in the return list, whether it is the r(R) from -polychoric- or the r(C) from -corr-.)

      One could also use -putexcel-:
      Code:
      putexcel set YourOutputFile.xls
      putexcel A1 = matrix(r(R)) //  -putexcel- is ok with a return list reference

      Comment


      • #4
        Thank you so much Mike!

        With putexcel, it comes out without the variable labels, but the correlations are correct.
        With estout(matrix), everything comes out perfectly.

        Thank you so much for your assistance!!

        Kind regards
        Odile

        Comment


        • #5
          Short intro to save the return matrix and exporting it using estout for all non-proficient Stata users like me:
          Code:
          *1. Download dataset
          use https://www.stata-press.com/data/r17/nlsw88.dta
          * 2. Run polychoric command
          polychoric age race married industry occupation union
          * 3. Assign the return matrix from polychoric to a Stata matrix
          matrix correlations = r(R)
          * 4. Use the estout package to export this matrix. The only problem is that the matrix fills every cell, so you will have to manually delete the correlations duplicates.
          estout matrix(correlations)
          Last edited by Felix Kaysers; 29 Nov 2022, 03:27.
          Cheers,
          Felix
          Stata Version: MP 18.0
          OS: Windows 11

          Comment

          Working...
          X