Announcement

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

  • Two-level hierarchical model in Stata using meglm

    Hei
    Could anyone help me with my code as it is not working and I cannot figure out the problem.
    I am doing a two level hierarchical model where the first level is individual and second level is school level. I want to see the effect on students achievement, where individual level variables are entered as fixed effects and school level variables as random effects. Unfortunately my model does not work as it gives me an error: cannot compute an improvement -- discontinuous region encountered.
    Does anyone know how could I change my code to get it working or would it be very wrong to enter the school level variables into the model as fixed effects?

    I am using PISA_2022 dataset and I will copy my code here:
    My individual variables are coded as: ST004D01T - 0 if male and 1 if female; IMMIG - 0, 1, 2; ST022Q01TA - 0, 1; LANGTEST_QQQ.y - 0,1.
    School level variables: SC001Q01TA (school location) - 0, 1, 2; CLSIZE - 0, 1, 2, 3

    Before doing the model I saw that the first level scale W_FSTUWT needs to be recalculated so:
    sort CNTSCHID
    generate sqw = W_FSTUWT * W_FSTUWT
    by CNTSCHID: egen sumw = sum(W_FSTUWT)
    by CNTSCHID: egen sumsqw = sum(sqw)
    generate pst1s1 = W_FSTUWT*sumw/sumsqw

    And then finally my model:
    meglm PV1MATH ICTOUT ICTAVSCH ICTAVHOM ICTWKDY ST004D01T i.IMMIG ESCS REPEAT ST022Q01TA LANGTEST_QQQ.y [pweight= pst1s1] || CNTSCHID: i.SC001Q01TA i.CLSIZE, pweight(W_SCHGRNRABWT)

    My end goal is to find out if technology has an impact on students achievement so the first 4 variables are PISA own ICT variables. Also as dependent variable I am using the PV1MATH variable.


  • #2
    If you are using PISA achievement tests, then you have to take into account the plausible values for the outcome. The OECD data team has developed a Stata module, repest, to facilitate analyses. The cheat sheet is handy.

    In terms of your model, school level variables i.SC001Q01TA i.CLSIZE belong in the fixed part of the model, not the random part of the model when you have two level data such as this. Random variables in these model are variables that you allow for their slopes to vary across higher level units. But schools are the highest level units in your data, so these variables cannot vary in this way.

    Accordingly, the syntax for the meglm part of the model, should instead be the following (ignoring pweights, which should be handled in the repest call):
    Code:
    meglm PV1MATH ICTOUT ICTAVSCH ICTAVHOM ICTWKDY ST004D01T i.IMMIG ESCS REPEAT ST022Q01TA ///
          LANGTEST_QQQ.y i.SC001Q01TA i.CLSIZE || CNTSCHID:

    Comment

    Working...
    X