Announcement

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

  • Problems with polychoric and ssd set correlations

    Hi:

    I have been succesful in the past using Stas' Kolenikov -polychoric- in combination with code provided by Joseph Coveney some time ago, to use polychoric correlations before -sem- and -factormat- :

    local thevars ..."list of variables goes here"...

    polychoric `thevars'
    mat polychR = r(R)

    forvalues i=1/`: word count `thevars' ' {
    forvalues j=1/`i' {
    local setcor `setcor' `=polychR[`i',`j']'
    }
    if `i' < `: word count `thevars' ' local setcor `setcor' \
    }

    local N = _N
    clear
    ssd init `thevars'
    ssd set obs `N'
    ssd set cor `setcor'

    ..."sem or factormat with options start here..."

    I have been asked to analyze 96 variables and a very complex model, and I get an error when running the last line of the code (ssd set cor `setcor'):

    matrix not positive semidefinite
    One or more numeric values are incorrect because real data can generate only positive semidefinite
    covariance or correlation matrices.

    The dataset has no missing values, and when I previously split the variables in two blocks (because the variables are part of two different questionnaires) I had no problem at all.

    Mystified.

    Marta

  • #2
    Polychoric correlations are pairwise. You're likely to get a nonpositive semidefinite matrix when the correlations are done pairwise, especially if you have more than just a few variables.

    There are a couple of workarounds. I think that the one favored currently is Nick Higham's Nearest Correlation Matrix algorithm, which I programmed awhile back in Stata (actually, I think that it was in Mata) just to see how it worked (it would take another while to locate the file). A similar way (and I think the one used by factormat , forcepsd) is spectral decomposition and nudging up the nonpositive eigenvalues.

    If you're interested in the latter, you might try something like
    Code:
    polychoric . . .
    matrix define Corr = r(R)
    factormat Corr, n(1000) forcepsd
    matrix define Corr = e(C)
    and then proceed from there.

    Comment


    • #3
      Thanks a lot, Joseph!

      I'll try it and see how it works.

      Regards,
      Marta

      Comment


      • #4
        To close the topic: it worked perfectly.

        Many thanks again!!
        Marta

        Comment

        Working...
        X