Hi everyone,
I have a panel data set which looks approximately like this:
For every person, I have data on 100 periods, with a variable saying whether they committed a crime in that period, and what their income was in that period.
I would like to plot a graph where I show for the average income of all offenders on t-2, t-1, t=0 (when crime = 1), t+1 and t+2. So basically, I want to show the average income of offenders two periods before and two periods after committing the crime.
It should look something like this:

where the line is at t=0 (where crime = 1), in this case one can see average income from t-8 until t+8.
I have no idea how to get to such a graph, so it would be great if someone could help me out!
I have a panel data set which looks approximately like this:
id | time | crime | income |
1 | 1 | 0 | 2000 |
1 | 2 | 0 | 1800 |
1 | 3 | 1 | 1000 |
1 | 4 | 0 | 1200 |
1 | 5 | 0 | 1400 |
2 | 1 | 0 | 1500 |
2 | 2 | 1 | 1100 |
2 | 3 | 1 | 1400 |
2 | 4 | 0 | 1700 |
2 | 5 | 0 | 2000 |
I would like to plot a graph where I show for the average income of all offenders on t-2, t-1, t=0 (when crime = 1), t+1 and t+2. So basically, I want to show the average income of offenders two periods before and two periods after committing the crime.
It should look something like this:
where the line is at t=0 (where crime = 1), in this case one can see average income from t-8 until t+8.
I have no idea how to get to such a graph, so it would be great if someone could help me out!

Comment