Announcement

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

  • Help in dealing with messy longitudinal line graph

    Greetings,

    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]
    which produces a graph that looks like this:

    Click image for larger version

Name:	time_gss_spk.jpeg
Views:	2
Size:	758.4 KB
ID:	1485202

    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!
    Attached Files

  • #2
    The results are what you asked by insisting on so many parameters to be fitted. Smoothing would just make the results into something quite different. It can't help anyone understand what your model is doing.

    Comment


    • #3
      Hey Nick,

      I see what you saying. To simplify things, I display only 2 age categories in the graph below
      Click image for larger version

Name:	39F7CEC4-F743-4B0B-B3CC-4E1E1E2F95CF.jpg
Views:	2
Size:	773.0 KB
ID:	1485256

      There's a negative trend I'm trying to highlight for AGE_CAT1=1. It's noisy, though. Is smoothing appropriate here? And, if so, how do I determine what bandwidth to use?

      Thanks!
      Attached Files

      Comment


      • #4
        As I understand it, you're showing predictions for groups of respondents. As in #2 I have no idea why you think smoothing those predictions will help. What you might do is plot the original data by age categories and ponder smooth summaries of those original data.

        The substance is pertinent here too. Is your response likely to fluctuate substantially from year to year or is a smoother long-term pattern expected. That substance surely should guide your exploratory data analysis and modelling.

        Comment

        Working...
        X