Announcement

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

  • Graph interaction term

    Hi,


    I’m estimating a hybrid within-between model following Schunck (2013) and I would like to graph average marginal effects for both the within-person and between-person interaction.

    Because I’ve had to construct the interaction manually (following Schunck’s approach, pg. 71-72) instead of using factor variable notation, I can’t use margins/marginsplots and I can’t figure out how else to do it.

    The interaction is between binary employment and finances (three categories)

    I have two specifications. The first includes the main effects of both employment and finances:

    Code:
    xtreg sf12mcs_dv_z memp2 demp2 mfin2 dfin2 mfin3 dfin3 memp2Xfin2 demp2Xfin2 memp2Xfin3 demp2Xfin3 mage_2 dage_2 mage_3 dage_3 mage_4 dage_4 mhealth_2 dhealth_2 i.sex i.parent_ed i.parent_occ_GT i.ethnic, i(pidp) re vce(cluster pidp)
    The second excludes the main effect of employment:

    Code:
    xtreg sf12mcs_dv_z mfin2 dfin2 mfin3 dfin3 memp2Xfin1 demp2Xfin1 memp2Xfin2 demp2Xfin2 memp2Xfin3 demp2Xfin3 mage_2 dage_2 mage_3 dage_3 mage_4 dage_4 mhealth_2 dhealth_2 i.sex i.parent_ed i.parent_occ_GT i.ethnic, i(pidp) re vce(cluster pidp)

    Where emp2Xfin1 = emp2*fin1, emp2Xfin2 = emp2*fin2 and emp2Xfin3 = emp2*fin3, each decomposed into within (d) and between (m) components.



    Schunck, R. (2013). Within and between estimates in random-effects models: Advantages and drawbacks of correlated random effects and hybrid models. The Stata Journal, 13(1), 65-76.

  • #2
    If you have Stata 19+, see -xtreg, cre- for estimating a correlated random-effects (CRE) linear panel data model: https://www.stata.com/new-in-stata/c...effects-model/. Your reference paper is from 2013, which is somewhat outdated. With Stata 19 or later, you no longer need to estimate a CRE model manually by creating interactions and using the RE estimator.

    Comment


    • #3
      Andrew Musau gives good advice, as always.

      I just want to point out one limitation: this only works with linear regression. StataCorp has not extended the -cre- option to -xtlogit-, -xtprobit-, -xtpoisson-, nor, as far as I am aware, any other -xt- commands.

      The user-written -xthybrid- program, although it does not support factor-variable notation, does support correlated random effects models for all of the regression types supported by Stata's -meglm- command, i.e. all the standard general linear models.

      So while I urge O.P. to follow the advice in #2 and switch over to -xtreg, cre- so he can make use of -margins-, if he finds himself in a situation where a non-linear regression is called for, he will have to learn how to emulate -margins- when factor-variable notation is unavailable or, probably simpler, emulate -xthybrid- using -meglm-.

      Comment

      Working...
      X