Announcement

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

  • Generating a table for correlations obtained by group

    Hello,

    I would like to generate the correlations between two dependent variables for a large set of countries, using the following command:

    Code:
    bysort country: correl  value_added_exports gross_exports
    I simply want to describe the data for now and later see if there are any difference in using either of these trade statistics. I am looking for a command to put all the corresponding correlations by country into a table. I was considering a loop but could not figure anything useful out, yet.

    Kind regards,

    Moritz.

  • #2
    egenmore from SSC carries a function correlate(). So you could get a table something like this:


    Code:
    sysuse auto , clear
    
    * omit next command if already installed
    ssc install egenmore
    
    bysort rep78 : egen corr = corr(mpg weight)
    tabdisp rep78 if rep78 < . , c(corr) format(%04.3f)

    Comment

    Working...
    X