Announcement

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

  • McDonald and Moffit Decomposition

    Hello,

    I'm trying to do the McDonald and Moffit calculation, and I'm getting an error message with the below command.

    ​​​​​​mkmat one ib0.age_categories ib1.education ib6.income gender_binary_female ib0.political_affiliation_t_other gn_sus_q1 gn_sus_q3 gn_sus_q4, matrix(X)

    factor-variable and time-series operators not allowed
    r(101);

    What could I be doing wrong?

  • #2
    If you want to export indicators from a categorical variable, you have to generate these beforehand. For example:

    Code:
    sysuse auto, clear
    tab rep78, gen(repair)
    sum repair*
    Res.:

    Code:
    . tab rep78, gen(repair)
    
         Repair |
    record 1978 |      Freq.     Percent        Cum.
    ------------+-----------------------------------
              1 |          2        2.90        2.90
              2 |          8       11.59       14.49
              3 |         30       43.48       57.97
              4 |         18       26.09       84.06
              5 |         11       15.94      100.00
    ------------+-----------------------------------
          Total |         69      100.00
    
    .
    . sum repair*
    
        Variable |        Obs        Mean    Std. dev.       Min        Max
    -------------+---------------------------------------------------------
         repair1 |         69    .0289855    .1689948          0          1
         repair2 |         69     .115942    .3225009          0          1
         repair3 |         69    .4347826    .4993602          0          1
         repair4 |         69    .2608696    .4423259          0          1
         repair5 |         69    .1594203    .3687494          0          1
    So "repair1" would correspond to 1.repair in factor variable notation, "repair2" to 2.repair, and so on. Assuming that you do not want to export the bases, you leave out one indicator per categorical variable.

    Comment


    • #3
      Thank you so much Andrew, it worked. Your help is much appreciated.



      Comment


      • #4
        Originally posted by Andrew Musau View Post
        If you want to export indicators from a categorical variable, you have to generate these beforehand. For example:

        Code:
        sysuse auto, clear
        tab rep78, gen(repair)
        sum repair*
        Res.:

        Code:
        . tab rep78, gen(repair)
        
        Repair |
        record 1978 | Freq. Percent Cum.
        ------------+-----------------------------------
        1 | 2 2.90 2.90
        2 | 8 11.59 14.49
        3 | 30 43.48 57.97
        4 | 18 26.09 84.06
        5 | 11 15.94 100.00
        ------------+-----------------------------------
        Total | 69 100.00
        
        .
        . sum repair*
        
        Variable | Obs Mean Std. dev. Min Max
        -------------+---------------------------------------------------------
        repair1 | 69 .0289855 .1689948 0 1
        repair2 | 69 .115942 .3225009 0 1
        repair3 | 69 .4347826 .4993602 0 1
        repair4 | 69 .2608696 .4423259 0 1
        repair5 | 69 .1594203 .3687494 0 1
        So "repair1" would correspond to 1.repair in factor variable notation, "repair2" to 2.repair, and so on. Assuming that you do not want to export the bases, you leave out one indicator per categorical variable.
        As a follow up question - I'd like to know how the figures in the example command were determined. They are part of the McDonald and Moffit calculation example hughlighted in my earlier qustion: matrix beta = b[1,5],b[1,1], b[1,2],b[1,3],b[1,4]. I understand that figures represent rows and columns for elements of the matrix b, but how do I determine the number and ordering of the elements?

        Comment


        • #5
          If interested, see https://www.statalist.org/forums/for...=1704534914599.

          Comment

          Working...
          X