Announcement

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

  • Creating indicator variables xi, prefix() for an interaction term

    Hi STATA friends,

    I aim to generate indicator variables regarding the interaction term c.budgetbalance15#Left_right_placement:

    xi, prefix(_Y) c.budgetbalance15#i.Left_right_placement

    Ultimately, I try to plot the interaction term with the grinter command. Because it doesn`t work with factor variables, I try take a way around it, including the indicator variable in the model like this:

    xi: reg index_EU_support budgetbalance15 membership_length ib2.Political_discussions i.Gender Age i.Education ib2.Left_right_placement Y* i.Community i.country , vce(robust)

    final step:

    grinter budgetbalance15, inter(Y*) const02(i.Left_right_placement)

    i.Left_right_placement is coded:
    1: being politically orientated toward the left-wing,
    2: being orientated politically toward the center and
    3: being orientated politically toward the right-wing.

    But somehow STATA doesn't recognize Y* when I try to run the regression. Does anyone have a hint for me how to create indicator varibales for the interaction c.budgetbalance15#Left_right_placement in a way I can include them in the regression?

    Thank you!!!


  • #2
    You'll increase your chances of a useful answer by following the FAQ on asking questions - provide Stata code in code delimiters, readable Stata output, and sample data using dataex.

    You first question, "Stata not recognizing Y*" is probably that you use the prefix _Y so you have no variables starting with Y.

    In recent versions of Stata, you don't need the xi in the regress statement. Read the documentation on factor variable notation. If left_right is a dummy, then c.budgetbalance15#i.left_right_placement should work just fine. You probably don't need the i. - I think Stata assumes dummies in this notation. You'll want to include the main effects as well - budgetbalance15 and left_right_placement. If left is continuous, you'll need c. before it. By creating the interactions prior to the regress, you make it hard to use margins and marginsplot to handle the interactions. I'd suggest setting up the regress with factor variable notation for the interactions, and then use margins and marginsplot.

    Comment

    Working...
    X