Announcement

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

  • #16
    With that number of students and some reasonable number of schools, convergence shouldn't take forever with mixed under most circumstances, but if you're growing impatient, then consider going with the equivalent SEM, as Erik and Leonardo allude to above.

    In a mock dataset that I tried to make emulate yours to the extent that I can, the SEM configuration converges in about a quarter of the time that the mixed-model does. See below. (Do-file and log file attached if you're interested.)
    Code:
    version 18.0
    
    clear *
    
    // seedem
    set seed 923940210
        
    quietly set obs `=floor(62934 / 400)'
    generate `c(obs_t)' sid = _n
    generate double sid_u = rnormal()
    
    // My guesses as to the number of school-level & student-level predictors
    forvalues i = 1/4 {
        generate byte bet`i' = rbinomial(1, 0.5)
    }
    generate double bet5 = runiform()
    generate double bet6 = runiform()
    
    quietly expand 400
    generate `c(obs_t)' pid = _n
    drawnorm sco0 sco1, double corr(1 0.5 \ 0.5 1)
    quietly {
        replace sco0 = sco0 + sid_u
        replace sco1 = sco1 + sid_u
    }
    forvalues i = 1/6 {
        generate double wit`i' = runiform()
    }
    
    timer clear
    timer on 1
    gsem (sco? <- M[sid] i.(bet1-bet4) c.(wit1-wit6 bet5 bet6)), ///
        covstructure(e._OEn, unstructured) ///
        nocnsreport nodvheader nolog
    timer off 1
    
    quietly reshape long sco, i(pid) j(sbj)
    timer on 2
    mixed sco i.sbj##i.(bet1-bet4) i.sbj##c.(wit1-wit6 bet5 bet6) ///
        || sid: || pid: , noconstant residuals(unstructured, t(sbj)) ///
        nogroup nolrtest nolog
    timer off 2
    
    timer list
    
    exit
    About half a minute with gsem versus two minutes with mixed on my machine.

    So, something like
    Code:
    /* Nota bene: no  -rename-; no -reshape- */
    gsem ///
        ( Nrdtlectf Nrdmathf <- M[id_ecole] ///
            i.(sexedeelv agedeélève diflcev1ir avoirfaim rvauxdome11ique ses) ///
            c.(Nbelvdanslécole nbensgt) ///
            i.(localisation genremaitre typeécole coursdesoutien) ) ///
        if ecaxte > 1, ///
        covstructure(e._OEn, unstructured)
    in your case.
    Attached Files

    Comment


    • #17
      Originally posted by Joseph Coveney View Post
      /* Nota bene: no -rename-; no -reshape- */
      But you will need either
      Code:
      rename *, lower
      or to add the nocapslatent latent(M) options to gsem estimation command.

      Comment

      Working...
      X