I'm running Stata 15.1 on OSX. Using data from the general social survey, I'm attempting to graph longitudinal trends in responses to a binary dependent variable (yes/no) by age group.
I run the following syntax:
Code:
regress SPKRAC i.year##i.age_cat4 if white==1 & ideo3==1 [pweight=wtssall]
Array
As you can see, it's a bit of a mess. I'd like to make it (or, more specifically, the trend lines) more presentable. I was doing a little searching around and read up a bit on 'smoothing'. I have no experience in using this feature, though, and (if this is the appropriate route to take) would like a little assistance in determining which procedure to use.
Here is some sample data:
Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input float(age_cat4 SPKRAC) int year
1 . 1972
4 . 1973
1 . 1974
2 . 1975
4 100 1976
4 0 1977
4 . 1978
4 100 1980
3 0 1982
1 . 1983
.n 100 1984
2 100 1985
1 . 1986
2 100 1987
4 . 1988
1 . 1989
4 . 1990
4 100 1991
3 100 1993
2 . 1994
4 0 1996
4 100 1998
1 100 2000
1 100 2002
4 . 2004
4 0 2006
3 . 2008
2 . 2010
1 0 2012
4 100 2014
3 100 2016
4 . 1972
4 . 1973
3 . 1974
1 . 1975
4 100 1976
2 100 1977
4 . 1978
4 100 1980
3 0 1982
4 . 1983
2 100 1984
3 0 1985
4 . 1986
2 100 1987
3 100 1988
3 . 1989
3 . 1990
2 100 1991
3 100 1993
4 . 1994
2 . 1996
1 . 1998
3 0 2000
3 100 2002
3 . 2004
1 . 2006
3 100 2008
1 . 2010
1 100 2012
1 0 2014
4 . 2016
3 . 1972
2 . 1973
4 . 1974
4 . 1975
3 100 1976
4 100 1977
2 . 1978
4 100 1980
1 0 1982
4 . 1983
3 100 1984
1 0 1985
3 . 1986
4 0 1987
4 . 1988
2 0 1989
1 100 1990
2 . 1991
3 100 1993
.n 0 1994
4 100 1996
2 . 1998
4 . 2000
2 . 2002
4 . 2004
4 . 2006
3 . 2008
4 0 2010
3 100 2012
4 100 2014
4 100 2016
1 . 1972
2 . 1973
4 . 1974
1 . 1975
4 100 1976
1 100 1977
4 . 1978
end
format %ty year
Thanks in advance!
0 Response to Help in dealing with messy longitudinal line graph
Post a Comment