Announcement

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

  • absorb fixed effects in xtreg or mixed?

    I have a model that includes both user fixed effects (fe) and country random effects (re). My question is: Should I be using the "mixed" command or the "xtreg" command to include both fixed effects and random effects in the model? I have attempted both and not been successful. I have 20,000 users and 150 countries. Could we absorb the Fixed effect in the model like what areg or reghdfe do?

    my code for xtreg is:

    xtset country
    xtreg y x1 x2 i.user, re



  • #2
    Originally posted by Sebastian Chung View Post
    xtset country
    xtreg y x1 x2 i.user, re
    I think that the 'xtreg y x1 x2 i.user, re' does not work because the 'users' is of high dimension (#20,000). For the Stata (and other common statistical softwares), inverting such a matrix can be computationally very demanding.

    FAQ 12.1: We can understand your dataset only to the extent that you explain it clearly. The best way to explain it is to show an example. The community-contributed command dataex makes it easy to give simple example datasets in postings. It was written to support Statalist and its use is strongly recommended. Usually a copy of 20 or so observations from your dataset is enough to show your problem. See help dataex for details.

    Comment


    • #3
      You'll increase your chances of a useful answer by following the FAQ on asking questions - provide Stata code in code delimiters, readable Stata output (fixed spacing fonts help), and sample data using dataex.

      If users do not switch country, then you can dispense with the country random effects - they fall into the category of things that do not vary within user and so are picked up by the user fixed effect. This might help since you now can use xtreg, fe and not try to invert a massive matrix..

      Comment


      • #4
        Thanks Amin and Phil for your suggestions! In that case, does it mean that I cannot estimate the mixed effect model because there are 20,000 user FE? I originally want to use procedure similar to areg and reghdfe to absorb the user FE (that the procedure controls rather than estimates the FE).

        Comment


        • #5
          I do agree with Phil Bromiley. I speculate that you do not have enough movers in your sample that enables you to disentangle the FE of the country with that of users. If there were enough movers, you could use e.g., Abowd, Kramarz, and Margolis (1999) method using connectedness (explained simpler here). Including the country's dummies, you might also face the issue of multicollinearity. I think that the choice of a model depends on your research purpose. Are you going to use the estimated FE , or are you interested in the association between x and y? Could you please explain what the goal of your research is?

          Originally posted by Sebastian Chung View Post
          does it mean that I cannot estimate the mixed effect model because there are 20,000 user FE?
          If you want to use FE model, you can estimate the model using the FE of users but you can not put users as 'i.user' in the regression.
          Code:
          xtset user
          xtreg y x1 x2 controls , fe
          Originally posted by Sebastian Chung View Post
          I originally want to use a procedure similar to areg and reghdfe to absorb the user FE (that the procedure controls rather than estimates the FE)
          As far as I know, their results will be the same. See an example below.

          Example (xtreg, areg, reg with i. ):
          Let's for a now, ignore the country's FE. Create the following demonstration data set , and then run the regressions.

          Code:
          * Create a demonstration data set
          clear all
          set obs 300
          set seed 1234
          gen c = rnormal()
            label var c "Time Constant Heterogeniety (user specific)"
          gen id = _n
            label var id "User ID"
          expand 10
          bysort id: gen year=_n
            label var year "Year of observation"
          tab year
          gen x = rnormal()+c
            label var x "explanatory variable X (with time constant and time varying components)"
          gen u = 2*rnormal()+4*c
            label var u "Error term (correlated with unobservables c)"
          gen y = x + u
            label var y "Outcome variable"
          xtset id year  
          save "DemoData"
          Now, we try xtreg, areg, and reg with i. :

          Code:
          use  "DemoData" , clear
          xtreg y x, fe
          areg y x, absorb(id)
          reg y x i.id
          Last edited by Amin Sofla; 31 May 2018, 12:00.

          Comment

          Working...
          X