Announcement

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

  • Pick the value Stata omit in fixed-effects regression

    Hey all, happy new year!

    I want to ran a study event regression in the following way:

    Code:
    xtset id years_from_first_birth
    xi: xtreg income_in_2018_prices i.years_from_first_birth i.year i.age if gender == 0, robust
    xi: xtreg income_in_2018_prices i.years_from_first_birth i.year i.age if gender == 1, robust
    Now Stata automatically omitted the variable that was created for years_from_first_birth == 5, but I want it to omit the variable for years_from_first_birth == 0. How can I command Stata to do so?

    BTW - if you know a better way to regress what I did please tell me, I'm sure I used the best way.

    Thank you!

    Fitz

  • #2
    First, get rid of the -xi:- prefixes. -xi- is largely obsolete, having been replaced by factor-variable notation. (Read -help fvvarlist- to learn about this.) While it still has some uses with older commands that do not support factor-variable notation, most of those commands have themselves been superseded by newer commands that encompass the same calculations. So don't totally forget that -xi- exists, but think twice or more before actually using it.

    Code:
    xtreg income_in_2018_prices ib0.years_from_first_birth i.year i.age if gender == 0, robust
    xtreg income_in_2018_prices ib0.years_from_first_birth i.year i.age if gender == 1, robust
    will force Stata to use 0 as the reference level for years from first birth. For year and age, Stata will choose according to its default rule, which will be the lowest value in the estimation sample.

    By the way, I would expect year and age to be colinear with each other and also with years from first birth within id. So the within-person effects of these variables on income cannot be estimated from these data. You are getting estimation of between-person effects only. If that is what you want, that is fine. But just remember that you cannot draw any conclusions from this analysis about what happens to an individual's income as they age and time goes by. You can only draw conclusions about the incomes of people who differ in age or are observed in different years.
    Last edited by Clyde Schechter; 01 Jan 2025, 12:59.

    Comment


    • #3
      Originally posted by Clyde Schechter View Post
      First, get rid of the -xi:- prefixes. -xi- is largely obsolete, having been replaced by factor-variable notation. (Read -help fvvarlist- to learn about this.) While it still has some uses with older commands that do not support factor-variable notation, most of those commands have themselves been superseded by newer commands that encompass the same calculations. So don't totally forget that -xi- exists, but think twice or more before actually using it.

      Code:
      xtreg income_in_2018_prices ib0.years_from_first_birth i.year i.age if gender == 0, robust
      xtreg income_in_2018_prices ib0.years_from_first_birth i.year i.age if gender == 1, robust
      will force Stata to use 0 as the reference level for years from first birth. For year and age, Stata will choose according to its default rule, which will be the lowest value in the estimation sample.

      By the way, I would expect year and age to be colinear with each other and also with years from first birth within id. So the within-person effects of these variables on income cannot be estimated from these data. You are getting estimation of between-person effects only. If that is what you want, that is fine. But just remember that you cannot draw any conclusions from this analysis about what happens to an individual's income as they age and time goes by. You can only draw conclusions about the incomes of people who differ in age or are observed in different years.
      Hi Clyde, first of all - thank you.

      When I tried to run just:
      Code:
       xtreg income_in_2018_prices i.years_from_first_birth i.year i.age if gender == 0, robust
      I got an error message from Stata that told me that it can't handle with negative values and the only way I could fix it was by
      Code:
      xi:
      .
      I also tried
      Code:
      ib
      and it didn't work as well, Stata thought it was part of the variable name.

      I'm sorry I don't quate the errors or bring screen prints of them, but I'm not next to the computer that this data is on it.

      Thank you again,

      Fitz

      Comment


      • #4
        Originally posted by FitzGerald Blindman View Post

        Hi Clyde, first of all - thank you.

        When I tried to run just:
        Code:
         xtreg income_in_2018_prices i.years_from_first_birth i.year i.age if gender == 0, robust
        I got an error message from Stata that told me that it can't handle with negative values and the only way I could fix it was by
        Code:
        xi:
        .
        I also tried
        Code:
        ib
        and it didn't work as well, Stata thought it was part of the variable name.

        I'm sorry I don't quate the errors or bring screen prints of them, but I'm not next to the computer that this data is on it.

        Thank you again,

        Fitz
        I simulated something on my own computer and that's what I've got:
        Click image for larger version

Name:	1.jpg
Views:	1
Size:	16.2 KB
ID:	1770180


        Comment


        • #5
          FitzGerald:
          can't you transform -var2- in a two-level categorical variable before=0 and after=1 birth?
          Kind regards,
          Carlo
          (StataNow 18.5)

          Comment


          • #6
            Without loss of information, recode var2 to positive integers, possibly adding value labels to clarify meaning. The actual numerical values won't matter in your regression context, so they might just as well all be positive.

            If the actual values of a (categorical) factor-variable don't matter, why does Stata restrict them to positive values? Well, if negative values were allowed, then -42.var2 could mean two things: the negative of 42.var2 or the indicator for when var2==-42. The restriction to positive values makes the meaning unambiguous.

            Comment


            • #7
              As always, dan klein gives excellent advice clearly explained.

              Concerning
              I also tried Code:

              ib
              and it didn't work as well, Stata thought it was part of the variable name.
              I can only speculate because you don't show the full command in which you tried using ib, but, let me just emphasize that a period (.) is required between the factor variable operator and the variable name. That is, it must be ib0.years_from_first_birth. Without that period, Stata will, indeed, assume that ib0 is part of the variable name. There are no minor details in code.

              Comment

              Working...
              X