Announcement

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

  • Glmm

    Hi
    I have the following design : 65 participants have to label emotional faces. the hit rate (0 or 1) is the DV. I'm trying to fit a glmm model with predictors (intensity: continuous, emotion : categorical, testX: continous and all their interaction. in the fixed effect part I also include a depression measure to control for (GDS : continuous). for the random part (not really funny to understand with stata), i want the random intercept for subject (N) and for stimuli (stim). all subject have been exposed to all stimuli. all continuous IV have been centered around the mean I wrote the following syntax:
    xtmelogit Hit c.GDS c.testX##i.emotion##c.intensity || N:|| FSTIM:,
    1. i'm not sure to have written the correct syntax for my design.
    2. i haven't the same result as R despite many test. Hit ~ GDS + testX * emotion * intensity + (1 | N)+(1|Stim)
    3. does the syntax take into account the repeated measurement?
    4: i'm puzzled by the random effect :
    ----------------------------------------------------------------------------
    | No. of Observations per Group Integration
    Group Variable | Groups Minimum Average Maximum Points
    ----------------+-----------------------------------------------------------
    N | 64 40 40.0 40 1
    FSTIM | 2,560 1 1.0 1 1
    ----------------------------------------------------------------------------
    indeed, it s like the soft consider that their is 2560 stimuli as, in reality, their is 40 stimuli that 64 participants have experienced. could you help me to correct my syntax? i have tried many things and the problem remain the same.
    thanks a lot
    carole

  • #2
    Hello Carole,

    Welcome to the Stata Forum,

    I kindly suggest you to present the commands and output under CODE delimiters or with the SCC - dataex - as recommended in the FAQ.

    When I type - help xtmelogit - in Stata 14,2, I get this message:

    xtmelogit has been renamed to meqrlogit. xtmelogit continues to work but, as of Stata 13, is no longer an official part of Stata. This is the original help file, which we will no
    longer update, so some links may no longer work.
    That said, and just wondering, a potential cause of difference between the commands in R and Stata may be due to the default covariance. Perhaps you could try to select the same structure for both softwares (plus integrations points and other sort of options, including restrictions),and see what happens.

    Best,

    Marcos

    Edited: on second thoughts, shall you have really chosen the name "N" for your id variable, my advice is: try to choose a different name,
    Last edited by Marcos Almeida; 30 Dec 2016, 05:56.
    Best regards,

    Marcos

    Comment


    • #3
      thanks Marcos
      , I corrected my post. i have change xtmelogit by melogit (same results). the model if a glmm with binomial distribution and logit link.


      Hi
      I have the following design : 65 participants have to label emotional faces. the hit rate (0 or 1) is the DV. I'm trying to fit a glmm model with predictors (intensity: continuous, emotion : categorical, testX: continous and all their interaction. in the fixed effect part I also include a depression measure to control for (GDS : continuous). for the random part (not really funny to understand with stata), i want the random intercept for subject (N) and for stimuli (stim). all subject have been exposed to all stimuli. all continuous IV have been centered around the mean I wrote the following syntax:

      1. i'm not sure to have written the correct syntax for my design.
      2. i haven't the same result as R despite many test. Hit ~ GDS + testX * emotion * intensity + (1 | N)+(1|Stim)
      3. does the syntax take into account the repeated measurement?
      4: i'm puzzled by the random effect. see above for partial data set, syntax and results for random effect. indeed, it s like the soft consider that their is 2560 stimuli as, in reality, their is 40 stimuli that 64 participants have experienced. could you help me to correct my syntax? i have tried many things and the problem remain the same.
      thanks a lot
      carole.

      Code:
      input byte Hit str9 emo float(intc GDSc MMSEc) str2 N byte STIM
      0 "Joie"      -2  0 1.84375 "B"  2
      1 "Joie"      -2  0 1.84375 "B"  1
      1 "Joie"      -1  0 1.84375 "B"  4
      1 "Joie"      -1  0 1.84375 "B"  3
      1 "Joie"       0  0 1.84375 "B"  6
      1 "Joie"       0  0 1.84375 "B"  5
      1 "Joie"       1  0 1.84375 "B"  8
      1 "Joie"       1  0 1.84375 "B"  7
      1 "Joie"       2  0 1.84375 "B" 10
      1 "Joie"       2  0 1.84375 "B"  9
      0 "colere"    -2  0 1.84375 "B" 22
      1 "colere"    -2  0 1.84375 "B" 21
      0 "colere"    -1  0 1.84375 "B" 24
      0 "colere"    -1  0 1.84375 "B" 23
      1 "colere"     0  0 1.84375 "B" 26
      0 "colere"     0  0 1.84375 "B" 25
      1 "colere"     1  0 1.84375 "B" 28
      1 "colere"     1  0 1.84375 "B" 27
      1 "colere"     2  0 1.84375 "B" 30
      1 "colere"     2  0 1.84375 "B" 29
      1 "peur"      -2  0 1.84375 "B" 32
      0 "peur"      -2  0 1.84375 "B" 31
      1 "peur"      -1  0 1.84375 "B" 34
      0 "peur"      -1  0 1.84375 "B" 33
      0 "peur"       0  0 1.84375 "B" 36
      0 "peur"       0  0 1.84375 "B" 35
      0 "peur"       1  0 1.84375 "B" 38
      0 "peur"       1  0 1.84375 "B" 37
      0 "peur"       2  0 1.84375 "B" 40
      1 "peur"       2  0 1.84375 "B" 39
      1 "tristesse" -2  0 1.84375 "B" 12
      1 "tristesse" -2  0 1.84375 "B" 11
      0 "tristesse" -1  0 1.84375 "B" 14
      0 "tristesse" -1  0 1.84375 "B" 13
      0 "tristesse"  0  0 1.84375 "B" 16
      1 "tristesse"  0  0 1.84375 "B" 15
      0 "tristesse"  1  0 1.84375 "B" 18
      1 "tristesse"  1  0 1.84375 "B" 17
      0 "tristesse"  2  0 1.84375 "B" 20
      1 "tristesse"  2  0 1.84375 "B" 19
      1 "Joie"      -2  2 1.84375 "D"  2
      0 "Joie"      -2  2 1.84375 "D"  1
      1 "Joie"      -1  2 1.84375 "D"  4
      1 "Joie"      -1  2 1.84375 "D"  3
      1 "Joie"       0  2 1.84375 "D"  6
      1 "Joie"       0  2 1.84375 "D"  5
      0 "Joie"       1  2 1.84375 "D"  8
      1 "Joie"       1  2 1.84375 "D"  7
      1 "Joie"       2  2 1.84375 "D" 10
      1 "Joie"       2  2 1.84375 "D"  9
      0 "colere"    -2  2 1.84375 "D" 22
      0 "colere"    -2  2 1.84375 "D" 21
      0 "colere"    -1  2 1.84375 "D" 24
      0 "colere"    -1  2 1.84375 "D" 23
      0 "colere"     0  2 1.84375 "D" 26
      1 "colere"     0  2 1.84375 "D" 25
      0 "colere"     1  2 1.84375 "D" 28
      1 "colere"     1  2 1.84375 "D" 27
      1 "colere"     2  2 1.84375 "D" 30
      1 "colere"     2  2 1.84375 "D" 29
      0 "peur"      -2  2 1.84375 "D" 32
      0 "peur"      -2  2 1.84375 "D" 31
      1 "peur"      -1  2 1.84375 "D" 34
      0 "peur"      -1  2 1.84375 "D" 33
      1 "peur"       0  2 1.84375 "D" 36
      1 "peur"       0  2 1.84375 "D" 35
      0 "peur"       1  2 1.84375 "D" 38
      1 "peur"       1  2 1.84375 "D" 37
      0 "peur"       2  2 1.84375 "D" 40
      1 "peur"       2  2 1.84375 "D" 39
      1 "tristesse" -2  2 1.84375 "D" 12
      1 "tristesse" -2  2 1.84375 "D" 11
      1 "tristesse" -1  2 1.84375 "D" 14
      0 "tristesse" -1  2 1.84375 "D" 13
      0 "tristesse"  0  2 1.84375 "D" 16
      0 "tristesse"  0  2 1.84375 "D" 15
      1 "tristesse"  1  2 1.84375 "D" 18
      1 "tristesse"  1  2 1.84375 "D" 17
      0 "tristesse"  2  2 1.84375 "D" 20
      0 "tristesse"  2  2 1.84375 "D" 19
      Code:
      melogit Hit c.GDSc c.MMSEc##i.emo##c.intc || N: || STIM:
      Code:
      ----------------------------------------------------------------------------
      | No. of Observations per Group Integration
      Group Variable | Groups Minimum Average Maximum Points
      ----------------+-----------------------------------------------------------
      N | 64 40 40.0 40 1
      FSTIM | 2,560 1 1.0 1 1
      ----------------------------------------------------------------------------
      Last edited by carole fantini; 30 Dec 2016, 07:58.

      Comment


      • #4
        Hello Carole,

        There are a lot of "issues" to talk about. For example, when you say the GDS is continuous, but in your data set we have sort of 2 categories (actually integers = 0 or 2). You said you 65 participants, but I failed to reach this number. You seem to be using commands for string variables, but I need to encode them so as to perform the estimations.

        What is more, if I decide to emulate your commands (making some arrangements so as to encode string variables), I got several omissions due to collinearity, plus an output the differ much from your, plus a deceptive LR test ( let alone a different number of group and "STIM" not "FSTIM").

        Code:
        . melogit Hit c.GDSc c.MMSEc##i.emo2##c.intc || N: || STIM:, nolog
        note: MMSEc omitted because of collinearity
        note: 2.emo2#c.MMSEc omitted because of collinearity
        note: 3.emo2#c.MMSEc omitted because of collinearity
        note: 4.emo2#c.MMSEc omitted because of collinearity
        note: c.MMSEc#c.intc omitted because of collinearity
        note: 2.emo2#c.MMSEc#c.intc omitted because of collinearity
        note: 3.emo2#c.MMSEc#c.intc omitted because of collinearity
        note: 4.emo2#c.MMSEc#c.intc omitted because of collinearity
        
        Mixed-effects logistic regression               Number of obs     =         80
        
        -------------------------------------------------------------
                        |     No. of       Observations per Group
         Group Variable |     Groups    Minimum    Average    Maximum
        ----------------+--------------------------------------------
                      N |          2         40       40.0         40
                   STIM |         80          1        1.0          1
        -------------------------------------------------------------
        
        Integration method: mvaghermite                 Integration pts.  =          7
        
                                                        Wald chi2(8)      =      14.43
        Log likelihood = -43.095631                     Prob > chi2       =     0.0712
        -------------------------------------------------------------------------------------
                        Hit |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
        --------------------+----------------------------------------------------------------
                       GDSc |  -.0684121   .2616565    -0.26   0.794    -.5812493    .4444251
                      MMSEc |          0  (omitted)
                            |
                       emo2 |
                    colere  |  -2.040644   .9949219    -2.05   0.040    -3.990656   -.0906332
                      peur  |  -2.448669   .9275235    -2.64   0.008    -4.266582   -.6307562
                 tristesse  |  -2.040616   .9316535    -2.19   0.029    -3.866623   -.2146081
                            |
               emo2#c.MMSEc |
                    colere  |          0  (omitted)
                      peur  |          0  (omitted)
                 tristesse  |          0  (omitted)
                            |
                       intc |   .6795973   .5504379     1.23   0.217    -.3992412    1.758436
                            |
             c.MMSEc#c.intc |          0  (omitted)
                            |
                emo2#c.intc |
                    colere  |   .5702623   .7604951     0.75   0.453    -.9202807    2.060805
                      peur  |  -.5749683   .6389448    -0.90   0.368    -1.827277    .6773404
                 tristesse  |  -1.099587   .6470339    -1.70   0.089     -2.36775    .1685761
                            |
        emo2#c.MMSEc#c.intc |
                    colere  |          0  (omitted)
                      peur  |          0  (omitted)
                 tristesse  |          0  (omitted)
                            |
                      _cons |   2.108984   .8517766     2.48   0.013     .4395326    3.778436
        --------------------+----------------------------------------------------------------
        N                   |
                  var(_cons)|   1.94e-37   1.27e-17                             .           .
        --------------------+----------------------------------------------------------------
        N>STIM              |
                  var(_cons)|   2.90e-33   9.70e-17                             .           .
        -------------------------------------------------------------------------------------
        LR test vs. logistic model: chi2(0) = 0.00                Prob > chi2 =      .
        
        Note: LR test is conservative and provided only for reference.
        IMHO, it seems you'd need to tackle several issues: selection of a feasible model,checking power, perform the modeling, tackle collinearity, etc. Also, I fear 2 intercepts might be pushing too much the envelope, so to speak

        All in all, that is the furthest I can go, and I may be wrong.

        Hopefully you will get better advice and a more optimistic note from other members.

        Best,

        Marcos
        Best regards,

        Marcos

        Comment


        • #5
          Hi marcos
          thanks a lot for your response. as the data i have post are partial you haven't the full picture :-)
          GDS is continuous scores ranging from -1 to 2. for a reason I ignore, the analysis take into account only 64 participants. but that does not change anything. the colliearity you found is a non sens as MMSE is a cognitive ability measurement while emo is just the type of emotion that were displayed (a participant obtain a hit score of one if he identifies correctly the emotion : joie, colere tristesse and so on).
          I don(t understand what you are meaning by "You seem to be using commands for string variables, but I need to encode them so as to perform the estimations.".
          for more precision : there is 64 participants exposed to 40 stimuli (each participant respond to the 40 stimuli : 40 observations per participant).
          do you need the full dataset?

          Comment


          • #6
            here is the output with the entire dataset and with your syntax (except for emo i have coded to be in long format. i forgot to tell you that).
            Code:
             melogit Hit c.GDSc c.MMSEc##i.newemo##c.intc || N: || STIM:, nolog
            
            Mixed-effects logistic regression               Number of obs     =      2,560
            
            -------------------------------------------------------------
                            |     No. of       Observations per Group
             Group Variable |     Groups    Minimum    Average    Maximum
            ----------------+--------------------------------------------
                     Ngroup |         64         40       40.0         40
                       STIM |      2,560          1        1.0          1
            -------------------------------------------------------------
            
            Integration method: mvaghermite                 Integration pts.  =          7
            
                                                            Wald chi2(16)     =     433.22
            Log likelihood =  -1200.834                     Prob > chi2       =     0.0000
            ---------------------------------------------------------------------------------------
                              Hit |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
            ----------------------+----------------------------------------------------------------
                             GDSc |  -.1334586   .0952473    -1.40   0.161    -.3201398    .0532227
                            MMSEc |   .1889655   .0555955     3.40   0.001     .0800004    .2979307
                                  |
                           newemo |
                          colere  |  -2.415649   .2795107    -8.64   0.000     -2.96348   -1.867818
                            peur  |  -2.926784   .2727128   -10.73   0.000    -3.461291   -2.392277
                       tristesse  |  -1.689988   .2742862    -6.16   0.000    -2.227579   -1.152397
                                  |
                   newemo#c.MMSEc |
                          colere  |  -.1044189   .0569005    -1.84   0.066    -.2159418    .0071041
                            peur  |  -.1145069   .0559525    -2.05   0.041    -.2241718   -.0048419
                       tristesse  |   -.075316   .0560538    -1.34   0.179    -.1851795    .0345475
                                  |
                             intc |   1.477818   .1619829     9.12   0.000     1.160337    1.795299
                                  |
                   c.MMSEc#c.intc |   .0655936    .032835     2.00   0.046     .0012382    .1299489
                                  |
                    newemo#c.intc |
                          colere  |  -.2504206   .1864805    -1.34   0.179    -.6159157    .1150745
                            peur  |  -.8929869   .1744227    -5.12   0.000    -1.234849   -.5511247
                       tristesse  |  -1.472039    .176522    -8.34   0.000    -1.818016   -1.126062
                                  |
            newemo#c.MMSEc#c.intc |
                          colere  |   .0351182    .039545     0.89   0.375    -.0423886     .112625
                            peur  |   -.022006   .0376856    -0.58   0.559    -.0958686    .0518565
                       tristesse  |   -.090689   .0378453    -2.40   0.017    -.1648645   -.0165135
                                  |
                            _cons |   2.982943   .2715379    10.99   0.000     2.450738    3.515147
            ----------------------+----------------------------------------------------------------
            Ngroup                |
                        var(_cons)|   .4705301   .1177494                      .2881215    .7684209
            ----------------------+----------------------------------------------------------------
            Ngroup>STIM           |
                        var(_cons)|   2.15e-32   5.26e-17                             .           .
            ---------------------------------------------------------------------------------------
            LR test vs. logistic model: chibar2(01) = 89.80       Prob >= chibar2 = 0.0000
            the problem with random effect remains. normally we would find : N: 64 and STIM : 40....

            Comment


            • #7
              I am less familiar with R. However, your Stata command asked for levels of stimuli nested within individuals.

              I think your R syntax did not ask for this nesting. I think this is crossed random effects, rather than nested. I haven't encountered a situation where I needed crossed random effects, but I think this is one. Can anyone else confirm?

              If I am right, Carole's correct syntax should be melogit Hit (independent variables) || N: R.STIM
              Be aware that it can be very hard to answer a question without sample data. You can use the dataex command for this. Type help dataex at the command line.

              When presenting code or results, please use the code delimiters format them. Use the # button on the formatting toolbar, between the " (double quote) and <> buttons.

              Comment


              • #8
                HI Weiwen
                i'm thinking that you are right. the design seems to be completely crossed rather than nested. I will try your syntax and post the results.

                Comment


                • #9
                  If crossed random effects model is what you are looking for, that is the correct syntax:
                  Code:
                   melogit Hit c.GDSc c.MMSEc##i.emo2##c.intc || _all:R.N || STIM:, nolog

                  Comment


                  • #10
                    Many thanks ! I think it s ok now.
                    Code:
                    -------------------------------------------------------------
                                    |     No. of       Observations per Group
                     Group Variable |     Groups    Minimum    Average    Maximum
                    ----------------+--------------------------------------------
                               _all |          1      2,560    2,560.0      2,560
                               STIM |         40         64       64.0         64
                    -------------------------------------------------------------

                    Comment


                    • #11
                      I'm trying to plot the three way interaction. but despite reading the manual i encounter some problems I can't resolve. curiously, it s not possible to select margins at negative value of an IV (as they are centered I necessarily have negative values. second, I would like to plot the predicted values. I have launch predict but but but : very time consuming indeed (running since 45 minutes and no results yet). when I add predict in the marginplot command, the soft tells me that the syntax is invalid. you will find the two codes below.
                      for margins with negative values (it s ok for int but not for MMSEc (the real value is -10.83 but that give me an error message too :
                      Code:
                       margins i.newemo, at(int=(-2(1)2) MMSEc(-11(1)4))
                      for plot predicted values for the two way interaction model : give an error : invalid statistic (maybe it's because I need to compute all predict values before??)
                      Code:
                      margins i.newemo, at(int=(-2(1)2)), predict(Hit)
                      thanks

                      Comment


                      • #12
                        any ideas?

                        Comment

                        Working...
                        X