Announcement

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

  • Graph overlayed by id combined per group

    Hello everyone,

    I have panel data that look like this (this is a subsample, it contains more years, more groups and more id per group)
    Year Group id characteristic value
    2016 A a1 life 2
    2016 A a2 nl 5
    2016 A a3 re 3,5
    2017 A a1 life 3
    2017 A a2 nl 2,5
    2017 A a3 re 4
    2016 B b1 life 1,5
    2016 B b2 life 2
    2016 B b3 re 3,6
    2017 B b1 life 2,5
    2017 B b2 life 3,6
    2017 B b3 re 4
    I want to draw a graph where Y is the value and the X is the year and:
    Each group is represented in a subgraph
    In each group, overlaid plots if characteristic == "life"

    I have tried using xtline, but it does not allow for by(), so I have noway of dividing into subgraphs per group.

    Thank you in advance

  • #2
    Not really sure what you're trying to get here. Does something like this suffice?

    Code:
    separate value, by(characteristic) veryshortlabel
    twoway line value? Year, by(Group) xlabel(2016(1)2017) scheme(s1color) legend(row(1))

    Comment


    • #3
      Thank you Hemanshu Kumar for your response.
      The code you provided gives me a graph with one line for each characteristic. What I need instead is 1 line for each id, conditional on teir characteristic. For example, I want 1 plot per id for ids that have the characteristic life, by (group). As you can see in the data, in group B, I have 2 ids that have the characteristic life so I want 2 lines in the subgraph of group B. i do not necessarily need all characteristics to be used in 1 graph.

      Comment


      • #4
        So then

        Code:
        separate value, by(id) veryshortlabel
        twoway line value? Year if characteristic == "life", by(Group)  xlabel(2016(1)2017) scheme(s1color) legend(row(1))

        Comment

        Working...
        X