Announcement

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

  • Problem with Interaction Expension (xi)

    I am trying to replicate a study based on a panel data set (125 countries, 35 years) and I am not able to fully understand the use of the command xi in this particular context. I understand that xi expands terms containing categorial variables into indicator variables.
    In the code below Step 2 is clear to me. What is the function of Step 1 though? That means, why is an ivreg2 necessary in advance to expand the variables risocode, year*wb_region into indicator variables?

    Code:
    * Step 1
    /* Generating in-sample indicator so that all specifications have the same number of observations */
    qui: xi: ivreg2 intra_state (wheat_aid=instrument) `baseline_controls' i.risocode i.year*i.wb_region if year>=1971 & year<=2006, cluster(risocode)
    gen in_sample=1 if e(sample)==1
    
    *Step2
    *** Panel A: OLS Estimates ***
    * Col 1
    xi: reg any_war wheat_aid i.risocode i.year*i.wb_region if in_sample==1, cluster(risocode)
    outreg2 wheat_aid using "T2_PanelA_ols.xls", replace se noast nocons lab dec(5)

  • #2
    Step 1 has nothing to do with expanding indicator variables.

    The purpose of the first step is to determine what observations are included when the ivreg command is specified so that the OLS estimates are run on exactly the same observations. The command
    Code:
    gen in_sample=1 if e(sample)==1
    creates the variable in_sample which is 1 for observations that were included in the ivreg, and 0 for those that were excluded - such as year<1971, year>2006, and any observations for which one of the variables in the model is missing. Then in the OLS regression
    Code:
    if in_sample==1
    runs it on exactly the same observations, even though it does not use, for example, the baseline_controls variables, some of which may have missing values.

    Comment


    • #3
      Thank you, William, now it makes sense to me.
      Only one follow-up question: The command `baseline_controls' in Step 1 is only there to label the variables i.risocode and i.year*i.wb_region as the baseline controls and to refer to it later as a macro, right? Because leaving this command out doesn't seem to change anything.

      Comment


      • #4
        The macro `baseline_controls' presumably was defined prior to that step. It probably was supposed to contain variables. Is there a line somewhere above the reg command that looks like this?
        Code:
        local baseline_controls ...
        Stata/MP 14.1 (64-bit x86-64)
        Revision 19 May 2016
        Win 8.1

        Comment


        • #5
          Great, your are right. Thank you Carole.

          Comment

          Working...
          X