Announcement

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

  • outreg and factor variables

    Dear Statalist,
    I use factor variables in a standard regression (i.varname). I wish to only keep a few variables in my output table using outreg, but I cannot find a way to refer to factor variables in the keep/drop option.
    Example of what I am trying to accomplish:
    Code:
    regress outcome c.cost##eligibility i.age i.year
    outreg, keep(cost eligibility)
    *or alternatively:
    outreg, drop(i.age i.year)
    That is, there are dummies for each age and year category, which I don't want to get into my output table. Cost is a continuous variable that I interact with a dummy variable eligibility. I have tried keep(cost 1.eligibility), keep(c.cost##eligibility) etc. modifications, without luck. With just "eligibility" in the keep option, the error message is "eligibility not found in estimates, or repeated". With "1.eligibility" the error message says "factor variables not allowed", with "i.eligibility" it says "1: operator invalid". With standard postregression command you can use the 1.varname type to refer to factor variables but apparently not outreg.

    A way out is of course to create a new variable (generate cost_elig=cost*eligibility) and include that in the regression, with keep(cost eligbility cost_elig) in outreg, but I like the flexibility of factor variable and interaction notation, that I don't have to generate new variabels as I go.

    I found an earlier thread from a couple years ago on the same topic but the issue remained unresolved.
    Any ideas? Or, does outreg simply not support factor variables?
    Best,
    Tuuli

  • #2
    With "1.eligibility" the error message says "factor variables not allowed"
    Can you double check this? It works for me.
    Code:
    sysuse auto, clear
    regress price c.mpg##i.foreign
    outreg, keep(mpg 1.foreign 1.foreign#c.mpg)
    Alternatively:
    Code:
    reghdfe outcome c.cost##eligibility, absorb(age year)
    outreg

    Comment


    • #3
      Thank you Nils, you're right, I tried your auto example on my own computer and it works.
      Amazingly though, when I try the same example on the computer where my data is, it doesn't! There, I get the same error messages that I described earlier.
      I am even more puzzled now.

      Comment


      • #4
        Check which version of outreg (SJ/SSC) you have on each machine.

        Code:
         
        which outreg
        Check that you are not confusing outreg with outreg2 (SSC).

        Comment


        • #5
          Thanks Nick. It's indeed outreg, not outreg2. But on my computer where the keep option works, I have outreg version 4.30 (28oct2013), and on the computer where it doesn't I have version 4.10 (30nov2011). There has probably been an update regarding this issue. I'll update the old one with adoupdate. Thanks!

          Comment


          • #6
            My generic advice: Before posting about possible program bugs or problems, run -update all- and -adoupdate-. If you are lucky the problem may have already been fixed.
            -------------------------------------------
            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

            Working...
            X