Announcement

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

  • irt rsm and group analysis

    I am trying to do the IRT group analysis on my data. I am using Stata 15 on Mac.

    The problem is that when I try to run the following group analysis, I get an error message "variable type not found (error in option group()) r(111);"

    The code I tried to run is as follows: irt rsm q1 q2 q3 q4 q5 q6 q7 q8 q9 q10, group(type) or irt rsm q1 q2 q3 q4 q5 q6 q7 q8 q9 q10, group(group)

    My data consists of 10 items in 5-point Likert scale. The data includes a 'type' variable indicating who completed the survey (direct report, parent support/direct report, parent-report). The data looks like this. I have recoded group variable into type, to make it numerical just in case.

    input byte(q1 q2 q3 q4 q5 q6 q7 q8 q9 q10) str7 group type
    5 4 4 4 4 5 4 4 4 4 "direct" 0
    2 5 5 5 4 4 5 5 5 4 "direct" 0
    5 1 5 1 5 5 5 5 5 5 "direct" 0
    4 4 4 4 4 5 4 3 3 5 "direct" 0
    5 5 5 5 5 5 4 5 5 5 "direct" 0
    5 4 4 4 4 3 4 22 5 "direct" 0
    4 4 4 4 4 4 4 4 3 4 "direct" 0
    5 2 4 4 5 4 5 4 4 4 "direct" 0
    4 3 4 3 4 4 1 4 4 3 "support" 1
    5 5 4 4 4 4 3 4 4 3 "direct" 0
    5 5 5 5 5 2 5 5 5 5 "direct" 0
    5 4 2 4 5 5 3 4 5 4 "direct" 0
    5 4 5 5 5 5 5 5 2 5 "direct" 0
    4 3 4 3 5 4 4 4 4 5 "direct" 0
    4 5 3 3 4 1 4 3 5 4 "direct" 0
    3 5 3 5 4 4 3 4 4 5 "direct" 0
    4 3 1 4 4 5 3 4 4 3 "direct" 0
    5 4 4 4 3 5 3 4 1 5 "direct" 0
    4 3 4 4 3 4 5 4 4 4 "direct" 0
    4 1 4 5 3 5 3 4 3 5 "parent" 2


    The code "irt rsm q1 q2 q3 q4 q5 q6 q7 q8 q9 q10" does work.

    When I tried to run by type (sort: irt rsm q1 q2 q3 q4 q5 q6 q7 q8 q9 q10)

    Everything runs fine with the group, direct. Then when it comes to -> group = parent, I get an error message that says

    variable _one not allowed
    Variable _one is reserved for internal use by irt rsm. drop or rename the existing variable _one
    and rerun the command.
    r(110);



    That said, I tried to run the group analysis with the web data to figure out what I was doing wrong. Then I still get the same error message. The codes I tried were

    webuse masc2

    irt 2pl q1 q2 q3 q4 q5 q6 q7 q8 q9 , group(female)

    And then I get this error message:

    variable female not found
    (error in option group())
    r(111);

    Could someone enlighten me on how to handle this?

  • #2
    webuse masc2, clear
    irt 2pl q1 q2 q3 q4 q5 q6 q7 q8 q9, group(female)
    This works for me on StataNow 18.5 and Stata 16. The command irt has undergone several bug fixes, a number involving the -group()- option, see

    Code:
    help whatsnew
    So I suggest that you first update your installation and try again.

    Code:
    update all
    Then you can repost if this does not solve it.

    Res.:

    Code:
    . webuse masc2, clear
    (Data from De Boeck & Wilson (2004))
    
    . irt 2pl q1 q2 q3 q4 q5 q6 q7 q8 q9 , group(female)
    
    Fitting fixed-effects model:
    
    Iteration 0:  Log likelihood = -8035.4481  
    Iteration 1:  Log likelihood = -8024.3465  
    Iteration 2:  Log likelihood = -8024.3398  
    Iteration 3:  Log likelihood = -8024.3398  
    
    Group: Male
    
    Group: Female
    
    Fitting full model:
    
    Iteration 0:  Log likelihood = -7809.4118  
    Iteration 1:  Log likelihood = -7793.3376  
    Iteration 2:  Log likelihood = -7766.6178  
    Iteration 3:  Log likelihood = -7764.3054  
    Iteration 4:  Log likelihood = -7764.1855  
    Iteration 5:  Log likelihood = -7764.1853  
    
    Two-parameter logistic model                             Number of obs = 1,500
    Log likelihood = -7764.1853
    
    Group: Male
    
    ------------------------------------------------------------------------------
                 | Coefficient  Std. err.      z    P>|z|     [95% conf. interval]
    -------------+----------------------------------------------------------------
    q1           |
         Discrim |   1.281117   .1505808     8.51   0.000     .9859843     1.57625
            Diff |  -.5776251   .0765588    -7.54   0.000    -.7276777   -.4275725
    -------------+----------------------------------------------------------------
    q2           |
         Discrim |   .7533139   .0988723     7.62   0.000     .5595277       .9471
            Diff |  -.0807525   .0842077    -0.96   0.338    -.2457965    .0842916
    -------------+----------------------------------------------------------------
    q3           |
         Discrim |   .9011866   .1237182     7.28   0.000     .6587034     1.14367
            Diff |  -1.736271   .1993548    -8.71   0.000    -2.126999   -1.345542
    -------------+----------------------------------------------------------------
    q4           |
         Discrim |   .7783182   .0985258     7.90   0.000     .5852111    .9714253
            Diff |   .3609076   .0967343     3.73   0.000     .1713118    .5505033
    -------------+----------------------------------------------------------------
    q5           |
         Discrim |   1.185248   .1474891     8.04   0.000     .8961747    1.474321
            Diff |   1.354557   .1480597     9.15   0.000     1.064365    1.644748
    -------------+----------------------------------------------------------------
    q6           |
         Discrim |   .9917891   .1177473     8.42   0.000     .7610086     1.22257
            Diff |    .687201   .1006604     6.83   0.000     .4899102    .8844917
    -------------+----------------------------------------------------------------
    q7           |
         Discrim |   .5875935   .0949878     6.19   0.000     .4014208    .7737663
            Diff |   1.617197   .2697513     6.00   0.000     1.088494      2.1459
    -------------+----------------------------------------------------------------
    q8           |
         Discrim |   1.198906   .1561803     7.68   0.000      .892798    1.505014
            Diff |  -1.765274    .169059   -10.44   0.000    -2.096624   -1.433925
    -------------+----------------------------------------------------------------
    q9           |
         Discrim |    .657975   .0990875     6.64   0.000     .4637672    .8521829
            Diff |  -1.542599   .2106254    -7.32   0.000    -1.955417   -1.129781
    -------------+----------------------------------------------------------------
      mean(Theta)|          0  (omitted)
    -------------+----------------------------------------------------------------
       var(Theta)|          1  (constrained)
    ------------------------------------------------------------------------------
    
    Group: Female
    
    ------------------------------------------------------------------------------
                 | Coefficient  Std. err.      z    P>|z|     [95% conf. interval]
    -------------+----------------------------------------------------------------
    q1           |
         Discrim |   1.281117   .1505808     8.51   0.000     .9859843     1.57625
            Diff |  -.5776251   .0765588    -7.54   0.000    -.7276777   -.4275725
    -------------+----------------------------------------------------------------
    q2           |
         Discrim |   .7533139   .0988723     7.62   0.000     .5595277       .9471
            Diff |  -.0807525   .0842077    -0.96   0.338    -.2457965    .0842916
    -------------+----------------------------------------------------------------
    q3           |
         Discrim |   .9011866   .1237182     7.28   0.000     .6587034     1.14367
            Diff |  -1.736271   .1993548    -8.71   0.000    -2.126999   -1.345542
    -------------+----------------------------------------------------------------
    q4           |
         Discrim |   .7783182   .0985258     7.90   0.000     .5852111    .9714253
            Diff |   .3609076   .0967343     3.73   0.000     .1713118    .5505033
    -------------+----------------------------------------------------------------
    q5           |
         Discrim |   1.185248   .1474891     8.04   0.000     .8961747    1.474321
            Diff |   1.354557   .1480597     9.15   0.000     1.064365    1.644748
    -------------+----------------------------------------------------------------
    q6           |
         Discrim |   .9917891   .1177473     8.42   0.000     .7610086     1.22257
            Diff |    .687201   .1006604     6.83   0.000     .4899102    .8844917
    -------------+----------------------------------------------------------------
    q7           |
         Discrim |   .5875935   .0949878     6.19   0.000     .4014208    .7737663
            Diff |   1.617197   .2697513     6.00   0.000     1.088494      2.1459
    -------------+----------------------------------------------------------------
    q8           |
         Discrim |   1.198906   .1561803     7.68   0.000      .892798    1.505014
            Diff |  -1.765274    .169059   -10.44   0.000    -2.096624   -1.433925
    -------------+----------------------------------------------------------------
    q9           |
         Discrim |    .657975   .0990875     6.64   0.000     .4637672    .8521829
            Diff |  -1.542599   .2106254    -7.32   0.000    -1.955417   -1.129781
    -------------+----------------------------------------------------------------
      mean(Theta)|  -.2156589   .0675521    -3.19   0.001    -.3480587   -.0832592
    -------------+----------------------------------------------------------------
       var(Theta)|    .793737   .1167097                      .5950007    1.058853
    ------------------------------------------------------------------------------

    Comment


    • #3
      If you are still having trouble after updating, per Andrew's suggestion, you can use the user-written program uirt (Stata Journal article). It is more flexible than Stata's irt commands. The author of uirt, Bartosz Kondratek, is on Statalist. Some code to get you started, mostly pulled from the SJ article, which is fantastic:
      Code:
      ssc install uirt
      webuse masc2, clear
      
      *** Single-group 2PL - loadings (discrimination) unique as are the intercepts (difficulties)
      uirt q*                
      estimates store two_plm_1gr
      
      *Inspect model fit at an item level
      uirt_chi2w q*        // q6 is a problem, probably should investigate a 3PL (guessing parameter) model
      
      *** Group-specific model for the latent traits (DIF test for 2PL model based on sex)
      uirt q*, init(from(two_plm_1gr)) group(female)
      estimates store two_plm_2gr
      
      *Examine item-level DIF using likelihood ratio testing 
      uirt_dif *, cleargraphs // can get group-specific ICC and PDF graphs by removing cleargraphs option
      ,

      Comment


      • #4
        Thanks for the kind words, Erik Ruzek. I am very happy you find this tool useful.
        So Kang, the RSM is not implemented in uirt. If you’re fine with a more liberal approach to thresholds, the closest you can get with uirt is PCM.
        The code to fit multi-group PCM to your data would be:
        Code:
        uirt q*, gr(type) pcm(q*)
        Or, should want to specify a different reference group than the default lowest value of the grouping variable:
        Code:
        uirt q*, gr(type,ref(2)) pcm(q*)
        The good thing with uirt is that it is written mostly in mata. The estimation commands should work fine even with Stata 10.
        Last edited by Bartosz Kondratek; 12 Sep 2024, 15:14.

        Comment


        • #5
          Thank you so much! I updated the Stata, and it now works fine! I also found the uirt very helpful! All of your help was so invaluable, and thank you again!

          Comment

          Working...
          X