I have a problem regarding how to graph two scatter plots and their fitted lines with longitudinal data. Morover, I have the id (xwaveid), the year (wave), whether they receive salary/wages of not (wschave==1), whether they are in the control or treatment group (incontrolgroup==1 or intreatmentgroup==1) and their annual gross income. My data is as below.
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input long xwaveid float wave byte wschave float(incontrolgroup intreatmentgroup annualgrossincome) 100018 2006 1 1 0 24232 100018 2007 1 1 0 22412 100018 2008 1 1 0 12220 100018 2009 1 1 0 8840 100018 2010 1 1 0 14820 100018 2011 1 1 0 18564 100018 2012 1 1 0 14560 100018 2013 1 1 0 17420 100018 2014 1 1 0 19500 100019 2006 1 1 0 119600 100019 2007 1 1 0 72800 100019 2008 1 1 0 119600 100019 2009 1 1 0 104000 100019 2010 1 1 0 140400 100019 2011 1 1 0 72800 100019 2012 1 1 0 135200 100019 2013 1 1 0 140920 100019 2014 1 1 0 156000 100100 2006 1 0 1 53820 100100 2007 1 0 1 65962 100100 2008 1 0 1 55042 100100 2009 1 0 1 65000 100100 2010 1 0 1 59020 100100 2011 1 0 1 62400 100100 2012 1 0 1 80600 100100 2013 1 0 1 78000 100100 2014 1 0 1 80600 100107 2006 1 1 0 50700 100107 2007 1 1 0 46800 100107 2008 1 1 0 47840 100107 2009 1 1 0 52000 100107 2010 1 1 0 . 100107 2011 1 1 0 50752 100107 2012 1 1 0 50778 100107 2013 1 1 0 55328 100107 2014 1 1 0 70200 100138 2006 1 0 1 36322 100138 2007 1 0 1 39000 100138 2008 2 0 1 . 100138 2009 1 0 1 38428 100138 2010 1 0 1 34580 100138 2011 1 0 1 38584 100138 2012 1 0 1 56472 100138 2013 1 0 1 53924 100138 2014 1 0 1 57200 100140 2006 1 1 0 28600 100140 2007 1 1 0 52000 100140 2008 1 1 0 31200 100140 2009 1 1 0 26000 100140 2010 1 1 0 33800 100140 2011 1 1 0 26000 100140 2012 1 1 0 39000 100140 2013 1 1 0 46800 100140 2014 1 1 0 44200 100164 2006 1 0 1 65000 100164 2007 1 0 1 39000 100164 2008 1 0 1 59982 100164 2009 1 0 1 80990 100164 2010 1 0 1 79040 100164 2011 1 0 1 67600 100164 2012 1 0 1 82940 100164 2013 1 0 1 83200 100164 2014 2 0 1 . 100165 2006 1 0 1 53118 100165 2007 1 0 1 41600 100165 2008 1 0 1 54600 100165 2009 1 0 1 64792 100165 2010 1 0 1 52000 100165 2011 1 0 1 75296 100165 2012 1 0 1 70200 100165 2013 1 0 1 72982 100165 2014 2 0 1 . 100185 2006 1 0 1 46800 100185 2007 1 0 1 50544 100185 2008 1 0 1 38220 100185 2009 2 0 1 . 100185 2010 2 0 1 . 100185 2011 1 0 1 45760 100185 2012 1 0 1 34476 100185 2013 2 0 1 . 100185 2014 2 0 1 . 100195 2006 1 0 1 49428 100195 2007 1 0 1 61440 100195 2008 1 0 1 63912 100195 2009 1 0 1 51912 100195 2010 1 0 1 53472 100195 2011 2 0 1 . 100195 2012 1 0 1 38480 100195 2013 1 0 1 44200 100195 2014 1 0 1 39000 100196 2006 1 0 1 52000 100196 2007 1 0 1 67600 100196 2008 1 0 1 72800 100196 2009 1 0 1 62400 100196 2010 1 0 1 65728 100196 2011 1 0 1 65000 100196 2012 1 0 1 83200 100196 2013 1 0 1 93600 100196 2014 1 0 1 95472 100338 2006 1 0 1 36000 end format %ty wave label values wschave FWSCHAVE label def FWSCHAVE 1 "[1] Currently receives wage and salary income", modify label def FWSCHAVE 2 "[2] Does not currently receive wage and salary income", modify
I have tried different combinations based on what I found online. But my graphs look very weird. (since I havent achieved a decent graph yet, I havent inserted a code for the fitted line). For the below code
Code:
twoway (scatter annualgrossincome wave if intreatmentgroup==1 & wschave==1,sort) (scatter annualgrossincome wave if incontrolgroup==1 & wschave==1,sort)
Array
My goal is look at trends in the control and treatment groups trends. I hope to see a similar trend until 2010 which diverges for the treatment group afterwards. But since I cannot create the graph properly I cannot look at the existence of a parallel trend prior 2010. Any help would be very highly appreciated... Thank you very much in advance.
Kind regards.
0 Response to Graphing based on a condition of longitudinal data
Post a Comment