Announcement

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

  • acreg and interaction terms

    I'm trying to perform WLS analysis with Conley Robusts standard errors. acreg seems to be the optimal command to perform the exercise in Stata.

    However, my regression has interaction terms between continuous variables, which I am passing to acreg as is standard in other regression commands (c.var1#c.var2). I've been trying to implement the specification but get the error r(198) with the message "operator invalid".

    I've been able to replicate the error in the simple code below:

    Code:
    sysuse auto, clear
    
    qui su mpg
    gen mpg_high = (mpg > r(mean))
    qui su weight
    gen weight_high = (weight > r(mean))
    
    reg price i.mpg_high i.weight_high
    reg price i.mpg_high i.weight_high i.mpg_high#i.weight_high
    reg price c.mpg c.weight
    reg price c.mpg c.weight c.mpg#c.weight
    
    acreg price i.mpg_high i.weight_high
    cap noi acreg price i.mpg_high i.weight_high i.mpg_high#i.weight_high // Also breaks down for discrete interactions.
    acreg price c.mpg c.weight
    cap noi acreg price c.mpg c.weight c.mpg#c.weight  // Replicated error that I am getting in my setting.
    While I can simply create the interaction terms and pass them directly, this approach does not work for the purpose of estimating margins and creating margin plots, which is my ultimate goal.

    Using reg2hdfespatial is not sensible in my setting, as the command does not take weights.

    Any thoughts on either how to solve this or how to get margin plots from interaction terms in a WLS specification with spatially robust standard errors would be very helpful.

    Thanks everyone!

    Jose Morales-Arilla
    PhD Candidate in Public Policy
    Harvard University
    Last edited by Jose Morales-Arilla; 21 Apr 2021, 10:39.

  • #2
    I have the same problem here... If you have a good solution please please post it here! Millions of thanks! Currently I decide to do margins plot using results from reghdfe (not a spatial robust SE) and show in a separate table that the results are spatially robust.

    Comment


    • #3
      User-written commands often do not support factor notation. Obtaining the average marginal effects is easy by centering variables about their sample averages before constructing the interactions. But that doesn't help with marginsplot. Still, one can center the x around the specific values of interest and redo the estimation to obtain the marginal effects at the different values of x. And then plot those separately.

      I'm curious as to why one wants to use WLS in this context.

      Comment

      Working...
      X