Announcement

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

  • xi: xtivreg . Too many dummies

    I am doing some work and have the following command for an instrumental varial regression with panel data. I have 1052 observations per year for 17 years. I am using Stata 17 on mac 12.1

    Code:
    tab year, gen(anio)
    
    for varlist anio*: gen aptoX= porcentaje_apto*X
    
    gen paptoyear= porcentaje_apto*year
    
    xi: xtivreg mortalidad_porhab (hectareas_sembrada=papto) i.year i.fips, first
    I have panel data where year goes from 2003 to 2019, porcentaje_apto is percentage of municipality where a certain tree can be grown (it does not change from year to year) , mortalidad_porhab is infant death rate for each municipality per year, hectareas_sembrada is how many hectares of the tree are grown for each municipality per year and fips is the ID for each municipality.

    Problem is i have too many dummies which makes stata run very slow with this code.

    Is there a way to get same results without the need of the dummies?
    I've also tried
    Code:
    xtivreg mortalida_porhab (hectareas_sembrada= paptoyear), fe first
    but i don't get same results so dont know if i am doing somenthing wrong.
    thanks for any tips you can provide
    Last edited by ana garcia gtz; 09 May 2022, 18:37.

  • #2
    xtivreg is from SSC (FAQ Advice #12). You probably have a large number of municipalities in the dataset. Install ivreghdfe from SSC and absorb the fixed effects. You also should cluster your standard errors at the municipality level.

    Code:
    ssc install ivreghdfe, replace
    ivreghdfe mortalidad_porhab (hectareas_sembrada=papto), first absorb(fips year) cluster(fips)
    Last edited by Andrew Musau; 09 May 2022, 23:30.

    Comment


    • #3
      Cross-posted at https://www.reddit.com/r/stata/comme..._many_dummies/ Please note our policy on cross-posting, which is that you should tell us about it.

      As you're using Stata 17, xi: should be unnecessary in most cases. See

      Code:
      help xi
      on this point: it explains that factor variable notation is usually enough.

      Comment


      • #4
        FYI, xtivreg may have started life as a user-written command, but now it is part of official Stata. The PDF documentation for the command states "We thank Mead Over of the Center for Global Development, who wrote an early implementation of xtivreg." The documentation also says factor variable notation is supported.

        It often strikes me how many times we see people using xi: A few commands, especially older user-written commands (but also sem), do not support factor variable notation, but when a command does support FV it is usually if not always better to use FV than xi: Output produced by xi: tends to look terrible and various post-estimation commands (especially margins) do not work correctly if you use xi:
        -------------------------------------------
        Richard Williams
        Professor Emeritus of Sociology
        University of Notre Dame
        StataNow Version: 19.5 MP (2 processor)

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

        Comment


        • #5
          Originally posted by Richard Williams View Post
          FYI, xtivreg may have started life as a user-written command, but now it is part of official Stata.
          Thanks Richard. What was confusing me was ivregress and user-written commands such as ivreg2 from SSC. Of course, there is no xtivregress (consistent with there not being xtregress).

          Comment

          Working...
          X