Announcement

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

  • Table with correlations per sector (dataset containing observations from different sectors)

    Hello

    I have panel data comprising companies from multiple economic sectors. I am trying to create a table containing correlations between a variable Y and several variables X1 X2 X3 per economic sector (sector). Please note that I am not interested in the correlations among X1,X2,X3. I have looked at the statsby documentation but can't find how to do it. Does anybody know of a command that would do this? Any help would be much appreciated!

    Kind regards,
    Joao

  • #2
    You did not get a quick answer. You will increase your chances of useful answer by following the FAQ on asking questions-provide Stata code in code delimiters, readable Stata output, and sample data using dataex. Knowing precisely how your data set is set up in being able to replicate your problem can be essential to helping you. It also increases the chances that someone will actually code what you need. Note that you are probably best offering a carefully edited set of data that will illustrate your problem.

    While this would not be the efficient way to do it, you certainly can loop over sectors, calculate correlations, write the correlations into variables in your data set, and then do the next sector. But you should be able to do this with statsby. You might need to do stats by four the correlation of Y and X1, than other stats by for Y and X2, etc.

    Comment


    • #3
      I didn't understand this either, but cpcorr from SSC might help: e.g. https://www.statalist.org/forums/for...ween-variables

      Comment

      Working...
      X