Announcement

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

  • Generate a mean that varies over time

    Hello!
    I have data from a Survey since 1976.
    What I am trying to do is get to see how education for different race groups evolved over Time
    Educ is a continuous variable
    So I try to generate mean education and see how this evolved over time for different race group.
    However when I do the following code I get the attached file

    egen meaneduc=mean(educ)

    . graph twoway line mean educ, by(race)

    . graph twoway line meaneduc year, by(race)


    Meaning, it calculated the average mean over the given period of time, but what I want to see is how the average education level for each year evolved by race ? how can I do it???
    Attached Files

  • #2
    It's hard to follow what you did.

    Look at your syntax and your results.

    Your mean variable

    Code:
    egen meaneduc=mean(educ)
    contains only the mean over all observations. That's a constant.

    Asking for separate graphs by race and year should not produce a variation on showing the same constant again and again.

    Comment


    • #3
      You could perform a regression analysis, then get the margins and marginsplot.
      Best regards,

      Marcos

      Comment


      • #4
        Originally posted by Nick Cox View Post
        It's hard to follow what you did.

        Look at your syntax and your results.

        Your mean variable

        Code:
        egen meaneduc=mean(educ)
        contains only the mean over all observations. That's a constant.

        Asking for separate graphs by race and year should not produce a variation on showing the same constant again and again.
        Sorry im new to STATA, how do I see the evolution of the mean over time for different race?

        Comment


        • #5
          Originally posted by Marcos Almeida View Post
          You could perform a regression analysis, then get the margins and marginsplot.
          But if I do
          reg wage white
          for e.g.
          this would only give me how average wage for white compares to average white for non white
          But how do I see the evolution over time ?
          because if I do
          reg wage white year
          then year is simply the year in numerical number so effectively it gives me the impact of an additional year in wages but how do I move from that to the evolution of wage across year for white people?

          Comment


          • #6
            Being new to Stata is precisely why you should read and act on the FAQ Advice and present a consistent question. No data example here, but my guess is that you should try

            Code:
            egen wanted = mean(educ), by(race year)
            line wanted year, by(race) sort

            Comment

            Working...
            X