Announcement

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

  • Undiscovered mistake in regression with interaction term

    Hey everyone.

    I'm having troubles with the outcome of a linear regression model, since I expected something completely different:

    This ist how I coded the interaction:
    g number_younger_siblings_female=number_younger_sibl ings*(sex-1)

    The variable sex is coded 1 for males and 2 for females. (sex-1) makes it 0 for males and 1 for females.

    I expected the outcome to be a larger negative number for females, but what I found is a lower negative effect for females, what is unlikely according to the literature. It would make sense to have an negative coefficient of the interaction So I think there must be a mistake and I just can't find it. I would be super grateful if someone would find the mistake!

    This is my output:
    Click image for larger version

Name:	Bildschirmfoto 2022-09-22 um 07.51.36.png
Views:	2
Size:	241.2 KB
ID:	1682875
    Attached Files

  • #2
    Lena:
    1) the best practice to number the levels of a categorical variable is starting from 0 onwards (and if I'm not mistaken, Stata recode levels this way, i.e., starting from 0);
    2) the best practice to create interactions and categorcal variable is using -fvvarlist- notation;
    Code:
    c.numbero_of_younger_siblings##i.female
    I would give a shot to what above and see if the issue get fixed.
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment


    • #3
      Thank you so much for your ideas! So the code you provided is the interaction itself? So is this the correct whole regression?:

      xtreg enrollment female number_younger_siblings c.number_younger_siblings##i.female i.age, fe cluster(hh_idn)

      I don't really get what to do

      Comment


      • #4
        No ## indicates that Stata should include the interaction and the main effects, so your command should be:

        Code:
        xtreg enrollment c.number_younger_siblings##i.female i.age, fe cluster(hh_idn)
        You can read more about this if you type in Stata help fvvarlist
        ---------------------------------
        Maarten L. Buis
        University of Konstanz
        Department of history and sociology
        box 40
        78457 Konstanz
        Germany
        http://www.maartenbuis.nl
        ---------------------------------

        Comment


        • #5
          Ahh now I understand and it worked!! Thank you so much!

          Comment

          Working...
          X