Announcement

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

  • Converting reg into xtreg

    When someone converts a -regress- code into a -xtreg- code with the -fe- option, is it just a matter of substituting like this?:

    regress weight age1 age2 height age1ht age2ht

    becomes

    xtreg weight age1 age2 height age1ht age2ht, fe ?

    sort age
    by age: regress weight height

    becomes

    sort age
    by age: xtreg weight height, fe ?

  • #2
    Diante,

    please read the comments in your previous post. Do not start another post which essentially targets the same question.

    There is nothing wrong with your code. These are merely two (very) different models. The fixed-effects model (within estimator) controls for any (un)observed covariates that are constant within a panel unit (probably individuals in your case). As I explained in your previous post, the regress command (also called pooled OLS) corresponds to random-effects estimator if (and only if) the within panel unit variance is 0.

    Best
    Daniel

    Comment


    • #3
      Just a few comments:

      This is outdated code. It is generally much better to use factor variable notation, e.g.

      Code:
      regress weight i.age height i.age#c.height
      In the fe model, any variable with time invariant values, e.g. gender, will drop out.

      With xtreg, if you have specified a time variable, you could do things like use lagged values of variables.
      -------------------------------------------
      Richard Williams, Notre Dame Dept of Sociology
      Stata Version: 17.0 MP (2 processor)

      EMAIL: [email protected]
      WWW: https://www3.nd.edu/~rwilliam

      Comment


      • #4
        Thank you for the help.

        Based on what Richard said, would the following code be wrong/useless?

        xtreg weight gender, fe

        Comment


        • #5
          Nothing wrong here in terms of legal syntax. Stata will omit gender (assuming that it is constant within all panel units). Whether this is 'useless' is up to you to decide.

          Best
          Daniel

          Comment


          • #6
            Originally posted by Diante Fielding View Post
            Thank you for the help.

            Based on what Richard said, would the following code be wrong/useless?

            xtreg weight gender, fe

            Assuming gender doesn't change across time, then gender would just get dropped form the model. It would stay in if you instead did re, though.
            -------------------------------------------
            Richard Williams, Notre Dame Dept of Sociology
            Stata Version: 17.0 MP (2 processor)

            EMAIL: [email protected]
            WWW: https://www3.nd.edu/~rwilliam

            Comment


            • #7
              I'm lucky that you're online. I want to see the effect of gender, while taking care of omitted variables.
              Therefore I will use xtreg weight gender, re
              and
              regress weight i.age height i.age#c.height, fe

              I didn't use factor variabl notation before because without that notation my regression output looks nicer
              Last edited by Diante Fielding; 01 Aug 2014, 10:11.

              Comment

              Working...
              X