Announcement

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

  • graphing a change with xtline

    Hello,

    I have issues with the command to generate a graph which will show a change of my variable over time.
    I have panel data for 10 industries between 2006-2017. I would like to graph a change in their investment in computer hardware: although each industry differs in investment at the base year (2006), I would like to assume that all 10 industries start at 0 change, and then show how their investment expenditure has changed over time.
    What I have done so far is:
    xtset industry time
    gen
    changehardware = (hardware - L1.hardware)/ L1.hardware
    xtlinechangehardware, overlay

    However, this way there is a difference between them even at year 2006. Could someone please help?

  • #2
    The initial value will be missing as you are using the lag operator. You may want something like

    Code:
    bys industry (time): gen changehardware =cond (_n==1, 0, (hardware - L1.hardware)/ L1.hardware)

    Comment

    Working...
    X