Announcement

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

  • covariance structure in mixed model

    Dear all,

    I've been having problems selecting the correct covariance structure and for my mixed model (employees nested within firms).
    When adding a (categorical) random slope (regarding the size of the firm) to my model, my model doesn't converge (backed up) with the default (independent) covariance structure and only converges when using the cov(exchangeable) option (for the R. notation, only independent and exchangeable covariance structures are available)
    Code:
    mixed jobsat level1fixedeffects level2fixedeffects || firmid: R.size
    Did I understand it correctly, that one uses the exchangeable covariance structure only for repeated measures/panel/longitudinal data? I'm using pooled cross-sectional data, looking at firms for 2 consecutive years and treating the year variable as a fixed effect, so the observations (employees) on the first level are not the same for both years. I believe the covariance structure should therefore be independent and not exchangeable, so the non-convergence just tells me that the model is not sufficient and I shouldn't use it.

    Please tell me if you need further information in order to answer my question regarding the covariance structure.
    Your input will be greatly appreciated.

    Felicia

    Last edited by Felicia Hollingsworth; 30 Oct 2019, 05:29.

  • #2
    I just realized, covariance(identity) is the default and not covariance(independent).
    An identy covariance structure means that all variances are equal and all covariances are 0. Would that apply to my case?

    Comment


    • #3
      Does a firm's size change during the two years?

      Comment


      • #4
        The firm's size is measured as the number of employees which does change from one year to another. But since the firm's size is a categorical variable there are only a few firms (62 out of around 2000) where the size category changes during the two years.

        Comment


        • #5
          OK. But would the model look more like
          Code:
          mixed jobsat level1fixedeffects level2fixedeffects || firmid: || firmid: R.size
          .ÿ
          .ÿversionÿ16.0

          .ÿ
          .ÿclearÿ*

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

          .ÿquietlyÿsetÿobsÿ2000

          .ÿ
          .ÿgenerateÿintÿfidÿ=ÿ_n

          .ÿgenerateÿdoubleÿfid_uÿ=ÿrnormal()

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

          .ÿgenerateÿbyteÿsizÿ=ÿruniformint(1,ÿ6)

          .ÿ
          .ÿquietlyÿexpandÿ2

          .ÿbysortÿfid:ÿgenerateÿbyteÿtimÿ=ÿ_n

          .ÿquietlyÿreplaceÿsizÿ=ÿ///
          >ÿÿÿÿÿÿÿÿÿcond(sizÿ==ÿ1,ÿ2,ÿcond(sizÿ==ÿ6,ÿ5,ÿsizÿ+ÿcond(runiform()ÿ<ÿ0.5,ÿ-1,ÿ1)))ÿ///
          >ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿifÿtimÿ==ÿ2ÿ&ÿruniform()ÿ<=ÿ62ÿ/ÿ2000

          .ÿ
          .ÿquietlyÿexpandÿ100

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

          .ÿ
          .ÿgenerateÿdoubleÿrspÿ=ÿfid_uÿ+ÿ0ÿ*ÿpr2ÿ+ÿ0ÿ*ÿpr1ÿ+ÿ0ÿ*ÿtimÿ+ÿ(sizÿ-ÿ3.5)ÿ/ÿ2.5ÿ+ÿrnormal()

          .ÿ
          .ÿmixedÿrspÿc.(pr?)ÿi.timÿ||ÿfid:ÿ||ÿfid:ÿR.sizÿ,ÿnolrtestÿnolog

          Mixed-effectsÿMLÿregressionÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿNumberÿofÿobsÿÿÿÿÿ=ÿÿÿÿ400,000
          Groupÿvariable:ÿfidÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿNumberÿofÿgroupsÿÿ=ÿÿÿÿÿÿ2,000

          ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿObsÿperÿgroup:
          ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿminÿ=ÿÿÿÿÿÿÿÿ200
          ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿavgÿ=ÿÿÿÿÿÿ200.0
          ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿmaxÿ=ÿÿÿÿÿÿÿÿ200

          ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿWaldÿchi2(3)ÿÿÿÿÿÿ=ÿÿÿÿÿÿÿ1.95
          Logÿlikelihoodÿ=ÿ-573363.56ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿProbÿ>ÿchi2ÿÿÿÿÿÿÿ=ÿÿÿÿÿ0.5833

          ------------------------------------------------------------------------------
          ÿÿÿÿÿÿÿÿÿrspÿ|ÿÿÿÿÿÿCoef.ÿÿÿStd.ÿErr.ÿÿÿÿÿÿzÿÿÿÿP>|z|ÿÿÿÿÿ[95%ÿConf.ÿInterval]
          -------------+----------------------------------------------------------------
          ÿÿÿÿÿÿÿÿÿpr2ÿ|ÿÿÿ.0181535ÿÿÿ.0917332ÿÿÿÿÿ0.20ÿÿÿ0.843ÿÿÿÿ-.1616402ÿÿÿÿ.1979472
          ÿÿÿÿÿÿÿÿÿpr1ÿ|ÿÿ-.0063265ÿÿÿ.0054911ÿÿÿÿ-1.15ÿÿÿ0.249ÿÿÿÿ-.0170888ÿÿÿÿ.0044358
          ÿÿÿÿÿÿÿ2.timÿ|ÿÿÿ-.002445ÿÿÿ.0032054ÿÿÿÿ-0.76ÿÿÿ0.446ÿÿÿÿ-.0087275ÿÿÿÿ.0038376
          ÿÿÿÿÿÿÿ_consÿ|ÿÿ-.0112714ÿÿÿ.0531688ÿÿÿÿ-0.21ÿÿÿ0.832ÿÿÿÿ-.1154803ÿÿÿÿ.0929376
          ------------------------------------------------------------------------------

          ------------------------------------------------------------------------------
          ÿÿRandom-effectsÿParametersÿÿ|ÿÿÿEstimateÿÿÿStd.ÿErr.ÿÿÿÿÿ[95%ÿConf.ÿInterval]
          -----------------------------+------------------------------------------------
          fid:ÿIdentityÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ|
          ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿvar(_cons)ÿ|ÿÿÿ1.330599ÿÿÿÿ.046713ÿÿÿÿÿÿ1.242122ÿÿÿÿ1.425378
          -----------------------------+------------------------------------------------
          fid:ÿIdentityÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ|
          ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿvar(R.siz)ÿ|ÿÿÿ.0716396ÿÿÿ.0147445ÿÿÿÿÿÿÿ.047859ÿÿÿÿ.1072365
          -----------------------------+------------------------------------------------
          ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿvar(Residual)ÿ|ÿÿÿ1.000432ÿÿÿ.0022428ÿÿÿÿÿÿÿ.996046ÿÿÿÿ1.004838
          ------------------------------------------------------------------------------

          .ÿ
          .ÿexit

          endÿofÿdo-file


          .


          I'd be more inclined to make time a random slope than binned levels of headcount.

          Comment


          • #6
            Dear Joseph,
            first of all, thank you for taking the time to answer my question!

            Are you basically creating "time"/year as a third level of the multilevel model by using "firmid" as a random intercept twice?

            I would really like to keep time as a fixed effect since I don't expect a lot of change in jobsat in this short period of time (only two years).

            Could you give me any more information regarding the appropriate covariance structure for my model?

            Best regards
            Felicia

            Comment


            • #7
              Originally posted by Felicia Hollingsworth View Post
              Are you basically creating "time"/year as a third level of the multilevel model by using "firmid" as a random intercept twice?
              No. Time is in the model as a fixed effect only and, as you can see in the output, there are only two levels to the model: firm (fid) and residual. I'm not using "firmid" as a random intercept twice. The || firmid: is the intercept and the || firmid: R.size is the way that the help file says to specify "random effects among the values of a factor variable" at firmid as "a variable identifying the group structure for the random effects at that level".

              Could you give me any more information regarding the appropriate covariance structure for my model?
              Only that the R.size specification treats the variable as nominal categorical, when it seems to be that would be at least ordered. You could explore treating it as a continuous variable in the random effects specification; I don't know whether it's worth it, but in that case you would have other covariance specifications available for the relation between slope and intercept, such as the following.

              .ÿ
              .ÿversionÿ16.0

              .ÿ
              .ÿclearÿ*

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

              .ÿquietlyÿsetÿobsÿ2000

              .ÿ
              .ÿgenerateÿintÿfidÿ=ÿ_n

              .ÿgenerateÿdoubleÿfid_uÿ=ÿrnormal()

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

              .ÿgenerateÿbyteÿsizÿ=ÿruniformint(1,ÿ6)

              .ÿ
              .ÿquietlyÿexpandÿ2

              .ÿbysortÿfid:ÿgenerateÿbyteÿtimÿ=ÿ_n

              .ÿquietlyÿreplaceÿsizÿ=ÿ///
              >ÿÿÿÿÿÿÿÿÿcond(sizÿ==ÿ1,ÿ2,ÿcond(sizÿ==ÿ6,ÿ5,ÿsizÿ+ÿcond(runiform()ÿ<ÿ0.5,ÿ-1,ÿ1)))ÿ///
              >ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿifÿtimÿ==ÿ2ÿ&ÿruniform()ÿ<=ÿ62ÿ/ÿ2000

              .ÿ
              .ÿquietlyÿexpandÿ100

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

              .ÿ
              .ÿgenerateÿdoubleÿrspÿ=ÿfid_uÿ+ÿ0ÿ*ÿpr2ÿ+ÿ0ÿ*ÿpr1ÿ+ÿ0ÿ*ÿtimÿ+ÿ(sizÿ-ÿ3.5)ÿ/ÿ2.5ÿ+ÿrnormal()

              .ÿ
              .ÿmixedÿrspÿc.(pr?)ÿi.timÿ||ÿfid:ÿsizÿ,ÿcovariance(unstructured)ÿnolrtestÿnolog

              Mixed-effectsÿMLÿregressionÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿNumberÿofÿobsÿÿÿÿÿ=ÿÿÿÿ400,000
              Groupÿvariable:ÿfidÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿNumberÿofÿgroupsÿÿ=ÿÿÿÿÿÿ2,000

              ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿObsÿperÿgroup:
              ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿminÿ=ÿÿÿÿÿÿÿÿ200
              ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿavgÿ=ÿÿÿÿÿÿ200.0
              ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿmaxÿ=ÿÿÿÿÿÿÿÿ200

              ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿWaldÿchi2(3)ÿÿÿÿÿÿ=ÿÿÿÿÿÿÿ0.73
              Logÿlikelihoodÿ=ÿ-573439.43ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿProbÿ>ÿchi2ÿÿÿÿÿÿÿ=ÿÿÿÿÿ0.8651

              ------------------------------------------------------------------------------
              ÿÿÿÿÿÿÿÿÿrspÿ|ÿÿÿÿÿÿCoef.ÿÿÿStd.ÿErr.ÿÿÿÿÿÿzÿÿÿÿP>|z|ÿÿÿÿÿ[95%ÿConf.ÿInterval]
              -------------+----------------------------------------------------------------
              ÿÿÿÿÿÿÿÿÿpr2ÿ|ÿÿÿ.0609454ÿÿÿ.0876509ÿÿÿÿÿ0.70ÿÿÿ0.487ÿÿÿÿ-.1108473ÿÿÿÿ.2327381
              ÿÿÿÿÿÿÿÿÿpr1ÿ|ÿÿ-.0026804ÿÿÿÿ.005493ÿÿÿÿ-0.49ÿÿÿ0.626ÿÿÿÿ-.0134465ÿÿÿÿ.0080857
              ÿÿÿÿÿÿÿ2.timÿ|ÿÿ-.0003564ÿÿÿ.0032031ÿÿÿÿ-0.11ÿÿÿ0.911ÿÿÿÿ-.0066344ÿÿÿÿ.0059216
              ÿÿÿÿÿÿÿ_consÿ|ÿÿ-.1179158ÿÿÿ.0503641ÿÿÿÿ-2.34ÿÿÿ0.019ÿÿÿÿ-.2166277ÿÿÿÿ-.019204
              ------------------------------------------------------------------------------

              ------------------------------------------------------------------------------
              ÿÿRandom-effectsÿParametersÿÿ|ÿÿÿEstimateÿÿÿStd.ÿErr.ÿÿÿÿÿ[95%ÿConf.ÿInterval]
              -----------------------------+------------------------------------------------
              fid:ÿUnstructuredÿÿÿÿÿÿÿÿÿÿÿÿ|
              ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿvar(siz)ÿ|ÿÿÿ.1407503ÿÿÿÿ.015148ÿÿÿÿÿÿÿ.113983ÿÿÿÿ.1738035
              ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿvar(_cons)ÿ|ÿÿÿÿ2.29819ÿÿÿ.2005149ÿÿÿÿÿÿ1.936955ÿÿÿÿ2.726795
              ÿÿÿÿÿÿÿÿÿÿÿÿÿÿcov(siz,_cons)ÿ|ÿÿ-.4326777ÿÿÿ.0550258ÿÿÿÿÿ-.5405262ÿÿÿ-.3248291
              -----------------------------+------------------------------------------------
              ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿvar(Residual)ÿ|ÿÿÿ1.001045ÿÿÿ.0022442ÿÿÿÿÿÿ.9966561ÿÿÿÿ1.005453
              ------------------------------------------------------------------------------

              .ÿ
              .ÿexit

              endÿofÿdo-file


              .

              Comment

              Working...
              X