Announcement

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

  • #16
    I have decided to use MI. but, if i have well understood, I need to use the long data format, estimates the missing values with MI procedures with 20 imputations, and then to compute the mixed analysis?? thanks a lot

    Comment


    • #17
      Actually, for longitudinal data, you need to first reshape wide, do the imputations (so that missing values can be imputed based on the values of the same variables at different times, as well as values of other variables) and then -mi reshape- back to long for analysis with -mi estimate: mixed-.

      Comment


      • #18
        Hi Clyde thanks a lot. i have done this analysis but unfortunately the code you provide to me to compute margins and graph (piecewise) does not function anymore. this code does not find the estimates ("last estimates not found"). Is that possible that this code is not compatible with MI??

        Comment


        • #19
          It is not compatible with -mi-. There is a command -mimrgns-, written by Dan Klein and available from SSC that you can use instead. I do not know if you can use -marginsplot- afterwards. But if I remember the earlier part of this thread correctly, you are doing the graphics by "brute force" because of some splines anyway, am I right?

          Comment


          • #20
            Hi Clyde, "brute force"? what does it mean? :-). yes there was splines as we compare the change in slope between each knots...

            Comment


            • #21
              By "brute force" I mean that you were using the -saving()- option of -margins- to create a data set containing the -margins- output, and then using -graph twoway- to graph the data from that.

              Comment


              • #22
                if i have correctly understand your graph code, inside this one, there is indeed a saving options after margins. I have tried to change the command inside this code by replacing margins by mimrgns, but the saving option seems not allowed...further I think that there is a problem with the mi estimation as computing two differents mixed analysis (a simple model and then adding a covariates) lead to the same beta coef ! curious.....
                Last edited by carole fantini; 07 Nov 2018, 22:51.

                Comment


                • #23
                  I'm afraid I don't know what to advise you from here. You might have to hand enter the -mimrgns- output into a data set and then use -graph twoway- commands. Ugh! Before doing that, you might want to see if somebody else chimes in here with a better idea.

                  Comment


                  • #24
                    i'm wondering if its not easier to delete all missing cases. the final sample would be 66 with 5 complete time points that would be sufficient to run a mixed model?

                    Comment


                    • #25
                      thanks a lot for your helpful advices. as researcher in psychology, it appears that we need to develop high competencies in statistics which is not easy at all. i spent more time on that than on my own theories !

                      Comment


                      • #26
                        i'm wondering if its not easier to delete all missing cases. the final sample would be 66 with 5 complete time points that would be sufficient to run a mixed model?
                        No, I wouldn't do that. Throwing out an entire case because some time points are missing is likely to be worse, from a perspective of statistical bias, than running -mixed- with the incomplete cases included. If it gets too cumbersome to do the analysis with multiple imputation or sem/fiml, then just stick with the data as you found it. Don't go throwing out the incomplete cases: that will "look nice" to somebody who doesn't know that the apparently clean data set was eviscerated to make it look that way. But the results will be less valid, not more.

                        Comment


                        • #27
                          yes I'm totally agree with this. i have tried using SEM with fiml but the piecewise part is still impossible to understand the how to !. so i will keep my mixed model. or eventually, try to understand why after the correct MI, using a mixed model without covariates leads to the same parameters than a model with covariate (do you have seen that??)...I don 't trust my results for this reason . thanks clyde

                          Comment


                          • #28
                            Hi, Finally I have ran a mixed model without mi but with missing data . I join the results table below..
                            Code:
                            . mixed dep ibn.porteur#ibn.Pathologie ibn.porteur#ibn.Pathologie#c.(time1 time2 time3 time4)supp1c reeval1c, nocons|| ID: time1 time2 t
                            > ime3 time4 supp1c reeval1c 
                            
                            Performing EM optimization: 
                            
                            Performing gradient-based optimization: 
                            
                            Iteration 0:   log likelihood = -1356.3037  
                            Iteration 1:   log likelihood = -1351.7574  (not concave)
                            Iteration 2:   log likelihood = -1351.0334  (not concave)
                            Iteration 3:   log likelihood = -1349.6367  
                            Iteration 4:   log likelihood = -1349.5312  
                            Iteration 5:   log likelihood = -1349.5285  
                            Iteration 6:   log likelihood = -1349.5285  
                            
                            Computing standard errors:
                            
                            Mixed-effects ML regression                     Number of obs     =        387
                            Group variable: ID                              Number of groups  =         90
                            
                                                                            Obs per group:
                                                                                          min =          3
                                                                                          avg =        4.3
                                                                                          max =          5
                            
                                                                            Wald chi2(22)     =     385.60
                            Log likelihood = -1349.5285                     Prob > chi2       =     0.0000
                            
                            --------------------------------------------------------------------------------------------
                                                   dep |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
                            ---------------------------+----------------------------------------------------------------
                                    porteur#Pathologie |
                                    Non-carrier#HNPCC  |   9.300779    3.19851     2.91   0.004     3.031815    15.56974
                                     Non-carrier#HBOC  |    16.5451   2.915174     5.68   0.000     10.83146    22.25873
                                        Carrier#HNPCC  |   8.292023    3.16029     2.62   0.009     2.097968    14.48608
                                         Carrier#HBOC  |   15.35469   4.109438     3.74   0.000     7.300343    23.40904
                                                       |
                            porteur#Pathologie#c.time1 |
                                    Non-carrier#HNPCC  |   .5756573   1.885673     0.31   0.760    -3.120195    4.271509
                                     Non-carrier#HBOC  |  -3.553386   1.692951    -2.10   0.036    -6.871508   -.2352635
                                        Carrier#HNPCC  |       .625   1.820133     0.34   0.731    -2.942395    4.192395
                                         Carrier#HBOC  |   3.428571   2.383114     1.44   0.150    -1.242245    8.099388
                                                       |
                            porteur#Pathologie#c.time2 |
                                    Non-carrier#HNPCC  |   2.135634   3.351745     0.64   0.524    -4.433666    8.704933
                                     Non-carrier#HBOC  |   5.787661   2.910465     1.99   0.047     .0832541    11.49207
                                        Carrier#HNPCC  |  -1.915165   3.182915    -0.60   0.547    -8.153563    4.323233
                                         Carrier#HBOC  |  -14.52791   4.298384    -3.38   0.001    -22.95258   -6.103229
                                                       |
                            porteur#Pathologie#c.time3 |
                                    Non-carrier#HNPCC  |    1.66274   3.602458     0.46   0.644    -5.397947    8.723427
                                     Non-carrier#HBOC  |   1.034114   3.075379     0.34   0.737    -4.993518    7.061746
                                        Carrier#HNPCC  |   6.464014   3.419251     1.89   0.059    -.2375941    13.16562
                                         Carrier#HBOC  |   19.19499   4.940314     3.89   0.000      9.51215    28.87783
                                                       |
                            porteur#Pathologie#c.time4 |
                                    Non-carrier#HNPCC  |  -9.257999   3.749942    -2.47   0.014    -16.60775   -1.908247
                                     Non-carrier#HBOC  |   -5.52982   3.279388    -1.69   0.092     -11.9573     .897663
                                        Carrier#HNPCC  |  -9.569818   3.865905    -2.48   0.013    -17.14685   -1.992784
                                         Carrier#HBOC  |  -11.07056   4.944365    -2.24   0.025    -20.76134    -1.37978
                                                       |
                                                supp1c |    .435818    .163011     2.67   0.008     .1163223    .7553136
                                              reeval1c |    .209674   .1162549     1.80   0.071    -.0181813    .4375294
                            --------------------------------------------------------------------------------------------
                            
                            ------------------------------------------------------------------------------
                              Random-effects Parameters  |   Estimate   Std. Err.     [95% Conf. Interval]
                            -----------------------------+------------------------------------------------
                            ID: Independent              |
                                              var(time1) |   1.25e-11          .             .           .
                                              var(time2) |   3.28e-10          .             .           .
                                              var(time3) |   6.531154          .             .           .
                                              var(time4) |   2.51e-11          .             .           .
                                             var(supp1c) |     .46321          .             .           .
                                           var(reeval1c) |   .1255643          .             .           .
                                              var(_cons) |   20.76603          .             .           .
                            -----------------------------+------------------------------------------------
                                           var(Residual) |   39.75461          .             .           .
                            ------------------------------------------------------------------------------
                            LR test vs. linear model: chi2(7) = 126.93                Prob > chi2 = 0.0000
                            If I have well understood, each interaction between time knots (mkspline, marginal) tells us that, for example,the slope for Carrier#HBOC#time4 is different from the slope of the knots for Carrier#HBOC#time3..correct?
                            If so, I have searched by reading a lot to understand all three ways interactions for piecewise regression but very difficult when using marginal mkspline. So, I would like to test difference between pathology (HNPCC or HBOC) for carrier at time 1, 2...., but also to test for difference between carrier and non carrier at time 1, 2 etc...by pathology...I'm not sure, but it seems that lincom do that...but I don't understand the difference with the contrast command ( ex: contrast porteur#c.(time1 time2 time3 time4)@Pathologie, pveffects).
                            here is the data:
                            Code:
                            input byte(dep porteur Pathologie time1 time2 time3 time4) double(supp1c reeval1c) str6 ID
                             1 1 1 1 0 0 0  -10.54444408416748 -21.288888931274414 "040003"
                             0 1 1 2 0 0 0  -10.54444408416748 -21.288888931274414 "040003"
                             0 1 1 3 1 0 0  -10.54444408416748 -21.288888931274414 "040003"
                             6 1 1 4 2 1 0  -10.54444408416748 -21.288888931274414 "040003"
                             0 1 1 5 3 2 1  -10.54444408416748 -21.288888931274414 "040003"
                             9 0 1 1 0 0 0   .4555555582046509   3.711111068725586 "040004"
                             0 0 1 2 0 0 0   .4555555582046509   3.711111068725586 "040004"
                             6 0 1 3 1 0 0   .4555555582046509   3.711111068725586 "040004"
                             6 0 1 4 2 1 0   .4555555582046509   3.711111068725586 "040004"
                             1 0 1 5 3 2 1   .4555555582046509   3.711111068725586 "040004"
                             4 0 2 1 0 0 0   .4555555582046509  -3.288888931274414 "040009"
                            15 0 2 2 0 0 0   .4555555582046509  -3.288888931274414 "040009"
                             9 0 2 3 1 0 0   .4555555582046509  -3.288888931274414 "040009"
                            21 0 2 4 2 1 0   .4555555582046509  -3.288888931274414 "040009"
                             . 0 2 5 3 2 1   .4555555582046509  -3.288888931274414 "040009"
                             4 1 2 1 0 0 0                   .                   . "30013" 
                             1 1 2 2 0 0 0                   .                   . "30013" 
                             . 1 2 3 1 0 0                   .                   . "30013" 
                            15 1 2 4 2 1 0                   .                   . "30013" 
                             . 1 2 5 3 2 1                   .                   . "30013" 
                            15 0 2 1 0 0 0  -10.54444408416748  -1.288888931274414 "30014" 
                             7 0 2 2 0 0 0  -10.54444408416748  -1.288888931274414 "30014" 
                             7 0 2 3 1 0 0  -10.54444408416748  -1.288888931274414 "30014" 
                            13 0 2 4 2 1 0  -10.54444408416748  -1.288888931274414 "30014" 
                            15 0 2 5 3 2 1  -10.54444408416748  -1.288888931274414 "30014" 
                            29 1 2 1 0 0 0   .4555555582046509  10.711111068725586 "30015" 
                            42 1 2 2 0 0 0   .4555555582046509  10.711111068725586 "30015" 
                             . 1 2 3 1 0 0   .4555555582046509  10.711111068725586 "30015" 
                            28 1 2 4 2 1 0   .4555555582046509  10.711111068725586 "30015" 
                            14 1 2 5 3 2 1   .4555555582046509  10.711111068725586 "30015" 
                             8 0 2 1 0 0 0  -.5444444417953491   8.711111068725586 "30017" 
                             4 0 2 2 0 0 0  -.5444444417953491   8.711111068725586 "30017" 
                            11 0 2 3 1 0 0  -.5444444417953491   8.711111068725586 "30017" 
                             . 0 2 4 2 1 0  -.5444444417953491   8.711111068725586 "30017" 
                             . 0 2 5 3 2 1  -.5444444417953491   8.711111068725586 "30017" 
                             4 1 2 1 0 0 0   -9.54444408416748  -.2888889014720917 "30018" 
                             0 1 2 2 0 0 0   -9.54444408416748  -.2888889014720917 "30018" 
                             1 1 2 3 1 0 0   -9.54444408416748  -.2888889014720917 "30018" 
                            16 1 2 4 2 1 0   -9.54444408416748  -.2888889014720917 "30018" 
                             0 1 2 5 3 2 1   -9.54444408416748  -.2888889014720917 "30018" 
                             9 1 2 1 0 0 0  -6.544444561004639   1.711111068725586 "30020" 
                            15 1 2 2 0 0 0  -6.544444561004639   1.711111068725586 "30020" 
                            13 1 2 3 1 0 0  -6.544444561004639   1.711111068725586 "30020" 
                            18 1 2 4 2 1 0  -6.544444561004639   1.711111068725586 "30020" 
                             . 1 2 5 3 2 1  -6.544444561004639   1.711111068725586 "30020" 
                            22 1 2 1 0 0 0    8.45555591583252 -11.288888931274414 "30021" 
                            11 1 2 2 0 0 0    8.45555591583252 -11.288888931274414 "30021" 
                             . 1 2 3 1 0 0    8.45555591583252 -11.288888931274414 "30021" 
                             . 1 2 4 2 1 0    8.45555591583252 -11.288888931274414 "30021" 
                             4 1 2 5 3 2 1    8.45555591583252 -11.288888931274414 "30021" 
                             6 0 2 1 0 0 0  1.4555555582046509  -7.288888931274414 "30022" 
                             7 0 2 2 0 0 0  1.4555555582046509  -7.288888931274414 "30022" 
                             8 0 2 3 1 0 0  1.4555555582046509  -7.288888931274414 "30022" 
                             9 0 2 4 2 1 0  1.4555555582046509  -7.288888931274414 "30022" 
                             . 0 2 5 3 2 1  1.4555555582046509  -7.288888931274414 "30022" 
                            18 0 1 1 0 0 0   5.455555438995361   3.711111068725586 "30023" 
                            17 0 1 2 0 0 0   5.455555438995361   3.711111068725586 "30023" 
                             . 0 1 3 1 0 0   5.455555438995361   3.711111068725586 "30023" 
                            25 0 1 4 2 1 0   5.455555438995361   3.711111068725586 "30023" 
                            18 0 1 5 3 2 1   5.455555438995361   3.711111068725586 "30023" 
                             5 1 2 1 0 0 0 -3.5444445610046387  -2.288888931274414 "30025" 
                            14 1 2 2 0 0 0 -3.5444445610046387  -2.288888931274414 "30025" 
                             7 1 2 3 1 0 0 -3.5444445610046387  -2.288888931274414 "30025" 
                            11 1 2 4 2 1 0 -3.5444445610046387  -2.288888931274414 "30025" 
                            16 1 2 5 3 2 1 -3.5444445610046387  -2.288888931274414 "30025" 
                            11 0 2 1 0 0 0   4.455555438995361   .7111111283302307 "30026" 
                             7 0 2 2 0 0 0   4.455555438995361   .7111111283302307 "30026" 
                             8 0 2 3 1 0 0   4.455555438995361   .7111111283302307 "30026" 
                            11 0 2 4 2 1 0   4.455555438995361   .7111111283302307 "30026" 
                            16 0 2 5 3 2 1   4.455555438995361   .7111111283302307 "30026" 
                             9 1 2 1 0 0 0  2.4555554389953613  -4.288888931274414 "30028" 
                            15 1 2 2 0 0 0  2.4555554389953613  -4.288888931274414 "30028" 
                             5 1 2 3 1 0 0  2.4555554389953613  -4.288888931274414 "30028" 
                             8 1 2 4 2 1 0  2.4555554389953613  -4.288888931274414 "30028" 
                            13 1 2 5 3 2 1  2.4555554389953613  -4.288888931274414 "30028" 
                            11 0 2 1 0 0 0  -10.54444408416748  13.711111068725586 "30029" 
                             7 0 2 2 0 0 0  -10.54444408416748  13.711111068725586 "30029" 
                             8 0 2 3 1 0 0  -10.54444408416748  13.711111068725586 "30029" 
                            10 0 2 4 2 1 0  -10.54444408416748  13.711111068725586 "30029" 
                             . 0 2 5 3 2 1  -10.54444408416748  13.711111068725586 "30029" 
                            22 0 2 1 0 0 0   4.455555438995361  -8.288888931274414 "30031" 
                            10 0 2 2 0 0 0   4.455555438995361  -8.288888931274414 "30031" 
                             7 0 2 3 1 0 0   4.455555438995361  -8.288888931274414 "30031" 
                            11 0 2 4 2 1 0   4.455555438995361  -8.288888931274414 "30031" 
                            10 0 2 5 3 2 1   4.455555438995361  -8.288888931274414 "30031" 
                            11 1 2 1 0 0 0                   .                   . "30034" 
                             . 1 2 2 0 0 0                   .                   . "30034" 
                             6 1 2 3 1 0 0                   .                   . "30034" 
                            10 1 2 4 2 1 0                   .                   . "30034" 
                            15 1 2 5 3 2 1                   .                   . "30034" 
                            30 0 2 1 0 0 0 -2.5444445610046387   4.711111068725586 "30036" 
                             1 0 2 2 0 0 0 -2.5444445610046387   4.711111068725586 "30036" 
                            22 0 2 3 1 0 0 -2.5444445610046387   4.711111068725586 "30036" 
                             7 0 2 4 2 1 0 -2.5444445610046387   4.711111068725586 "30036" 
                             1 0 2 5 3 2 1 -2.5444445610046387   4.711111068725586 "30036" 
                            35 1 2 1 0 0 0  -.5444444417953491   6.711111068725586 "30038" 
                            51 1 2 2 0 0 0  -.5444444417953491   6.711111068725586 "30038" 
                            13 1 2 3 1 0 0  -.5444444417953491   6.711111068725586 "30038" 
                            35 1 2 4 2 1 0  -.5444444417953491   6.711111068725586 "30038" 
                            42 1 2 5 3 2 1  -.5444444417953491   6.711111068725586 "30038"
                            thanks a lot for your help

                            Comment


                            • #29
                              If I have well understood, each interaction between time knots (mkspline, marginal) tells us that, for example,the slope for Carrier#HBOC#time4 is different from the slope of the knots for Carrier#HBOC#time3..correct?
                              Well, it would mean that, except that your model is not correctly specified. It contains a three way interaction among porteur, Pathologie, and time. So it needs to include all the included "main" effects as well as all lower-degree interactions. But you omitted all of the "main" effects and you omitted the porteur interactions with time. Consequently, your results are uninterpretable. The correct model would be more like:

                              Code:
                              mixed dep ibn.porteur##ibn.Pathologie##c.(time1 time2 time3 time4) ///
                                  supp1c reeval1c, nocons|| ID: time1 time2 time3 time4 supp1c reeval1c
                              Note that it is better to use the ## operator when specifying interaction terms in regression commands, because then Stata automatically takes care of the "main" effects and the included lower-order interactions. And Stata will never forget any of them. (Stata will, of course, omit some of them if they are empty or colinear with something else, but that's OK.)

                              As for looking for effects of carrier status by pathology at different times, yes, that can be done with -lincom-, but it is much easier, and less error-prone, to do it with -margins-. I highly recommend the excellent Richard Williams' https://www3.nd.edu/~rwilliam/stats/Margins01.pdf for an especially clear introduction to the -margins- command. From there, it will be easier to read the -margins- chapter of the PDF documentation so that you will also learn about some of its more advanced features, such as calculating marginal effects, and the use of -at()- options, and the -pwcontrast- option.



                              Comment


                              • #30
                                Hello Clyde, Yes I understand that omitting main effects as well as lower ordered interaction is problematic. Sometimes I see that in papers but I was not convinced at all intuitively. I have opt for this because my sample size is not very large for such model even with five time point I suppose. Thanks for the reference provided. best journey :-)

                                Comment

                                Working...
                                X