Announcement

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

  • ICC coefficient with cross-classified modeling

    Hi,

    I'm wondering whether it is possible to get an intraclass coefficient after a cross-classified regression. I used the following syntax:
    Code:
    mixed var1 var2 if var3>=5 || _all: R.ResponseID || profileid:
    Using the following commands returns an error:
    Code:
    . iccvar
    only _cons can have random effects
    r(9);
    
    . estat icc
    estat icc not allowed after crossed-effects models
    r(321);
    Thanks in advance.

  • #2
    Maarten, have you found an answer since?
    My hunch is that there is no way with mixed or meglm, but would be delighted to hear there is a way!

    Comment


    • #3
      Originally posted by Johannes Muller View Post
      would be delighted to hear there is a way!
      There is.

      .ÿ
      .ÿversionÿ15.1

      .ÿ
      .ÿclearÿ*

      .ÿ
      .ÿsetÿseedÿ`=strreverse("1490777")'

      .ÿ
      .ÿ//ÿRaters
      .ÿquietlyÿsetÿobsÿ10

      .ÿgenerateÿbyteÿridÿ=ÿ_n

      .ÿgenerateÿdoubleÿrid_uÿ=ÿrnormal(0,ÿsqrt(0.25))

      .ÿ
      .ÿtempfileÿraters

      .ÿquietlyÿsaveÿ`raters'

      .ÿ
      .ÿ//ÿTargets
      .ÿdropÿ_all

      .ÿquietlyÿsetÿobsÿ100

      .ÿgenerateÿbyteÿtidÿ=ÿ_n

      .ÿgenerateÿdoubleÿtid_uÿ=ÿrnormal(0,ÿ1)

      .ÿ
      .ÿcrossÿusingÿ`raters'

      .ÿ
      .ÿ//ÿScores
      .ÿgenerateÿdoubleÿwhatever1ÿ=ÿruniform()

      .ÿgenerateÿdoubleÿwhatever2ÿ=ÿruniform()

      .ÿ
      .ÿgenerateÿdoubleÿscoÿ=ÿrid_uÿ+ÿtid_uÿ+ÿrnormal(0,ÿsqrt(0.25))

      .ÿ
      .ÿ*
      .ÿ*ÿBeginÿhere
      .ÿ*
      .ÿmixedÿscoÿc.w*ÿ||ÿ_all:ÿR.tidÿ||ÿrid:ÿ,ÿnogroupÿnostderrÿnolrtestÿnolog

      Mixed-effectsÿMLÿregressionÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿNumberÿofÿobsÿÿÿÿÿ=ÿÿÿÿÿÿ1,000

      ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿWaldÿchi2(2)ÿÿÿÿÿÿ=ÿÿÿÿÿÿÿ0.42
      Logÿlikelihoodÿ=ÿ-912.96748ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿProbÿ>ÿchi2ÿÿÿÿÿÿÿ=ÿÿÿÿÿ0.8107

      ------------------------------------------------------------------------------
      ÿÿÿÿÿÿÿÿÿscoÿ|ÿÿÿÿÿÿCoef.ÿÿÿStd.ÿErr.ÿÿÿÿÿÿzÿÿÿÿP>|z|ÿÿÿÿÿ[95%ÿConf.ÿInterval]
      -------------+----------------------------------------------------------------
      ÿÿÿwhatever1ÿ|ÿÿÿ.0364551ÿÿÿ.0580891ÿÿÿÿÿ0.63ÿÿÿ0.530ÿÿÿÿ-.0773974ÿÿÿÿ.1503076
      ÿÿÿwhatever2ÿ|ÿÿÿ.0097939ÿÿÿ.0566459ÿÿÿÿÿ0.17ÿÿÿ0.863ÿÿÿÿÿÿ-.10123ÿÿÿÿ.1208178
      ÿÿÿÿÿÿÿ_consÿ|ÿÿÿ.3024975ÿÿÿÿ.178453ÿÿÿÿÿ1.70ÿÿÿ0.090ÿÿÿÿ-.0472639ÿÿÿÿ.6522588
      ------------------------------------------------------------------------------

      ------------------------------------------------------------------------------
      ÿÿRandom-effectsÿParametersÿÿ|ÿÿÿEstimateÿÿÿStd.ÿErr.ÿÿÿÿÿ[95%ÿConf.ÿInterval]
      -----------------------------+------------------------------------------------
      _all:ÿIdentityÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ|
      ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿvar(R.tid)ÿ|ÿÿÿ.8506707ÿÿÿÿÿÿÿÿÿÿ.ÿÿÿÿÿÿÿÿÿÿÿÿÿ.ÿÿÿÿÿÿÿÿÿÿÿ.
      -----------------------------+------------------------------------------------
      rid:ÿIdentityÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ|
      ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿvar(_cons)ÿ|ÿÿÿ.2147508ÿÿÿÿÿÿÿÿÿÿ.ÿÿÿÿÿÿÿÿÿÿÿÿÿ.ÿÿÿÿÿÿÿÿÿÿÿ.
      -----------------------------+------------------------------------------------
      ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿvar(Residual)ÿ|ÿÿÿ.2437365ÿÿÿÿÿÿÿÿÿÿ.ÿÿÿÿÿÿÿÿÿÿÿÿÿ.ÿÿÿÿÿÿÿÿÿÿÿ.
      ------------------------------------------------------------------------------

      .ÿ
      .ÿ//ÿVarianceÿcomponents
      .ÿtempnameÿVrÿVtÿVe

      .ÿscalarÿdefineÿ`Vt'ÿ=ÿexp(_b[lns1_1_1:_cons])^2ÿ//ÿTargets

      .ÿscalarÿdefineÿ`Vr'ÿ=ÿexp(_b[lns2_1_1:_cons])^2ÿ//ÿRaters

      .ÿscalarÿdefineÿ`Ve'ÿ=ÿexp(_b[lnsig_e:_cons])^2ÿ//ÿResidual

      .ÿ
      .ÿdisplayÿinÿsmclÿasÿtextÿ"ICCÿ=ÿ"ÿasÿresultÿ%04.2fÿ`Vt'ÿ/ÿ(`Vt'ÿ+ÿ`Vr'ÿ+ÿ`Ve')
      ICCÿ=ÿ0.65

      .ÿ
      .ÿexit

      endÿofÿdo-file


      .


      I could have sworn that there is a way to directly refer to the variance components as a regression coefficient, that is, _b[<something>] in one fell swoop, but I cannot find it at the moment. You can get there also via estat sd and so on, but that's no more convenient than just squaring the exponential as I've done above.

      Comment


      • #4
        Dear Joseph,

        Thank you very much!
        This is great!
        I am now however still struggling with the translation of this to the case of dichotomous dependent variables.
        `Ve' won't be there, and generally I don't seem to be able to call the scalars in the same way after running melogit.
        Do you have any suggestions how to pursue there?

        Best

        Code:
        . ***ADJUSTMENT
        . replace sco = 0 if sco < 0
        (402 real changes made)
        
        . replace sco = 1 if sco > 0
        (598 real changes made)
        
        . 
        . * Begin here
        . *
        . 
        . 
        . . melogit sco c.w* || _all: R.tid || rid: , nogroup   nolrtest nolog
        note: crossed random-effects model specified; option intmethod(laplace) implied
        HTML Code:
        Mixed-effects logistic regression               Number of obs     =      1,000
        
        Integration method:     laplace
        
                                                        Wald chi2(2)      =       2.59
        Log likelihood = -422.21191                     Prob > chi2       =     0.2741
        ------------------------------------------------------------------------------
                 sco |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
        -------------+----------------------------------------------------------------
           whatever1 |  -.1950722   .4040661    -0.48   0.629    -.9870271    .5968827
           whatever2 |   .6084129   .3975913     1.53   0.126    -.1708517    1.387677
               _cons |   .8416372   .7204371     1.17   0.243    -.5703935    2.253668
        -------------+----------------------------------------------------------------
        _all>tid     |
           var(_cons)|   10.14345   2.260062                      6.554347    15.69791
        -------------+----------------------------------------------------------------
        rid          |
           var(_cons)|   3.062974   1.464869                      1.199653    7.820434
        ------------------------------------------------------------------------------

        Comment


        • #5
          Originally posted by Johannes Muller View Post
          I am now however still struggling with the translation of this to the case of dichotomous dependent variables. Do you have any suggestions how to pursue there?
          You need to look at how the coefficient vector is labeled.

          .ÿ
          .ÿ*
          .ÿ*ÿBeginÿhere
          .ÿ*
          .ÿassertÿ!missing(sco)

          .ÿquietlyÿreplaceÿscoÿ=ÿscoÿ>ÿ0

          .ÿ
          .ÿmelogitÿscoÿc.w*ÿ||ÿ_all:ÿR.tidÿ||ÿrid:ÿ,ÿdifficultÿnogroupÿnolrtestÿnolog
          note:ÿcrossedÿrandom-effectsÿmodelÿspecified;ÿoptionÿintmethod(laplace)ÿimplied

          Mixed-effectsÿlogisticÿregressionÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿNumberÿofÿobsÿÿÿÿÿ=ÿÿÿÿÿÿ1,000

          Integrationÿmethod:ÿÿÿÿÿlaplace

          ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿWaldÿchi2(2)ÿÿÿÿÿÿ=ÿÿÿÿÿÿÿ2.47
          Logÿlikelihoodÿ=ÿ-422.21192ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿProbÿ>ÿchi2ÿÿÿÿÿÿÿ=ÿÿÿÿÿ0.2907
          ------------------------------------------------------------------------------
          ÿÿÿÿÿÿÿÿÿscoÿ|ÿÿÿÿÿÿCoef.ÿÿÿStd.ÿErr.ÿÿÿÿÿÿzÿÿÿÿP>|z|ÿÿÿÿÿ[95%ÿConf.ÿInterval]
          -------------+----------------------------------------------------------------
          ÿÿÿwhatever1ÿ|ÿÿ-.1940105ÿÿÿ.3992221ÿÿÿÿ-0.49ÿÿÿ0.627ÿÿÿÿ-.9764713ÿÿÿÿ.5884504
          ÿÿÿwhatever2ÿ|ÿÿÿ.6082802ÿÿÿ.4122425ÿÿÿÿÿ1.48ÿÿÿ0.140ÿÿÿÿ-.1997003ÿÿÿÿ1.416261
          ÿÿÿÿÿÿÿ_consÿ|ÿÿÿ.8411393ÿÿÿÿ.740902ÿÿÿÿÿ1.14ÿÿÿ0.256ÿÿÿÿÿ-.611002ÿÿÿÿ2.293281
          -------------+----------------------------------------------------------------
          _all>tidÿÿÿÿÿ|
          ÿÿÿvar(_cons)|ÿÿÿ10.14312ÿÿÿ2.283375ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ6.524584ÿÿÿÿÿ15.7685
          -------------+----------------------------------------------------------------
          ridÿÿÿÿÿÿÿÿÿÿ|
          ÿÿÿvar(_cons)|ÿÿÿ3.062783ÿÿÿ1.502697ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ1.17082ÿÿÿÿ8.012025
          ------------------------------------------------------------------------------

          .ÿ
          .ÿ//ÿVarianceÿcomponents
          .ÿtempnameÿvrÿvtÿve

          .ÿscalarÿdefineÿ`vt'ÿ=ÿ_b[/:var(_cons[_all>tid])]

          .ÿscalarÿdefineÿ`vr'ÿ=ÿ_b[/:var(_cons[rid])]

          .ÿscalarÿdefineÿ`ve'ÿ=ÿ_pi^2ÿ/ÿ3

          .ÿ
          .ÿdisplayÿinÿsmclÿasÿtextÿ"ICCÿ=ÿ"ÿasÿresultÿ%04.2fÿ`vt'ÿ/ÿ(`vt'ÿ+ÿ`vr'ÿ+ÿ`ve')
          ICCÿ=ÿ0.61

          .ÿ
          .ÿexit

          endÿofÿdo-file


          .


          Comment


          • #6
            That's fantastic, thank you very much!!

            Comment

            Working...
            X