Announcement

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

  • Specifying a Correlation

    Say I'd like to simulate academic data
    Code:
    clear *
    
    set seed 1066
    cls
    
    matrix input mCorr = (1, .3, .4\  .3, 1, 0, \  .4, 1, 1)
    corr2data gpa gre final, n(2500)  means(3.5 150 80) sds(.15 4 2) corr(mCorr)
    
    corr
    I want there to be a correlation between GRE test scores (GRE) ones gpa, and their final grade, with GRE being between 130 and 165 and GPA being between 2 and 4.5, and final being between 0 and 100. How might I specify, say, a correlation between these three variables? I know it has something to do with this matrix command above... at present, Stata returns
    Code:
    . corr2data gpa gre final, n(2500)  means(3.5 150 80) sds(.15 4 2) corr(mCorr)
    corr(mCorr) is not symmetric
    How might I solve this? I've always wondered how we can perfectly (almost) specify a relationship between a set of variables, since this would come in handy in a simulation setting. I figured the easiest setting would be to use an academic example where the variables are pretty sensible to consider (i.e., better tests = better grades).

  • #2
    You made an error in specifying the contents of matrix mCorr. A correlation matrix must be symmetric. But you have mCorr[2,3] = 0 and mCorr[3,2] = 1.

    Personally, I doubt that either 0 or 1 is a realistic estimate of the correlation between gre and final (whatever final is), but in any case you have to pick something and use it consistently.

    For example:
    Code:
    . matrix input mCorr = (1, .3, .4\  .3, 1, 0 \  .4, 0, 1)
    
    .
    . corr2data gpa gre final, n(2500)  means(3.5 150 80) sds(.15 4 2) corr(mCorr)
    (obs 2,500)
    
    .
    . corr gpa gre final
    (obs=2,500)
    
                 |      gpa      gre    final
    -------------+---------------------------
             gpa |   1.0000
             gre |   0.3000   1.0000
           final |   0.4000   0.0000   1.0000

    Comment

    Working...
    X