Announcement

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

  • Variables not dropping out in FE regression

    I am trying to do a fixed effects estimation for which I need teacher fixed effects, my problem is that when I take teacher fixed effects then invariant variables like gender don't drop out. I have shared a data example for reference, I don't know what I am doing wrong please help.


    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input double child_teachercode byte(teachergender teacherage teachingexper teacheredu)
    10104 2 26 3 3
    10103 2 24 1 3
    10104 2 26 3 3
    10103 2 24 1 3
    10103 2 24 1 3
    10104 2 28 3 3
    10103 2 24 1 3
    10104 2 26 3 3
    10103 2 24 1 3
    10104 2 26 3 3
    10103 2 24 1 3
    10104 2 26 3 3
    10104 2 26 3 3
    10103 2 24 1 3
    10104 2 26 3 3
    10103 2 24 1 3
    10104 2 26 3 3
    10103 2 24 1 3
    10104 2 26 3 3
    10103 2 24 1 3
    10103 2 24 1 3
    10104 2  . . .
    10103 2 24 1 3
    10104 2 26 3 3
    10103 2 24 1 3
    10104 2 26 3 3
    10104 2 26 3 3
    10103 2 24 1 3
    10103 2 24 1 3
    10371 1 22 1 3
    10103 2  . . .
    10205 2 50 3 2
    10205 2 50 3 2
    10205 2 50 3 2
    10205 2 50 3 2
    10204 2 54 3 1
    10205 2 50 3 2
    10205 2 50 3 2
    10205 2 50 3 2
    10205 2 50 3 2
    10205 2 50 3 2
    10205 2 50 3 2
    10205 2 50 3 2
    10205 2 50 3 2
    10205 2 50 3 2
    10205 2 50 3 2
    10205 2 50 3 2
    10205 2 50 3 2
    10205 2 50 3 2
    10205 2 50 3 2
    10204 2 54 3 1
    10205 2 50 3 2
    10205 2 50 3 2
    10205 2 50 3 2
    10205 2 50 3 2
    10205 2 50 3 2
    10205 2 50 3 2
    10204 2 54 3 1
    10205 2 50 3 2
    10204 2 54 3 1
    10205 2 50 3 2
    10205 2 50 3 2
    10205 2 50 3 2
    10205 2 50 3 2
    10205 2 50 3 2
    10205 2 50 3 2
    10205 2 50 3 2
    10205 2 50 3 2
    10205 2 50 3 2
    10205 2 50 3 2
    10205 2 50 3 2
    10205 2 50 3 2
    10205 2 50 3 2
    10205 2 59 3 2
    10204 2 52 3 2
    10205 2 50 3 2
    10205 2 50 3 2
    10205 2 50 3 2
    10204 2 52 3 2
    10205 2 50 3 2
    10205 2 50 3 2
    10205 2 50 3 2
    10205 2 50 3 2
    10204 2 54 3 1
    10205 2 50 3 2
    10203 2 40 3 4
    10203 2 40 3 4
    10203 2 40 3 4
    10203 2 40 3 4
    10203 2 40 3 4
    10203 2 40 3 4
    10203 2 40 3 4
    10203 2 40 3 4
    10203 2 40 3 4
    10203 2 40 3 4
    10371 1 22 1 3
    10351 1 21 1 2
    10304 1 40 3 2
    10351 1 21 1 2
    10304 1 42 3 2
    end
    label values teachergender tr3_s1q2
    label def tr3_s1q2 1 "Male", modify
    label def tr3_s1q2 2 "Female", modify
    label values teachingexper tr3_s1q4
    label def tr3_s1q4 1 "Less than 1 year", modify
    label def tr3_s1q4 3 "Greater than 3 years", modify
    label values teacheredu tr3_s1q7
    label def tr3_s1q7 1 "<Matric", modify
    label def tr3_s1q7 2 "Matric", modify
    label def tr3_s1q7 3 "FA/FSc", modify
    label def tr3_s1q7 4 "BA/BSc", modify
    ------------------ copy up to and including the previous line ------------------
    --more--

  • #2
    I'm afraid you need to provide more information here. Is child_teachercode a teacher identifying variable? If so, why are there multiple observations per value of this variable? Is there a year variable, or something like that, which you didn't show?

    How did you -xtset- the data?

    What was the code you used for the fixed effects regression?

    Comment


    • #3
      Hi Beenish,

      It would be helpful if you could include the actual FE model you tried to run and the results that you got. I suspect it has to do with one of two problems (others may point out more):
      1. If you are running an OLS or logit regression, it's because in at least some observations, teachergender is changing within child_teachercode
      2. Trying to manually run a fixed-effects probit model (Stata doesn't have a fixed-effects probit model, xtprobit only estimates random effects). You can read more about why Stata doesn't have a FE probit model here https://www.stata.com/statalist/arch.../msg00364.html (short answer is there is a good technical reason for it, called the incidental parameters problem), but if you try and run it manually, the time-invariant variables may not drop out. Try xtlogit instead.
      As I mentioned, those the are the two challenges that immediately, come to mind. There may be others.

      Comment


      • #4
        I bet that it is due to issue number one that David mentioned. I would analyze the gender variable to see if it switches for any observation over time.

        Comment


        • #5
          Code:
          xtset child_teachercode
          I used this toset my data
          Code:
          xtreg math_theta_mle i.grade i.school_type child_female teacherage i.teachingexper i.teacheredu i.teachertraining daysteacherabsent i.school_district i.teachingmedium library computer sports wall fans electricity i.toiletfacility i.watersource i.typeofcontract i.textbooks contract i.YOB i.MOB month9 month8 month7 month6 month5 month4 month3 month2 month1 month0 i.childageyear i.transporttype i.timetaken motherinhouse fatherinhouse i.motheredu i.fatheredu elderbro eldersis teachergender , fe i( child_teachercode) robust cl( child_teachercode)
          This is my regression

          Comment


          • #6
            There is a year variable, as this is a panel for three years for multiple children

            Comment


            • #7
              I have checked the variable, all values are constant over the years.

              Comment


              • #8
                I have never known Stata to fail to omit a within-panel covariate that was constant within-panels. I know you say you checked the variable and all values are constant over the years, but I wonder if you checked it correctly. If you just scanned it by eye, you could easily miss something in a large data set. (And I assume your data set is large because if it isn't, you have no hope of reasonably estimating a regression with as many variables as you show.) Here's how to check if gender is really constant within child_teachercode

                Code:
                by child_teachercode (teachergender), sort: gen byte problem = ///
                    (teachergender[1] != teachergender[_N])
                assert !problem
                If your teachergender variable is truly consistent within child_teachercode, the -assert- command will give you no output. If there is some discrepancy, then the -assert- command will complain that the assertion is false. If that happens, you can run
                Code:
                list child_teachercode teachergender if problem, sepby(child_teachercode)
                to see the offending observations.

                Comment


                • #9
                  Thank you Clyde, I found the values that were causing problems.

                  Comment

                  Working...
                  X