Announcement

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

  • Interacting variables

    Hello, I need some help.

    I'm doing my master thesis about renewable energies and politics I have a panel data with 18 years and 155 countries.


    I have my regression
    Code:
    xtreg reconsumption lngdppcpppcte2011lag1 gdpgrowthlag1 manufacturinglag1 lnoilpricelag1 energyimportslag1 left presidential absenceofcorruptionlag1, fe vce(robust)
    and I wanna know how I can interact
    Code:
    lngdppcpppcte2011lag1
    with it owns median. Both variables are continuous.

    Thanks
    Last edited by Joyce Parreira; 06 Mar 2019, 05:49. Reason: #paneldata #interactingvariables #economics

  • #2
    Joyce:
    provided that I cannot follow what you're after, you may want to try:
    Code:
    egen median_var=median(lngdppcpppcte2011lag1)
    xtreg reconsumption c.lngdppcpppcte2011lag1##c.median_var gdpgrowthlag1 manufacturinglag1 lnoilpricelag1 energyimportslag1 left presidential absenceofcorruptionlag1, fe vce(robust)
    In all likelihood
    , you will experience omissions due to collineraity.
    Kind regards,
    Carlo
    (Stata 18.0 SE)

    Comment


    • #3
      I'm not sure that this does much - multiplying a variable by a constant just changes the scale but doesn't really change the results. Including a second constant (median_var) simply changes the intercept. Do you mean that you want separate parameters for lngdppcpppcte2011lag1 above and below the median? If so, you would use Carlo's egen then
      g highlng=lngdppcpppcte2011lag1>median_var xtreg y highlng##lngdppcpppcte2011lag1 By the way, such long variable names are problematic - often they're substantially truncated in results making it hard to know what variable is what.

      Comment

      Working...
      X