Announcement

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

  • Missing standard errors and failed lrtest in mixed

    Hi all,

    I am interested in whether (and how) my outcome variable Zadhdsev changes over time - I have 5 measurement points although not all individuals have data at all points. I am testing a series of models using mixed and have so far determined that a random linear model fits better than a fixed linear model for time, and that a quadratic term for time (time*time) is a significant predictor, as the rate of change decelerates over time. I am attempting to test whether a model with a random quadratic for time effect fits the data better, as I expect individuals to vary in their rate of deceleration in change.

    When I attempt an lrtest to compare model fit of fixed quadratic vs random quadratic, Stata says the models are not nested. I also notice that standard errors and CIs are missing for all of my my random-effects parameters in the random quadratic model. I would be grateful for any assistance in understanding what has gone wrong.

    In output below, TimeWeight is just the time variable and Time2 is this same variable, squared.


    Code:
    . ** now with fixed quadratic effect of time
    .                
    .    mixed Zadhdsev c.TimeWeight c.TimeWeight#c.TimeWeight, ///
    >            || id: TimeWeight, variance reml covariance(unstructured) ,
    
    Performing EM optimization:
    
    Performing gradient-based optimization:
    
    Iteration 0:   log restricted-likelihood = -323.47526  
    Iteration 1:   log restricted-likelihood = -321.68228  
    Iteration 2:   log restricted-likelihood = -321.66631  
    Iteration 3:   log restricted-likelihood = -321.66631  
    
    Computing standard errors:
    
    Mixed-effects REML regression                   Number of obs     =        245
    Group variable: id                              Number of groups  =         94
    
                                                    Obs per group:
                                                                  min =          1
                                                                  avg =        2.6
                                                                  max =          4
    
                                                    Wald chi2(2)      =      40.71
    Log restricted-likelihood = -321.66631          Prob > chi2       =     0.0000
    
    -------------------------------------------------------------------------------------------
                     Zadhdsev |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
    --------------------------+----------------------------------------------------------------
                   TimeWeight |  -.8046866   .1325707    -6.07   0.000     -1.06452   -.5448528
                              |
    c.TimeWeight#c.TimeWeight |   .1769486    .038914     4.55   0.000     .1006786    .2532186
                              |
                        _cons |    .435337   .0740135     5.88   0.000     .2902732    .5804009
    -------------------------------------------------------------------------------------------
    
    ------------------------------------------------------------------------------
      Random-effects Parameters  |   Estimate   Std. Err.     [95% Conf. Interval]
    -----------------------------+------------------------------------------------
    id: Unstructured             |
                   var(TimeWe~t) |   .1192109   .0439804      .0578473    .2456682
                      var(_cons) |   .0228074   .0224636      .0033091    .1571981
             cov(TimeWe~t,_cons) |    .052143   .0227641       .007526    .0967599
    -----------------------------+------------------------------------------------
                   var(Residual) |   .5197756   .0605104      .4137348    .6529948
    ------------------------------------------------------------------------------
    LR test vs. linear model: chi2(3) = 34.04                 Prob > chi2 = 0.0000
    
    Note: LR test is conservative and provided only for reference.
    
    .    
    .           estimates store fixedquadratic
    
    .          
    . ** now with random quadratic effect of time
    .
    .    mixed Zadhdsev c.TimeWeight c.Time#c.Time, ///
    >            || id: TimeWeight Time2, variance reml covariance(unstructured),  
    
    Performing EM optimization:
    
    Performing gradient-based optimization:
    
    Iteration 0:   log restricted-likelihood =  -303.8915  
    Iteration 1:   log restricted-likelihood = -300.96267  
    Iteration 2:   log restricted-likelihood = -300.85505  
    Iteration 3:   log restricted-likelihood = -300.85228  
    Iteration 4:   log restricted-likelihood = -300.85225  
    Iteration 5:   log restricted-likelihood = -300.85225  
    
    Computing standard errors:
    
    Mixed-effects REML regression                   Number of obs     =        245
    Group variable: id                              Number of groups  =         94
    
                                                    Obs per group:
                                                                  min =          1
                                                                  avg =        2.6
                                                                  max =          4
    
                                                    Wald chi2(2)      =      53.64
    Log restricted-likelihood = -300.85225          Prob > chi2       =     0.0000
    
    -------------------------------------------------------------------------------
         Zadhdsev |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
    --------------+----------------------------------------------------------------
       TimeWeight |   -1.12187   .2856026    -3.93   0.000    -1.681641   -.5620993
                  |
    c.Time#c.Time |   .1638921   .0611346     2.68   0.007     .0440704    .2837137
                  |
            _cons |   .2819303   .0747625     3.77   0.000     .1353985    .4284622
    -------------------------------------------------------------------------------
    
    ------------------------------------------------------------------------------
      Random-effects Parameters  |   Estimate   Std. Err.     [95% Conf. Interval]
    -----------------------------+------------------------------------------------
    id: Unstructured             |
                   var(TimeWe~t) |   1.521076          .             .           .
                      var(Time2) |   .1975466          .             .           .
                      var(_cons) |   .0115113          .             .           .
             cov(TimeWe~t,Time2) |  -.5266475          .             .           .
             cov(TimeWe~t,_cons) |   .1314882          .             .           .
                cov(Time2,_cons) |  -.0440412          .             .           .
    -----------------------------+------------------------------------------------
                   var(Residual) |   .2449735          .             .           .
    ------------------------------------------------------------------------------
    LR test vs. linear model: chi2(6) = 72.19                 Prob > chi2 = 0.0000
    
    Note: LR test is conservative and provided only for reference.
    
    .          
    .       estimates store randomquadratic,
    
    .       lrtest randomquadratic fixedquadratic,
    Mixed models are not nested




  • #2
    You have a variable in your dataset named Time in addition to the one named TimeWeight, and so your two models have different predictors (examine the fixed effects sections of the two regression tables), and are indeed not nested.

    Comment


    • #3
      Thanks so much for your answer and your courtesy! This error did creep in amongst my troubleshooting. However I don't see the same mistake in the log below, perhaps I am overlooking something else obvious:

      Code:
      . ** now with fixed quadratic effect of time
      .                 
      .    mixed Zadhdsev c.TimeWeight c.TimeWeight#c.TimeWeight, ///
      >            || id: TimeWeight, variance reml covariance(unstructured) , 
      
      Performing EM optimization: 
      
      Performing gradient-based optimization: 
      
      Iteration 0:   log restricted-likelihood = -323.47526  
      Iteration 1:   log restricted-likelihood = -321.68228  
      Iteration 2:   log restricted-likelihood = -321.66631  
      Iteration 3:   log restricted-likelihood = -321.66631  
      
      Computing standard errors:
      
      Mixed-effects REML regression                   Number of obs     =        245
      Group variable: id                              Number of groups  =         94
      
                                                      Obs per group:
                                                                    min =          1
                                                                    avg =        2.6
                                                                    max =          4
      
                                                      Wald chi2(2)      =      40.71
      Log restricted-likelihood = -321.66631          Prob > chi2       =     0.0000
      
      -------------------------------------------------------------------------------------------
                       Zadhdsev |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
      --------------------------+----------------------------------------------------------------
                     TimeWeight |  -.8046866   .1325707    -6.07   0.000     -1.06452   -.5448528
                                |
      c.TimeWeight#c.TimeWeight |   .1769486    .038914     4.55   0.000     .1006786    .2532186
                                |
                          _cons |    .435337   .0740135     5.88   0.000     .2902732    .5804009
      -------------------------------------------------------------------------------------------
      
      ------------------------------------------------------------------------------
        Random-effects Parameters  |   Estimate   Std. Err.     [95% Conf. Interval]
      -----------------------------+------------------------------------------------
      id: Unstructured             |
                     var(TimeWe~t) |   .1192109   .0439804      .0578473    .2456682
                        var(_cons) |   .0228074   .0224636      .0033091    .1571981
               cov(TimeWe~t,_cons) |    .052143   .0227641       .007526    .0967599
      -----------------------------+------------------------------------------------
                     var(Residual) |   .5197756   .0605104      .4137348    .6529948
      ------------------------------------------------------------------------------
      LR test vs. linear model: chi2(3) = 34.04                 Prob > chi2 = 0.0000
      
      Note: LR test is conservative and provided only for reference.
      
      .     
      .           estimates store fixedquadratic
      
      .           
      . ** now with random quadratic effect of time
      . 
      .    mixed Zadhdsev c.TimeWeight c.TimeWeight#c.TimeWeight, ///
      >            || id: TimeWeight Time2, variance reml covariance(unstructured),  
      
      Performing EM optimization: 
      
      Performing gradient-based optimization: 
      
      Iteration 0:   log restricted-likelihood = -303.69364  
      Iteration 1:   log restricted-likelihood = -300.64699  
      Iteration 2:   log restricted-likelihood = -300.50749  
      Iteration 3:   log restricted-likelihood = -300.50157  
      Iteration 4:   log restricted-likelihood = -300.50142  
      Iteration 5:   log restricted-likelihood = -300.50142  
      
      Computing standard errors:
      
      Mixed-effects REML regression                   Number of obs     =        245
      Group variable: id                              Number of groups  =         94
      
                                                      Obs per group:
                                                                    min =          1
                                                                    avg =        2.6
                                                                    max =          4
      
                                                      Wald chi2(2)      =      54.46
      Log restricted-likelihood = -300.50142          Prob > chi2       =     0.0000
      
      -------------------------------------------------------------------------------------------
                       Zadhdsev |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
      --------------------------+----------------------------------------------------------------
                     TimeWeight |  -.8193689   .1687157    -4.86   0.000    -1.150046   -.4886922
                                |
      c.TimeWeight#c.TimeWeight |   .1699047   .0610349     2.78   0.005     .0502785    .2895309
                                |
                          _cons |   .4433271   .0512699     8.65   0.000       .34284    .5438143
      -------------------------------------------------------------------------------------------
      
      ------------------------------------------------------------------------------
        Random-effects Parameters  |   Estimate   Std. Err.     [95% Conf. Interval]
      -----------------------------+------------------------------------------------
      id: Unstructured             |
                     var(TimeWe~t) |     1.5106          .             .           .
                        var(Time2) |   .1984012          .             .           .
                        var(_cons) |   .0120175          .             .           .
               cov(TimeWe~t,Time2) |   -.524842          .             .           .
               cov(TimeWe~t,_cons) |   .1324507          .             .           .
                  cov(Time2,_cons) |  -.0434717          .             .           .
      -----------------------------+------------------------------------------------
                     var(Residual) |   .2385993          .             .           .
      ------------------------------------------------------------------------------
      LR test vs. linear model: chi2(6) = 76.37                 Prob > chi2 = 0.0000
      
      Note: LR test is conservative and provided only for reference.
      
      .           
      .       estimates store randomquadratic, 
      
      .       lrtest randomquadratic fixedquadratic,
      Mixed models are not nested

      Comment


      • #4
        It seems that lrtest compares the rank of the e(V) matrix in part to determine whether the models are nested. When standard errors are missing, e(V) has correspondingly reduced rank. Take a look at the output below. I think that with nearly half of your data missing (not even a single ID has complete data) your ability to fit ambitious models is limited.

        .ÿversionÿ14.1

        .ÿ
        .ÿclearÿ*

        .ÿsetÿmoreÿoff

        .ÿsetÿseedÿ1354596

        .ÿ
        .ÿtempnameÿCorr

        .ÿmatrixÿinputÿ`Corr'ÿ=ÿ(.0115113ÿÿ.1314882ÿÿ-.0440412ÿ\ÿ///
        >ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ.1314882ÿ1.521076ÿÿÿ-.5266475ÿ\ÿ///
        >ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ-.0440412ÿ-.5266475ÿÿÿ.1975466)

        .ÿmatrixÿdefineÿ`Corr'ÿ=ÿcorr(`Corr')

        .ÿcaptureÿnoisilyÿdrawnormÿpid_uÿtim_uÿtim2_u,ÿdoubleÿcorr(`Corr')ÿn(94)
        __000000ÿnotÿpositiveÿ(semi)definite

        .ÿ
        .ÿmatrixÿrownamesÿ`Corr'ÿ=ÿAÿBÿC

        .ÿmatrixÿcolnamesÿ`Corr'ÿ=ÿAÿBÿC

        .ÿquietlyÿfactormatÿ`Corr',ÿn(94)ÿforcepsdÿÿ

        .ÿmatrixÿdefineÿ`Corr'ÿ=ÿe(C)

        .ÿ
        .ÿquietlyÿdrawnormÿpid_uÿtim_uÿtim2_u,ÿdoubleÿcorr(`Corr')ÿn(94)

        .ÿgenerateÿbyteÿpidÿ=ÿ_n

        .ÿ
        .ÿforvaluesÿtimÿ=ÿ1/5ÿ{
        ÿÿ2.ÿÿÿÿÿÿÿÿÿgenerateÿdoubleÿsev`tim'ÿ=ÿ///
        >ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ.2819303ÿ-ÿ///
        >ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ(1.12187ÿ+ÿtim_u)ÿ*ÿ`tim'ÿ+ÿÿ///
        >ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ(.1638921ÿ+ÿtim2_u)ÿ*ÿ`tim'ÿ*ÿ`tim'ÿ+ÿ///
        >ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿsqrt(.2449735)ÿ*ÿrnormal()
        ÿÿ3.ÿ}

        .ÿ
        .ÿquietlyÿreshapeÿlongÿsev,ÿi(pid)ÿj(tim)

        .ÿ
        .ÿquietlyÿdropÿifÿruniform()ÿ>ÿ2.6ÿ/ÿ5

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

        .ÿsortÿpidÿrandu

        .ÿquietlyÿbyÿpid:ÿdropÿifÿ_nÿ==ÿ5

        .ÿ
        .ÿgenerateÿbyteÿtim2ÿ=ÿtimÿ*ÿtim

        .ÿ
        .ÿmixedÿsevÿc.timÿc.tim#c.timÿ||ÿpid:ÿtimÿtim2,ÿremlÿcovariance(unstructured)ÿ///
        >ÿÿÿÿÿÿÿÿÿnolrtestÿtechnique(dfp)ÿnolog

        Mixed-effectsÿREMLÿregressionÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿNumberÿofÿobsÿÿÿÿÿ=ÿÿÿÿÿÿÿÿ240
        Groupÿvariable:ÿpidÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿNumberÿofÿgroupsÿÿ=ÿÿÿÿÿÿÿÿÿ91

        ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿObsÿperÿgroup:
        ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿminÿ=ÿÿÿÿÿÿÿÿÿÿ1
        ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿavgÿ=ÿÿÿÿÿÿÿÿ2.6
        ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿmaxÿ=ÿÿÿÿÿÿÿÿÿÿ4

        ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿWaldÿchi2(2)ÿÿÿÿÿÿ=ÿÿÿÿÿÿ76.27
        Logÿrestricted-likelihoodÿ=ÿ-522.94012ÿÿÿÿÿÿÿÿÿÿProbÿ>ÿchi2ÿÿÿÿÿÿÿ=ÿÿÿÿÿ0.0000

        ------------------------------------------------------------------------------
        ÿÿÿÿÿÿÿÿÿsevÿ|ÿÿÿÿÿÿCoef.ÿÿÿStd.ÿErr.ÿÿÿÿÿÿzÿÿÿÿP>|z|ÿÿÿÿÿ[95%ÿConf.ÿInterval]
        -------------+----------------------------------------------------------------
        ÿÿÿÿÿÿÿÿÿtimÿ|ÿÿ-1.319611ÿÿÿ.1680776ÿÿÿÿ-7.85ÿÿÿ0.000ÿÿÿÿ-1.649037ÿÿÿ-.9901847
        ÿÿÿÿÿÿÿÿÿÿÿÿÿ|
        ÿc.tim#c.timÿ|ÿÿÿÿ.069113ÿÿÿÿ.112358ÿÿÿÿÿ0.62ÿÿÿ0.538ÿÿÿÿ-.1511046ÿÿÿÿ.2893306
        ÿÿÿÿÿÿÿÿÿÿÿÿÿ|
        ÿÿÿÿÿÿÿ_consÿ|ÿÿÿ.3079608ÿÿÿ.1588541ÿÿÿÿÿ1.94ÿÿÿ0.053ÿÿÿÿ-.0033875ÿÿÿÿ.6193092
        ------------------------------------------------------------------------------

        ------------------------------------------------------------------------------
        ÿÿRandom-effectsÿParametersÿÿ|ÿÿÿEstimateÿÿÿStd.ÿErr.ÿÿÿÿÿ[95%ÿConf.ÿInterval]
        -----------------------------+------------------------------------------------
        pid:ÿUnstructuredÿÿÿÿÿÿÿÿÿÿÿÿ|
        ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿvar(tim)ÿ|ÿÿÿ.8849227ÿÿÿÿÿÿÿÿÿÿ.ÿÿÿÿÿÿÿÿÿÿÿÿÿ.ÿÿÿÿÿÿÿÿÿÿÿ.
        ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿvar(tim2)ÿ|ÿÿÿÿ1.09062ÿÿÿÿÿÿÿÿÿÿ.ÿÿÿÿÿÿÿÿÿÿÿÿÿ.ÿÿÿÿÿÿÿÿÿÿÿ.
        ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿvar(_cons)ÿ|ÿÿÿ.0115634ÿÿÿÿÿÿÿÿÿÿ.ÿÿÿÿÿÿÿÿÿÿÿÿÿ.ÿÿÿÿÿÿÿÿÿÿÿ.
        ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿcov(tim,tim2)ÿ|ÿÿÿ.9321004ÿÿÿÿÿÿÿÿÿÿ.ÿÿÿÿÿÿÿÿÿÿÿÿÿ.ÿÿÿÿÿÿÿÿÿÿÿ.
        ÿÿÿÿÿÿÿÿÿÿÿÿÿÿcov(tim,_cons)ÿ|ÿÿÿ.0936261ÿÿÿÿÿÿÿÿÿÿ.ÿÿÿÿÿÿÿÿÿÿÿÿÿ.ÿÿÿÿÿÿÿÿÿÿÿ.
        ÿÿÿÿÿÿÿÿÿÿÿÿÿcov(tim2,_cons)ÿ|ÿÿÿ.1120484ÿÿÿÿÿÿÿÿÿÿ.ÿÿÿÿÿÿÿÿÿÿÿÿÿ.ÿÿÿÿÿÿÿÿÿÿÿ.
        -----------------------------+------------------------------------------------
        ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿvar(Residual)ÿ|ÿÿÿ.2240516ÿÿÿÿÿÿÿÿÿÿ.ÿÿÿÿÿÿÿÿÿÿÿÿÿ.ÿÿÿÿÿÿÿÿÿÿÿ.
        ------------------------------------------------------------------------------

        .ÿdisplayÿinÿsmclÿasÿtextÿe(rank)
        3

        .ÿestimatesÿstoreÿFull

        .ÿ
        .ÿmixedÿsevÿc.timÿc.tim#c.timÿ||ÿpid:ÿtim,ÿremlÿcovariance(unstructured)ÿ///
        >ÿÿÿÿÿÿÿÿÿnolrtestÿtechnique(dfp)ÿnolog

        Mixed-effectsÿREMLÿregressionÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿNumberÿofÿobsÿÿÿÿÿ=ÿÿÿÿÿÿÿÿ240
        Groupÿvariable:ÿpidÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿNumberÿofÿgroupsÿÿ=ÿÿÿÿÿÿÿÿÿ91

        ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿObsÿperÿgroup:
        ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿminÿ=ÿÿÿÿÿÿÿÿÿÿ1
        ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿavgÿ=ÿÿÿÿÿÿÿÿ2.6
        ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿmaxÿ=ÿÿÿÿÿÿÿÿÿÿ4

        ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿWaldÿchi2(2)ÿÿÿÿÿÿ=ÿÿÿÿÿÿÿ2.04
        Logÿrestricted-likelihoodÿ=ÿ-730.51612ÿÿÿÿÿÿÿÿÿÿProbÿ>ÿchi2ÿÿÿÿÿÿÿ=ÿÿÿÿÿ0.3608

        ------------------------------------------------------------------------------
        ÿÿÿÿÿÿÿÿÿsevÿ|ÿÿÿÿÿÿCoef.ÿÿÿStd.ÿErr.ÿÿÿÿÿÿzÿÿÿÿP>|z|ÿÿÿÿÿ[95%ÿConf.ÿInterval]
        -------------+----------------------------------------------------------------
        ÿÿÿÿÿÿÿÿÿtimÿ|ÿÿ-1.258859ÿÿÿ.9154065ÿÿÿÿ-1.38ÿÿÿ0.169ÿÿÿÿ-3.053023ÿÿÿÿ.5353048
        ÿÿÿÿÿÿÿÿÿÿÿÿÿ|
        ÿc.tim#c.timÿ|ÿÿÿ.0460416ÿÿÿ.0960821ÿÿÿÿÿ0.48ÿÿÿ0.632ÿÿÿÿÿ-.142276ÿÿÿÿ.2343591
        ÿÿÿÿÿÿÿÿÿÿÿÿÿ|
        ÿÿÿÿÿÿÿ_consÿ|ÿÿÿÿ.289682ÿÿÿ.9577046ÿÿÿÿÿ0.30ÿÿÿ0.762ÿÿÿÿ-1.587385ÿÿÿÿ2.166748
        ------------------------------------------------------------------------------

        ------------------------------------------------------------------------------
        ÿÿRandom-effectsÿParametersÿÿ|ÿÿÿEstimateÿÿÿStd.ÿErr.ÿÿÿÿÿ[95%ÿConf.ÿInterval]
        -----------------------------+------------------------------------------------
        pid:ÿUnstructuredÿÿÿÿÿÿÿÿÿÿÿÿ|
        ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿvar(tim)ÿ|ÿÿÿ47.31035ÿÿÿ7.387998ÿÿÿÿÿÿ34.83632ÿÿÿÿ64.25102
        ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿvar(_cons)ÿ|ÿÿÿ43.14942ÿÿÿ7.886203ÿÿÿÿÿÿ30.15818ÿÿÿÿÿ61.7369
        ÿÿÿÿÿÿÿÿÿÿÿÿÿÿcov(tim,_cons)ÿ|ÿÿ-45.18201ÿÿÿ7.500161ÿÿÿÿÿ-59.88206ÿÿÿ-30.48197
        -----------------------------+------------------------------------------------
        ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿvar(Residual)ÿ|ÿÿÿ4.274706ÿÿÿ.4916205ÿÿÿÿÿÿ3.412025ÿÿÿÿ5.355503
        ------------------------------------------------------------------------------

        .ÿdisplayÿinÿsmclÿasÿtextÿe(rank)
        7

        .ÿestimatesÿstoreÿReduced

        .ÿ
        .ÿcaptureÿnoisilyÿlrtestÿFullÿReduced
        Mixedÿmodelsÿareÿnotÿnested

        .ÿ
        .ÿlrtestÿFullÿReduced,ÿstatsÿdirÿforce

        Likelihood-ratioÿtestÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿLRÿchi2(4)ÿÿ=ÿÿÿ-415.15
        (Assumption:ÿFullÿnestedÿinÿReduced)ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿProbÿ>ÿchi2ÿ=ÿÿÿÿ1.0000

        Akaike'sÿinformationÿcriterionÿandÿBayesianÿinformationÿcriterion

        -----------------------------------------------------------------------------
        ÿÿÿÿÿÿÿModelÿ|ÿÿÿÿÿÿÿÿObsÿÿll(null)ÿÿll(model)ÿÿÿÿÿÿdfÿÿÿÿÿÿÿÿÿAICÿÿÿÿÿÿÿÿBIC
        -------------+---------------------------------------------------------------
        ÿÿÿÿÿÿÿÿFullÿ|ÿÿÿÿÿÿÿÿ240ÿÿÿÿÿÿÿÿÿ.ÿÿ-522.9401ÿÿÿÿÿÿÿ3ÿÿÿÿÿ1051.88ÿÿÿ1062.322
        ÿÿÿÿÿReducedÿ|ÿÿÿÿÿÿÿÿ240ÿÿÿÿÿÿÿÿÿ.ÿÿ-730.5161ÿÿÿÿÿÿÿ7ÿÿÿÿ1475.032ÿÿÿ1499.397
        -----------------------------------------------------------------------------
        ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿNote:ÿN=ObsÿusedÿinÿcalculatingÿBIC;ÿseeÿ[R]ÿBICÿnote.

        -----------------------------------------------------------------------------
        ÿÿÿÿÿÿÿÿnameÿ|ÿcommandÿÿÿÿÿÿdepvarÿÿÿÿÿÿÿnparÿÿtitleÿ
        -------------+---------------------------------------------------------------
        ÿÿÿÿÿÿÿÿFullÿ|ÿmixedÿÿÿÿÿÿÿÿsevÿÿÿÿÿÿÿÿÿÿÿÿ10ÿÿ
        ÿÿÿÿÿReducedÿ|ÿmixedÿÿÿÿÿÿÿÿsevÿÿÿÿÿÿÿÿÿÿÿÿÿ7ÿÿ
        -----------------------------------------------------------------------------

        .ÿ
        .ÿexit

        endÿofÿdo-file


        .

        Comment


        • #5
          Thanks again Joseph, your response is extremely helpful.

          This dataset combines several studies with slightly different methodology - the missingness is due to different follow-up timepoints employed in the different studies. These different timepoints were one of the main reasons for choosing the mixed analysis - but I am learning that even this flexible modelling approach has its limits! For the outcome variable I'm looking at here, almost no participants were present at timepoint 5. Rerunning the models above without this timepoint does seem to help, in that Stata is able to estimate the SEs and CIs for the quadratic random term - which it estimates as close to zero (if I am interpreting the output below correctly).

          I think I may be best off reporting analyses using only timepoints 1-4 for this dataset, explaining that I only have "power" to draw conclusions about those timepoints. Thanks again for your assistance.

          Code:
          . use ADHD_forSTATA_6.dta, clear  
          
          . do "e:\Users\User\AppData\Local\Temp\STD02000000.tmp"
          
          . drop if TimeWeight==5  
          (94 observations deleted)
          
          . ** with fixed quadratic effect of time
          .                
          .    mixed Zadhdsev c.TimeWeight c.TimeWeight#c.TimeWeight, ///
          >            || id: TimeWeight, variance reml ,  
          
          Performing EM optimization:
          
          Performing gradient-based optimization:
          
          Iteration 0:   log restricted-likelihood = -312.98904  
          Iteration 1:   log restricted-likelihood = -312.37548  
          Iteration 2:   log restricted-likelihood = -312.36807  
          Iteration 3:   log restricted-likelihood = -312.36801  
          Iteration 4:   log restricted-likelihood = -312.36801  
          
          Computing standard errors:
          
          Mixed-effects REML regression                   Number of obs     =        240
          Group variable: id                              Number of groups  =         94
          
                                                          Obs per group:
                                                                        min =          1
                                                                        avg =        2.6
                                                                        max =          3
          
                                                          Wald chi2(2)      =      35.40
          Log restricted-likelihood = -312.36801          Prob > chi2       =     0.0000
          
          -------------------------------------------------------------------------------------------
                           Zadhdsev |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
          --------------------------+----------------------------------------------------------------
                         TimeWeight |    -.85331   .1584297    -5.39   0.000    -1.163826   -.5427936
                                    |
          c.TimeWeight#c.TimeWeight |   .1995946   .0531643     3.75   0.000     .0953945    .3037948
                                    |
                              _cons |   .4439978   .0744561     5.96   0.000     .2980666    .5899291
          -------------------------------------------------------------------------------------------
          
          ------------------------------------------------------------------------------
            Random-effects Parameters  |   Estimate   Std. Err.     [95% Conf. Interval]
          -----------------------------+------------------------------------------------
          id: Independent              |
                         var(TimeWe~t) |    .185344   .0617508      .0964684    .3561002
                            var(_cons) |   .0143414   .0575982      5.47e-06    37.60162
          -----------------------------+------------------------------------------------
                         var(Residual) |   .5112925   .0669631      .3955387    .6609215
          ------------------------------------------------------------------------------
          LR test vs. linear model: chi2(2) = 31.61                 Prob > chi2 = 0.0000
          
          Note: LR test is conservative and provided only for reference.
          
          .    
          .           estimates store fixedquadratic
          
          .          
          . ** with random quadratic effect of time
          .
          .    mixed Zadhdsev c.TimeWeight c.TimeWeight#c.TimeWeight, ///
          >            || id: TimeWeight Time2, variance reml ,  
          
          Performing EM optimization:
          
          Performing gradient-based optimization:
          
          Iteration 0:   log restricted-likelihood = -314.84243  
          Iteration 1:   log restricted-likelihood = -313.58683  (not concave)
          Iteration 2:   log restricted-likelihood = -313.34629  
          Iteration 3:   log restricted-likelihood = -312.80253  (not concave)
          Iteration 4:   log restricted-likelihood = -312.79579  
          Iteration 5:   log restricted-likelihood = -312.38335  
          Iteration 6:   log restricted-likelihood = -312.36804  
          Iteration 7:   log restricted-likelihood = -312.36801  
          
          Computing standard errors:
          
          Mixed-effects REML regression                   Number of obs     =        240
          Group variable: id                              Number of groups  =         94
          
                                                          Obs per group:
                                                                        min =          1
                                                                        avg =        2.6
                                                                        max =          3
          
                                                          Wald chi2(2)      =      35.40
          Log restricted-likelihood = -312.36801          Prob > chi2       =     0.0000
          
          -------------------------------------------------------------------------------------------
                           Zadhdsev |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
          --------------------------+----------------------------------------------------------------
                         TimeWeight |    -.85331   .1584294    -5.39   0.000    -1.163826   -.5427941
                                    |
          c.TimeWeight#c.TimeWeight |   .1995947   .0531642     3.75   0.000     .0953947    .3037946
                                    |
                              _cons |   .4439979   .0744562     5.96   0.000     .2980665    .5899292
          -------------------------------------------------------------------------------------------
          
          ------------------------------------------------------------------------------
            Random-effects Parameters  |   Estimate   Std. Err.     [95% Conf. Interval]
          -----------------------------+------------------------------------------------
          id: Independent              |
                         var(TimeWe~t) |   .1853431   .0724627      .0861363    .3988106
                            var(Time2) |   6.05e-11   3.25e-10      1.60e-15    2.29e-06
                            var(_cons) |   .0143439   .0599285      3.98e-06    51.63814
          -----------------------------+------------------------------------------------
                         var(Residual) |   .5112912    .067057       .395395    .6611582
          ------------------------------------------------------------------------------
          LR test vs. linear model: chi2(3) = 31.61                 Prob > chi2 = 0.0000
          
          Note: LR test is conservative and provided only for reference.
          
          .          
          .       estimates store randomquadratic,
          
          .       lrtest randomquadratic fixedquadratic,
          
          Likelihood-ratio test                                 LR chi2(1)  =     -0.00
          (Assumption: fixedquadratic nested in randomquadra~c) Prob > chi2 =    1.0000
          
          Note: The reported degrees of freedom assumes the null hypothesis is not on the boundary of the parameter space.  If this is not true, then the
                reported test is conservative.
          Note: LR tests based on REML are valid only when the fixed-effects specification is identical for both models.

          Comment


          • #6
            Sorry the above is not correct (can't seem to edit the post) - if I don't specify the covariance (unstructured), Stata is able to estimate standard deviations and CIs for the random slope model. I am now trying to understand why this would be and whether such a model could be validly interpreted - with the covariance of random effects of time and time2 set to independent.


            Code:
             
            . ** with fixed quadratic effect of time
            .                 
            .    mixed Zadhdsev c.TimeWeight c.TimeWeight#c.TimeWeight, ///
            >            || id: TimeWeight, variance reml  ,  
            
            Performing EM optimization: 
            
            Performing gradient-based optimization: 
            
            Iteration 0:   log restricted-likelihood = -324.18032  
            Iteration 1:   log restricted-likelihood = -323.62384  
            Iteration 2:   log restricted-likelihood = -323.61995  
            Iteration 3:   log restricted-likelihood = -323.61994  
            
            Computing standard errors:
            
            Mixed-effects REML regression                   Number of obs     =        245
            Group variable: id                              Number of groups  =         94
            
                                                            Obs per group:
                                                                          min =          1
                                                                          avg =        2.6
                                                                          max =          4
            
                                                            Wald chi2(2)      =      37.49
            Log restricted-likelihood = -323.61994          Prob > chi2       =     0.0000
            
            -------------------------------------------------------------------------------------------
                             Zadhdsev |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
            --------------------------+----------------------------------------------------------------
                           TimeWeight |   -.807402    .137762    -5.86   0.000    -1.077411   -.5373935
                                      |
            c.TimeWeight#c.TimeWeight |   .1779952   .0408094     4.36   0.000     .0980103    .2579802
                                      |
                                _cons |   .4363222   .0748976     5.83   0.000     .2895255    .5831189
            -------------------------------------------------------------------------------------------
            
            ------------------------------------------------------------------------------
              Random-effects Parameters  |   Estimate   Std. Err.     [95% Conf. Interval]
            -----------------------------+------------------------------------------------
            id: Independent              |
                           var(TimeWe~t) |   .1596324   .0522684      .0840257    .3032704
                              var(_cons) |    .020473    .057904      .0000801    5.231715
            -----------------------------+------------------------------------------------
                           var(Residual) |   .5329602   .0685051      .4142703     .685655
            ------------------------------------------------------------------------------
            LR test vs. linear model: chi2(2) = 30.13                 Prob > chi2 = 0.0000
            
            Note: LR test is conservative and provided only for reference.
            
            .     
            .           estimates store fixedquadratic
            
            .           
            . ** with random quadratic effect of time
            . 
            .    mixed Zadhdsev c.TimeWeight c.TimeWeight#c.TimeWeight, ///
            >            || id: TimeWeight Time2, variance reml ,  
            
            Performing EM optimization: 
            
            Performing gradient-based optimization: 
            
            Iteration 0:   log restricted-likelihood = -325.41072  
            Iteration 1:   log restricted-likelihood = -323.78791  
            Iteration 2:   log restricted-likelihood = -323.58873  
            Iteration 3:   log restricted-likelihood = -323.58531  
            Iteration 4:   log restricted-likelihood = -323.58492  
            Iteration 5:   log restricted-likelihood = -323.58492  
            
            Computing standard errors:
            
            Mixed-effects REML regression                   Number of obs     =        245
            Group variable: id                              Number of groups  =         94
            
                                                            Obs per group:
                                                                          min =          1
                                                                          avg =        2.6
                                                                          max =          4
            
                                                            Wald chi2(2)      =      38.10
            Log restricted-likelihood = -323.58492          Prob > chi2       =     0.0000
            
            -------------------------------------------------------------------------------------------
                             Zadhdsev |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
            --------------------------+----------------------------------------------------------------
                           TimeWeight |  -.8132938   .1383407    -5.88   0.000    -1.084437   -.5421509
                                      |
            c.TimeWeight#c.TimeWeight |   .1803178   .0416943     4.32   0.000     .0985985    .2620372
                                      |
                                _cons |   .4375082   .0749533     5.84   0.000     .2906025     .584414
            -------------------------------------------------------------------------------------------
            
            ------------------------------------------------------------------------------
              Random-effects Parameters  |   Estimate   Std. Err.     [95% Conf. Interval]
            -----------------------------+------------------------------------------------
            id: Independent              |
                           var(TimeWe~t) |    .152581   .0589074      .0715936     .325182
                              var(Time2) |   .0010521   .0041784      4.38e-07    2.527282
                              var(_cons) |   .0263405   .0622204       .000257    2.699579
            -----------------------------+------------------------------------------------
                           var(Residual) |    .525984   .0726976      .4011675    .6896351
            ------------------------------------------------------------------------------
            LR test vs. linear model: chi2(3) = 30.20                 Prob > chi2 = 0.0000
            
            Note: LR test is conservative and provided only for reference.
            
            .           
            .       estimates store randomquadratic, 
            
            .       lrtest randomquadratic fixedquadratic,
            
            Likelihood-ratio test                                 LR chi2(1)  =      0.07
            (Assumption: fixedquadratic nested in randomquadra~c) Prob > chi2 =    0.7913

            Comment

            Working...
            X