Announcement

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

  • Simulating multivariate ordinal data

    This is a request to ask if there are any packages that implement an algorithm to simulate multivariate ordinal data with a specific rank (Spearman) correlation matrix? A cursory search didn't find anything.

    The algorithm is described in Wicklin's book [1], but attributes the algorithms to [2,3].

    If there is no such code then I will consider implementing it myself.

    [1] Wicklin, R. (2013), Simulating Data with SAS, Cary, NC: SAS Institute Inc.

    [2] Kaiser, S., Träger, D., and Leisch, F. (2011), Generating Correlated Ordinal Random Values, Technical report, University of Munich, Department of Statistics. URL http://epub.ub.uni-muenchen.de/12157/

    [3] Demirtas, H. (2006), “A Method for Multivariate Ordinal Data Generation Given Marginal Distributions and Correlations,” Journal of Statistical Computation and Simulation, 76, 1017–1025.

  • #2
    this might do it.

    Code:
    clear
    
    matrix C = (1 , 0.5 \ 0.5 , 1)
    corr2data x1 x2 , corr(C) n(1000)
    xtile x1c = x1 , n(5)
    xtile x2c = x2 , n(3)
    
    corr x1 x2
    polychoric x1c x2c

    Comment


    • #3
      Thank you, George. I'm not familiar with polychoric correlation. It seems to be targeting an estimator of the Pearson correlation? I don't think this will work for my needs though, as I'm trying to generate ordinal variables with arbitrary distributions to follow a specified Spearman correlation distribution.

      Comment


      • #4
        maybe this then. seems to work with some different distributions, mainly because I'm converting to ranks (an order).

        Code:
        clear
        set obs 1000
        *g x1 = rnormal()
        *g x2 = rnormal()
        g x1 = rpoisson(10)
        g x2 = rpoisson(5)
        egen r1 = rank(x1)
        egen r2 = rank(x2)
        mkmat r1 r2 , mat(R) 
        matrix C = (1 , 0.5 \ 0.5 , 1)
        matrix Z = cholesky(C)
        matrix y = R*Z'
        svmat y
        correl r1 r2
        correl y1 y2

        Comment


        • #5
          Polychoric provides a correlation for categorical data (I was thinking categorical, not ordered as you indicated). Tetrachoric gets you the correlation between dummies.

          Comment

          Working...
          X