Announcement

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

  • median and interquartile range in panel data (graph)

    Hi, It's my first post on Stata forum. I hope this is write place to pose questions about Stata.

    I have panel data and want to make a twoway graph with year on horizontal axis and median of the variable(s) on vertical axis for different interquartile range of some orther variables.
    More specificaly, I want 3 lines. One shows median(investments) when leverage (for example) is lower then 10th percentile. Second line is median(investment) when leverage>leveragep(90) and third is median(investments) when leveragep(40)<leverage<leveragep(60). And I need this for every year. So, the graph has to show how the median of investments behave for different leverage group of firms, through time (as I said, I have panel data).

    Please help

  • #2
    Breaking this down,

    unnamed panel identifier; time (year) identifier

    wanted:

    median of investment when leverage is lower than 10th percentile.

    median of investment when leverage is higher than 90th percentile

    median of investment when leverage is between 40th and 60th percentiles

    for every year.

    With some guess work on what your variables and what you have yet to calculate, it seems that you need

    Code:
    egen l10 = pctile(leverage), by(year) pctile(10)
    egen median10 = median(investment) if leverage < l10, by(year)
    and similar statements for the other calculations. Then it's a line plot.
    Last edited by Nick Cox; 06 Jul 2015, 05:15.

    Comment


    • #3
      The option call pctile(10) should be p(10)

      Comment


      • #4
        Nick,

        Thanks a lot for your reply.

        Comment

        Working...
        X