Announcement

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

  • Keep Interaction Variables in estimates table

    Suppose I want to keep the coefficients for interaction terms using est table. In principle, this should just be a matter of choosing the appropriate keep() argument.

    Previously, I've done this without any difficulties, using the standard factor variable notation e.g. keep(i.var1#i.var2). I've recently upgraded to Stata 15 (15.1) and have discovered that my previous scripts are throwing errors (including when I set the version back to 14). I can't see anything in the help file for estimates store to explain the changed behaviour, so am mystified.

    Here's a simple example.

    Code:
    clear all
    
    version 15.1
    
    sysuse auto2.dta
    
    fvset base none rep78 foreign
    
    reg price i.rep78#i.foreign, noconstant r
    est store test
    
    est table test, keep(i.rep78#i.foreign)

    The error I'm getting is "invalid syntax". It seems the issue isn't with factor variables per se within keep(), for example keep(i.var1) or keep(1.var1) works as expected for the analogous regression.

    Any help is appreciated (sidenote: I'm aware there are other ways of outputting results - such as esttab/estout - which I indeed use to export tables to latex etc. However estimates table is convenient for quickly printing results to screen etc.)

  • #2
    I do not think the problem lies with the version of Stata, since I have version 15.1 and the command shown works above works:

    Code:
    . est table test, keep(i.rep78#i.foreign)
    
    ---------------------------
        Variable |    test     
    -------------+-------------
           rep78#|
         foreign |
           Poor #|
       Domestic  |     4564.5  
           Poor #|
        Foreign  |    (empty)  
           Fair #|
       Domestic  |   5967.625  
           Fair #|
        Foreign  |    (empty)  
        Average #|
       Domestic  |  6607.0741  
        Average #|
        Foreign  |  4828.6667  
           Good #|
       Domestic  |  5881.5556  
           Good #|
        Foreign  |  6261.4444  
      Excellent #|
       Domestic  |     4204.5  
      Excellent #|
        Foreign  |  6292.6667  
    ---------------------------

    Comment


    • #3
      Thanks,

      Your output (specifically the fact that it has empty cells showing) gave me the idea of checking my settings, and indeed the problem goes away if emptycells is set to keep. (I've permanently changed a number of settings for various reasons). Not sure why this is the case - if my recollection is correct emptycells drop didn't cause this problem in Stata 14, but this seems to have identified the issue (and a simple work around).

      Thanks again

      Comment

      Working...
      X