GithubHelp home page GithubHelp logo

Comments (17)

sergiocorreia avatar sergiocorreia commented on September 17, 2024

It seems omitted variables are a recurring source of bugs so I might need to think if there is a better way altogether.

Question: what would be your prefered behavior, besides replacing (empty) with (omitted)?
EG: Should I drop all omitted from the tables by default and add a noomit option?

from reghdfe.

sergiocorreia avatar sergiocorreia commented on September 17, 2024

BTW in terms of the regression table (not esttab) it seems that the noomit and noempty options can do what I was thinking without any modifications.

However, I'm still not sure how why some vars get labeled as empty (and what exactly does empty mean in this context).

from reghdfe.

NilsEnevoldsen avatar NilsEnevoldsen commented on September 17, 2024

Question: what would be your prefered behavior, besides replacing (empty) with (omitted)?

  1. Low priority: I don't know what (empty) means, but maybe replace (empty) with (omitted).
  2. Low priority: display 1.sex instead of __1__sex.
  3. Medium priority: make it so that esttab, noomit doesn't show 1.sex#2.agegroup. AFAICT, there's no way of automatically hiding 1.sex#2.agegroup.

EG: Should I drop all omitted from the tables by default and add a noomit option?

I don't understand. If you hid omitted by default, what would noomit do? Do you mean "add a showomit option"?

I think the tables displayed by reghdfe are fine as-is.

from reghdfe.

sergiocorreia avatar sergiocorreia commented on September 17, 2024

Ok, so I did some digging and found this:

Point 1

I'm a bit lost about how Stata chooses what is empty instead of omitted when writing the tables (I call _coef_table which calls _coef_table_mata which calls _b_table.mata and so on).

If you see the output, 1o.sex was indeed tagged with the o. prefix and that didn't stop Stata from recognizing it as "(empty)" instead of "(omitted)". I went into the rabbit hole trying to find out what they meant by that and ended up in viewsource _b_table.mata but it again never says what triggers (empty) instead of (omitted), there is not even an "empty" string in the entire source.

Point 2

Agreed, should be feasible

Point 3

Also agreed, should be a bit harder but doable.

Details:

  • Estout uses a few variants of this code to find out what variables are "omitted": substr(coef_name, 1, 2)=="o.". Thus, they care about the "o." prefix
  • Reghdfe was not tagging 1.sex#2.agegrp with an o. prefix, so the solution must involve putting it somewhere in the string.

from reghdfe.

NilsEnevoldsen avatar NilsEnevoldsen commented on September 17, 2024

Regarding point 1: Huh. Weird. Maybe empty takes precedence over omitted, but for some reason 1o.sex isn't considered empty in the case of areg. I found this. Empty refers to "empty cells", apparently. But e(V) doesn't look different between areg and reghdfe in this respect.

from reghdfe.

sergiocorreia avatar sergiocorreia commented on September 17, 2024

Yep, extremely weird. I did some testing (see code at the end) and also digging in the _rmcoll documentation, and it doesn't make sense at all. I just give up. Feel free to contact tech support if you have the energy.

For now, I'll just fix points 2 and 3 at some point tonight.

Code:

clear all
cls
set more off

cap pr drop foobar
pr define foobar, eclass
    matrix b = 0, 0, 0
    matrix V = 0,0,0\0,0,0\0,0,0

    local names `0'
    matrix colnames b = `names'
    matrix rownames V = `names'
    matrix colnames V = `names'

    ereturn post b V, // dep(depvar) obs(10) dof(5)
    ereturn display
end

set trace off
foobar x y z

foobar 1o.x 1o.y 1o.z // o. prefix doesn't work well with Stata table
foobar 1b.x 1b.y 1b.z //  neither b.
foobar 0bn.x 2bn.x 1bn.z // This works but fails with esttab

* o. prefix works with esttab
foobar 1o.x 2.y 1bno.z
esttab , noomit

from reghdfe.

NilsEnevoldsen avatar NilsEnevoldsen commented on September 17, 2024

noemptycells specifies that empty cells for interactions of factor variables not be displayed.
The default is to include in the table interaction cells that do not occur in the estimation sample and to label them as "(empty)".

from reghdfe.

sergiocorreia avatar sergiocorreia commented on September 17, 2024

The problem is that in reghdfe's case the interaction did occur but was completely colinear with the FEs.

Stata seems to be using some heuristic to tag interactions as empty or omitted. For instance, if the betas are zero it treats them as omitted (1.y) unless you tag them as omitted (1o.y) in which case it labels them as empty.

Since there is no e. prefix for empty, they must have required a trick like that, but AFAIK its not documented (and may affect how estout works)

from reghdfe.

sergiocorreia avatar sergiocorreia commented on September 17, 2024

By the way note that in the test code I put above there was not even a dataset, so there was no way to find out if the level was omitted or empty. Same if you are replaying a previous estimate. There must be a way to separate them internally but it appears to be undocumented.

from reghdfe.

sergiocorreia avatar sergiocorreia commented on September 17, 2024

Update: after talking with tech support and thinking about it, the only complete soln seems to be this:

  • Tag everything as o. so estout works well
  • When displaying the regression table, cheat and remove all the o. cases, the display the table and revert.

from reghdfe.

NilsEnevoldsen avatar NilsEnevoldsen commented on September 17, 2024

What does the regression table look like if you don't remove the o. cases? Is it that they say "(empty)" instead of "(omitted)"?

from reghdfe.

sergiocorreia avatar sergiocorreia commented on September 17, 2024

Exactly. The problem is if people see (empty) and (omitted) in the same table, they start wondering if something is up.

from reghdfe.

NilsEnevoldsen avatar NilsEnevoldsen commented on September 17, 2024

I just encountered the commands

set showbaselevels
set showemptycells
set showomitted

They reminded me of this issue. I don't know if they're useful to you in any way, or if you already knew they existed, but I thought I should mention them just in case.

from reghdfe.

sergiocorreia avatar sergiocorreia commented on September 17, 2024

Hi Nils,

I tried using those, but sadly they require the original dataset to be loaded, so I couldn't use them for what I wanted.

Thanks anyways!
S

from reghdfe.

sergiocorreia avatar sergiocorreia commented on September 17, 2024

BTW, do you always set -showempty- and the others to off? I was thinking about either having an option to set the three to off (e.g. reghdfe ... , compact) or setting them off by default, as it gets annoying to see all the empty cells on top of the collinearity warnings.

from reghdfe.

NilsEnevoldsen avatar NilsEnevoldsen commented on September 17, 2024

No. Those settings are all “empty” for me, i.e. not set to anything, if I understand correctly.

from reghdfe.

sergiocorreia avatar sergiocorreia commented on September 17, 2024

Ok, thanks!

from reghdfe.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.