Announcement

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

  • preparing data for dummy variable regression

    Dear All,

    I would like to know if I have a dummy variable in my data set which is already have the value of 1 and 0. if i write the command for my regression as below:

    Code:
    regress y dummvariable
    Stata will consider the value of my dummyvariable==1 or 0 not.

    Or I have to use separate command.

    With best regards,
    UP
    Last edited by Upananda Pani; 24 Jul 2022, 08:06.

  • #2
    Upananda:
    the best way to handle categorical predictors in Stata is via -fvvarlist- notation.
    That said:
    Code:
    regress y i.dummyvariable
    will consider all the 0/1 values of your categorical predictor.

    If for any reason that I cannot follow in the light of your details you want to retstrict your categorical predictor to, say, 1 value, you can code:
    Code:
    regress y i.dummyvariable if dummyvariable==1
    A toy-example follows:
    Code:
    . use "C:\Program Files\Stata17\ado\base\a\auto.dta"
    (1978 automobile data)
    
    . regress price i.foreign if foreign==1
    note: 1.foreign omitted because of collinearity.
    
          Source |       SS           df       MS      Number of obs   =        22
    -------------+----------------------------------   F(0, 21)        =      0.00
           Model |           0         0           .   Prob > F        =         .
        Residual |   144363213        21   6874438.7   R-squared       =    0.0000
    -------------+----------------------------------   Adj R-squared   =    0.0000
           Total |   144363213        21   6874438.7   Root MSE        =    2621.9
    
    ------------------------------------------------------------------------------
           price | Coefficient  Std. err.      t    P>|t|     [95% conf. interval]
    -------------+----------------------------------------------------------------
         foreign |
        Foreign  |          0  (omitted)
           _cons |   6384.682   558.9942    11.42   0.000      5222.19    7547.174
    ------------------------------------------------------------------------------
    
    .
    Last edited by Carlo Lazzaro; 24 Jul 2022, 08:16.
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment


    • #3
      There is nothing special you need to do. The estimates are the same whether or not you use i.dummyvariable, and you don't want to condition the observations on dummyvariable == 1 as you won't have any variation in the variable you care about. So I'm not sure what you're asking. It only makes sense to run the regression you propose when the dummy variable takes on both zero and one in your sample. In the simple case you show, the coefficient on dummyvariable is the difference in the sample average of y between dummy = 1 and dummy = 0. The intercept is the average of y when dummy = 0. Adding control variables makes the interpretation more complicated, but then you can think of holding other factors fixed.

      I think you're really asking about how to interpret the coefficient on dummy, and is simply the difference in the average outcome on y between the dummy = 1 and dummy = 0 groups, possibly holding fixed some other variables.

      Comment


      • #4
        I am grateful to both of you for your time and help in this regard. But when I have tried with the i.dummyvariable in my regression command. I have not observed any significant change in my coefficients. I am grateful Prof. Wooldridge for his efforts to explain the coefficients interpretation. I got my solution.

        Comment


        • #5
          There should be no change in your coefficients. i.dummyvariable is useful when you have interactive effects, and for nonlinear models. For a linear model without interactions there is little, if any, benefit from factor notation. It's all about interpreting the OLS estimates.

          Comment


          • #6
            Upananda:
            Jeffrect is obviously right about the dummy issue (with or without -fvvarlist- notation, nothing is expected to change).
            However, as in the future you may need interactions, I find getting yourself familiar with -fvvarlist- and adopting it by default a good habit, even with trivial codes.
            Kind regards,
            Carlo
            (Stata 19.0)

            Comment

            Working...
            X