Announcement

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

  • Panels are not nested within clusters - DiD model

    Dear,

    I read a lot of the threads before posting this question, however, did not seem to get an answer to it. I have longitudinal data (workers in the UK labour market). The data follow individuals for 5 consecutive quarters. I want to run a regression of Difference in difference (DiD) with fixed effects, however, I want to have robust and clustered standard errors at the individual level. I tried using the following:

    Code:
     xtset ID qtr
    xtdidregress (SUMHRS AGE SEX) (afterCovid19), group (ZHC) time (qtr)
    where :
    ID is the id of each individual (panel variable)
    qtr is the time variable (quarterly)
    SUMHRS is the outcome variable
    afterCovid19 is the dummy variable ( treatment intervention) indicate : 1= if period after covid. 0= if period pefore covid
    ZHC is a group of works which indicate 1 = if the workers treated 0 = not treated

    However, when I run the regression, it provides the error "ID not nested within ZHC".
    I’m not sure where the problem is in the data or in my model.

    Any insights on what I could do?

    Many thanks in advance!

  • #2
    Ali:
    the reason is that the same id moves from 0 to 1 across subsequent -qtr-.
    Therefore, the -clustvar- changes accordingly.
    Last edited by Carlo Lazzaro; 11 Oct 2022, 08:07.
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment


    • #3
      Originally posted by Carlo Lazzaro View Post
      Ali:
      the reason is that the same id moves from 0 to 1 across subsequent -qtr-.
      Therefore, the -clustvar- changes accordingly.
      Thank you Carlo for your reply

      I just wondering, is there any way to solve this problem and apply the DiD model ? or what is the alternative way to overcome this?

      Comment


      • #4
        Ali:
        just find a different (and time-invariant) variable to cluster on your standard errors.
        Kind regards,
        Carlo
        (Stata 19.0)

        Comment


        • #5
          Thanks for your suggestion, but may you give me a hint on what is the looks like of variable for cluster standard errors? could be any variable? how can I know if the variable is time-invariant?

          also, if I find a new variable to cluster, what is the new regression model command in Stata?

          Comment


          • #6
            Ali:
            for instance, -panelid- is the variable on which standard errors are usually clustered.
            See also Example 10, -didregress- entry, Stata .pdf manual.
            Last edited by Carlo Lazzaro; 11 Oct 2022, 16:22.
            Kind regards,
            Carlo
            (Stata 19.0)

            Comment


            • #7
              Many Thanks, Carlo, for your comments.

              I use the "ZHC" variable to cluster my standard errors. ZHC is the treatment group, so did that :

              Code:
              xtset ZHC
              Panel variable: ZHC (unbalanced)
              xtdidregress (SUMHRS AGE SEX) (afterCovid19) [pweight = LGWT20], group( ZHC) time ( qtr )
              However, I got the error with my group "invalid group specification
              None of the groups defined by ZHC is a control."

              Note that ZHC is a dummy variable I created

              Any insights on what I could do?

              Comment


              • #8
                Originally posted by Carlo Lazzaro View Post
                Ali:
                for instance, -panelid- is the variable on which standard errors are usually clustered.
                See also Example 10, -didregress- entry, Stata .pdf manual.
                Many Thanks, Carlo, for your comments.

                I use the "ZHC" variable to cluster my standard errors. ZHC is the treatment group, so did that :

                Code:
                xtset ZHC Panel variable: ZHC (unbalanced) xtdidregress (SUMHRS AGE SEX) (afterCovid19) [pweight = LGWT20], group( ZHC) time ( qtr )
                However, I got the error with my group "invalid group specification
                None of the groups defined by ZHC is a control."

                Note that ZHC is a dummy variable I created

                Any insights on what I could do?

                Comment


                • #9
                  Ali:
                  could you please share an excerpt/example of your dataset? Thanks.
                  Kind regards,
                  Carlo
                  (Stata 19.0)

                  Comment


                  • #10
                    Originally posted by Carlo Lazzaro View Post
                    Ali:
                    could you please share an excerpt/example of your dataset? Thanks.
                    Thanks for your reply

                    please see example of my dataset
                    Code:
                    * Example generated by -dataex-. For more info, type help dataex
                    clear
                    input double PERSID byte quarter long LGWT20 byte(FLOW anflow WEEK SEX QRTR OYFTPT1 YPTJOB TYEMPS TTUSHR STATR) int SOC10M byte(SCHM12 SECJMBR SECJOB AGE FLEXW7) float ZHC
                     350692010103 1 44910  3  1  6 1 2  1 -9 -9 40  1 3545 66  5  2 23 . 0
                    4231092970102 1  2600  3  1 10 2 2  1 -9 -9 40  1 7112 66  5  2 26 . 0
                    3000892010102 1 11090 11  3  8 2 2 -9 -9 -9 -9 -9   -9 66 -9 -9 64 . 0
                    9360992020101 1  9961  3  1  9 1 2  1 -9 -9 46  2 2434 66  5  2 56 . 0
                     110392020101 1 21408  3  1  3 2 2  2  4 -9 22  1 2119 66  5  2 33 . 0
                    2670492020101 1 11598  3  1  4 2 2  2  4 -9 27  1 4113 66  5  2 59 . 0
                    2951292020101 1 12083 11  3 12 1 2 -9 -9 -9 -9 -9   -9 -9 -9 -9 67 . 0
                      80392010102 1  7120  3  1  3 2 2  2  4 -9 18  1 6125 66  2  1 58 . 0
                    1261092030101 1  4937  3  1 10 2 2  2  4 -9 20  1 9274 66  5  2 62 . 0
                    4230692310101 1  1359  3  1  6 1 2  1 -9 -9 35  2 8214 66  5  2 52 . 0
                     230192020102 1 14164  3  1  1 1 2  1 -9 -9 42  1 7111 66  5  2 32 . 0
                    3090792020101 1  8088 11  3  7 1 2 -9 -9 -9 -9 -9   -9 66 -9 -9 62 . 0
                     660692030102 1 47269  3  1  6 2 2  1 -9  2 44  1 2315 66  5  2 27 . 0
                    2451192010101 1 13526 11  3 11 1 2 -9 -9 -9 -9 -9   -9 -9 -9 -9 66 . 0
                    4231192140102 1  2228  3  1 11 1 2  1 -9 -9 40  2 8149 66  5  2 56 . 0
                    2760692040102 1 11285  3  1  6 1 2  1 -9 -9 70  2 5330 66  5  2 52 . 0
                    2420792010101 1 13213  3  1  7 2 2  1 -9 -9 64  1 2315 66  5  2 47 . 0
                     530692010101 1 17048  3  1  6 2 2  1 -9  2 40  1 4122 66  5  2 25 . 0
                     690392040103 1 26411  2  0  3 1 2 -9 -9 -9 -9 -9   -9 -9 -9 -9 15 . 0
                     101192010101 1 41190  3  1 11 1 2  1 -9 -9 40  1 2142 66  5  2 27 . 0
                    1140192050101 1 12302  3 10  1 1 2  1  4 -9 28  1 2316 66  5  2 57 . 0
                    1661392060102 1 10887  3  1 13 1 2  1 -9 -9 60  1 8213 66  5  2 34 . 0
                     260892020102 1  8784  3  1  8 2 2  1 -9 -9 38  1 4211 66  5  2 54 . 0
                     670392010103 1 12910  3  1  3 2 2  1 -9 -9 38  1 2462 66  5  2 61 . 0
                     870592020102 1 39855  3  1  5 1 2  1 -9 -9 52  1 2137 66  5  2 37 . 0
                     310792040101 1 25718  6  7  7 1 2  1 -9  2 -9 -9   -9 66 -9 -9 30 . 0
                    1220292020101 1  6818  3  1  2 2 2  1 -9 -9 38  1 2142 66  5  2 43 . 0
                     120492010102 1 10744  3  1  4 1 2  1 -9 -9 40  1 1122 66  5  2 54 . 0
                     980792030102 1  6070 11  3  7 2 2 -9 -9 -9 -9 -9   -9 -9 -9 -9 65 . 0
                    9191092020101 1  6854 12 23 10 1 2 -9 -9 -9 -9 -9   -9 -9 -9 -9 69 . 0
                    2331392020102 1  9568 11  3 13 2 2 -9 -9 -9 -9 -9   -9 -9 -9 -9 65 . 0
                    7690992010103 1 13191  3  1  9 2 2  1 -9 -9 37  1 4131 66  5  2 35 . 0
                    2191392060102 1  5192 11  3 13 1 2 -9 -9 -9 -9 -9   -9 -9 -9 -9 65 . 0
                    9331392010101 1  5240  3  1 13 2 2  1 -9 -9 40  1 5434 -9  5  2 68 . 0
                    2491392050101 1  7575 11  3 13 2 2 -9 -9 -9 -9 -9   -9 66 -9 -9 64 . 0
                    2410192040101 1 19025  3  1  1 1 2  1 -9 -9 55  2 3416 66  5  2 52 . 0
                    1521092030101 1 16122  3  1 10 2 2  2  4 -9 12  2 5241 66  5  2 41 . 0
                     750192010101 1 10174  3  1  1 2 2  1 -9 -9 41  1 2424 66  5  2 64 . 0
                    9310792040103 1 21345  3  1  7 2 2  1 -9 -9 46  1 9251 66  5  2 26 . 0
                    7821392020101 1 13412  3  1 13 1 2  1 -9 -9 37  1 1121 66  5  2 39 . 0
                     310992030102 1 16705  3  1  9 2 2  1 -9 -9 40  1 2136 66  5  2 30 . 0
                    2171092010102 1 14397  3  1 10 1 2  1 -9 -9 45  1 3546 66  5  2 37 . 0
                    1800592030103 1  6009 11 15  5 2 2  2 -9 -9 -9 -9   -9 66 -9 -9 51 . 0
                    3110492030101 1 22278  3  1  4 2 2  1 -9 -9 45  1 3542 66  5  2 27 . 0
                    4230992800102 1  1163  3  1  9 1 2  2  4 -9 20  2 5323 66  5  2 55 . 0
                    7910892010101 1  9687 11  3  8 1 2  1 -9 -9 -9 -9   -9 66 -9 -9 55 . 0
                    1250592020101 1 10121  3  1  5 2 2  1 -9 -9 47  1 2314 66  5  2 32 . 0
                    2380492020102 1 12209 10  9  4 1 2 -9 -9 -9 -9 -9   -9 66 -9 -9 47 . 0
                    3170892010101 1 21010 11  3  8 2 2 -9 -9 -9 -9 -9   -9 66 -9 -9 47 . 0
                     431192030102 1 18775  3  1 11 2 2  1 -9 -9 39  1 6125 66  5  2 52 . 0
                     310492040101 1 18193  3  1  4 2 2  1 -9 -9 40  2 6122 66  5  2 32 . 0
                     291392010103 1 13414 11  3 13 1 2 -9 -9 -9 -9 -9   -9 66 -9 -9 33 . 0
                    4230292120102 1  3651  3  1  2 2 2  1 -9 -9 40  2 6221 66  5  2 24 . 0
                    2040292050101 1 13007  3  1  2 1 2  1 -9 -9 60  1 8213 66  5  2 56 . 0
                     490392020102 1 12003  3  1  3 2 2  2  2 -9 38  1 4114 66  5  2 58 . 0
                     650592030103 1 84192  8 22  5 1 2  1 -9  2 -9 -9   -9 66 -9 -9 21 . 0
                    4230692850101 1  1036  3  1  6 2 2  1 -9 -9 44  2 3534 66  5  2 51 . 0
                    4230592550102 1  2311  3  1  5 2 2 -9  4 -9 -8  1 6145 66  5  2 28 . 0
                    2390492030101 1 10386  3  1  4 2 2  1 -9 -9 38  1 2319 66  5  2 51 . 0
                    2781392010101 1  6493 11  3 13 1 2  2 -9 -9 -9 -9   -9 -9 -9 -9 68 . 0
                     330692020101 1  4677 11  3  6 2 2 -9 -9 -9 -9 -9   -9 66 -9 -9 63 . 0
                    1781392010101 1 12929 11  3 13 2 2 -9 -9 -9 -9 -9   -9 66 -9 -9 46 . 0
                    9120192030101 1 17474  3  1  1 1 2  1 -9 -9 37  1 3535 66  5  2 38 . 0
                    4230592580103 1  1547  3  1  5 1 2  1 -9 -9 57  1 5215 66  5  2 53 . 0
                    2390892020101 1 11351  3  1  8 2 2  1  3 -9 31  1 4212 66  5  2 58 . 0
                     890992050101 1  7684 12 23  9 2 2  2  4 -9 16  1 4161 -9  5  2 69 . 0
                    2160692010102 1  8500  3  1  6 1 2  1 -9 -9 32  1 1190 66  5  2 48 . 0
                    3151092010101 1  9940  3  1 10 1 2  1 -9 -9 46  1 5314 66  5  2 45 . 0
                    4230892560102 1  1363  3  1  8 2 2  1 -9 -9 40  1 1131 66  5  2 52 . 0
                     990892040101 1 15868  3  1  8 2 2  1 -9 -9 38  1 4129 66  5  2 48 . 0
                      81392020101 1  3960 12 23 13 1 2 -9 -9 -9 -9 -9   -9 -9 -9 -9 69 . 0
                     890192040102 1 12640  3  1  1 2 2  2 -9 -9 21  1 1139 66  1  1 60 . 0
                    2160692040101 1 55543  3  1  6 1 2  2  4 -9 20  1 3546 66  5  2 24 . 0
                    2110692020101 1 37976  5  5  6 1 2 -9  1 -9  4  2 3443 66  5  2 23 . 0
                     680792020101 1 19157  3  1  7 2 2  1 -9 -9 37  1 1135 66  5  2 31 . 0
                    2970592040101 1 17007  3  1  5 1 2  1 -9 -9 65  1 2319 66  5  2 31 . 0
                    2511292010101 1 26099  3  1 12 1 2  1 -9 -9 40  1 9233 66  5  2 56 . 0
                    1010792010101 1 32474  3  1  7 1 2  1 -9 -9 44  1 4133 66  5  2 34 . 0
                    4231392010101 1  2103  3  1 13 1 2  1 -9 -9 45  1 4114 66  5  2 32 . 0
                    2040792020102 1  9488  3  1  7 1 2  1 -9 -9 50  2 5319 66  5  2 54 . 0
                     221092010102 1  6452  3  1 10 2 2  2  4 -9 24  1 7211 66  5  2 53 . 0
                    2080492040102 1  8116  3  1  4 2 2  2  4 -9 27  1 6145 66  5  2 53 . 0
                     320992030101 1  6944  3  1  9 1 2  1 -9 -9 34  1 6141 -9  5  2 65 . 0
                    2710292010101 1  6608 11  3  2 2 2 -9 -9 -9 -9 -9   -9 -9 -9 -9 66 . 0
                    7600492010103 1 41060  3  1  4 2 2  2  4 -9 30  1 6121 66  5  2 22 . 0
                    4230192150102 1  1544  3  1  1 2 2  1 -9 -9 34  1 7130 66  5  2 50 . 0
                    2850592040102 1  5352 11  3  5 1 2 -9 -9 -9 -9 -9   -9 66 -9 -9 64 . 0
                    7750392020102 1  6708 11  3  3 2 2 -9 -9 -9 -9 -9   -9 -9 -9 -9 66 . 0
                    2081192030101 1 15751  3  1 11 2 2  1 -9  2 44  1 4129 66  5  2 58 . 0
                    2121092020101 1  8713  3  1 10 2 2  2 -9 -9 45  1 1252 66  5  2 40 . 0
                    4231392750101 1  1503 11  3 13 2 2 -9 -9 -9 -9 -9   -9 66 -9 -9 54 . 0
                    2001092030102 1  3228  5  5 10 2 2  2  4 -9 20  1 2462 -9  5  2 67 . 0
                    9311192050101 1 12543 11  3 11 2 2 -9 -9 -9 -9 -9   -9 66 -9 -9 62 . 0
                    2150692010101 1 13221  8 18  6 1 2  1 -9  2 -9 -9   -9 66 -9 -9 58 . 0
                    1461392030101 1  4903 12 23 13 2 2 -9 -9 -9 -9 -9   -9 -9 -9 -9 69 . 0
                    4230292180101 1  1074 11  3  2 2 2 -9 -9 -9 -9 -9   -9 66 -9 -9 46 . 0
                    4230492100103 1  6353  3  1  4 1 2  1 -9 -9 50  1 5225 66  5  2 22 . 0
                      60892020101 1  6144 11  3  8 1 2  1 -9 -9 -9 -9   -9 66 -9 -9 62 . 0
                    9201392040101 1 15508  3  1 13 1 2  2  1  1 21  1 3561 66  5  2 40 . 0
                    1261192020101 1  5830  5  5 11 2 2  2  4 -9  7  1 9233 66  5  2 64 . 0
                    end
                    label values FLOW FLOW
                    label def FLOW 2 "Entrant to working-age between first and final quarter", modify
                    label def FLOW 3 "In employment at first quarter; in employment at final quarter (EE)", modify
                    label def FLOW 5 "In employment at first quarter; inactive at final quarter (EN)", modify
                    label def FLOW 6 "Unemployed at first quarter; in employment at final quarter (UE)", modify
                    label def FLOW 8 "Unemployed at first quarter; inactive at final quarter (UN)", modify
                    label def FLOW 10 "Inactive at first quarter; unemployed at final quarter (NU)", modify
                    label def FLOW 11 "Inactive at first quarter; inactive at final quarter (NN)", modify
                    label def FLOW 12 "Reached retirement age by final quarter", modify
                    label values anflow anflow
                    label def anflow 0 "Entering", modify
                    label def anflow 1 "In employment in all quarters (E)", modify
                    label def anflow 3 "Inactive in all quarters (N)", modify
                    label def anflow 5 "In employment at first quarter; inactive at final quarter (EN)", modify
                    label def anflow 7 "Unemployed at first quarter; in employment at final quarter (UE)", modify
                    label def anflow 9 "Inactive at first quarter; unemployed at final quarter (NU)", modify
                    label def anflow 10 "Employed at first; unemployed; in employment at final quarter(EUE)", modify
                    label def anflow 15 "Inactive at first; unemployed; inactive at last quarter (NUN)", modify
                    label def anflow 18 "Unemployed at first; employed; inactive at final quarter (UEN)", modify
                    label def anflow 22 "3 or 4 moves between categories", modify
                    label def anflow 23 "Leaving", modify
                    label values WEEK WEEK
                    label values SEX SEX
                    label def SEX 1 "Male", modify
                    label def SEX 2 "Female", modify
                    label values QRTR QRTR
                    label def QRTR 2 "AJ (April to June)", modify
                    label values OYFTPT1 OYFTPT1
                    label def OYFTPT1 -9 "Does not apply", modify
                    label def OYFTPT1 1 "Full time", modify
                    label def OYFTPT1 2 "Part time", modify
                    label values YPTJOB YPTJOB5
                    label def YPTJOB5 -9 "Does not apply", modify
                    label def YPTJOB5 1 "Student or at school", modify
                    label def YPTJOB5 2 "Ill or disabled", modify
                    label def YPTJOB5 3 "Could not find full-time job", modify
                    label def YPTJOB5 4 "Did not want full-time job", modify
                    label values TYEMPS TYEMPS5
                    label def TYEMPS5 -9 "Does not apply", modify
                    label def TYEMPS5 1 "Self-employment", modify
                    label def TYEMPS5 2 "Full-time employee", modify
                    label values TTUSHR TTUSHR5
                    label def TTUSHR5 -9 "Does not apply", modify
                    label def TTUSHR5 -8 "No answer", modify
                    label values STATR STATR5
                    label def STATR5 -9 "Does not apply", modify
                    label def STATR5 1 "Employee", modify
                    label def STATR5 2 "Self-employed", modify
                    label values SOC10M SOC10M5
                    label def SOC10M5 -9 "Does not apply", modify
                    label def SOC10M5 1121 "Production managers and directors in manufacturing", modify
                    label def SOC10M5 1122 "Production managers and directors in construction", modify
                    label def SOC10M5 1131 "Financial managers and directors", modify
                    label def SOC10M5 1135 "Human resource managers and directors", modify
                    label def SOC10M5 1139 "Functional managers and directors n.e.c.", modify
                    label def SOC10M5 1190 "Managers and directors in retail and wholesale", modify
                    label def SOC10M5 1252 "Garage managers and proprietors", modify
                    label def SOC10M5 2119 "Natural and social science professionals n.e.c.", modify
                    label def SOC10M5 2136 "Programmers and software development professionals", modify
                    label def SOC10M5 2137 "Web design and development professionals", modify
                    label def SOC10M5 2142 "Environment professionals", modify
                    label def SOC10M5 2314 "Secondary education teaching professionals", modify
                    label def SOC10M5 2315 "Primary and nursery education teaching professionals", modify
                    label def SOC10M5 2316 "Special needs education teaching professionals", modify
                    label def SOC10M5 2319 "Teaching and other educational professionals n.e.c.", modify
                    label def SOC10M5 2424 "Business and financial project management professionals", modify
                    label def SOC10M5 2434 "Chartered surveyors", modify
                    label def SOC10M5 2462 "Quality assurance and regulatory professionals", modify
                    label def SOC10M5 3416 "Arts officers, producers and directors", modify
                    label def SOC10M5 3443 "Fitness instructors", modify
                    label def SOC10M5 3534 "Finance and investment analysts and advisers", modify
                    label def SOC10M5 3535 "Taxation experts", modify
                    label def SOC10M5 3542 "Business sales executives", modify
                    label def SOC10M5 3545 "Sales accounts and business development managers", modify
                    label def SOC10M5 3546 "Conference and exhibition managers and organisers", modify
                    label def SOC10M5 3561 "Public services associate professionals", modify
                    label def SOC10M5 4113 "Local government administrative occupations", modify
                    label def SOC10M5 4114 "Officers of non-governmental organisations", modify
                    label def SOC10M5 4122 "Book-keepers, payroll managers and wages clerks", modify
                    label def SOC10M5 4129 "Financial administrative occupations n.e.c.", modify
                    label def SOC10M5 4131 "Records clerks and assistants", modify
                    label def SOC10M5 4133 "Stock control clerks and assistants", modify
                    label def SOC10M5 4161 "Office managers", modify
                    label def SOC10M5 4211 "Medical secretaries", modify
                    label def SOC10M5 4212 "Legal secretaries", modify
                    label def SOC10M5 5215 "Welding trades", modify
                    label def SOC10M5 5225 "Air-conditioning and refrigeration engineers", modify
                    label def SOC10M5 5241 "Electricians and electrical fitters", modify
                    label def SOC10M5 5314 "Plumbers and heating and ventilating engineers", modify
                    label def SOC10M5 5319 "Construction and building trades n.e.c.", modify
                    label def SOC10M5 5323 "Painters and decorators", modify
                    label def SOC10M5 5330 "Construction and building trades supervisors", modify
                    label def SOC10M5 5434 "Chefs", modify
                    label def SOC10M5 6121 "Nursery nurses and assistants", modify
                    label def SOC10M5 6122 "Childminders and related occupations", modify
                    label def SOC10M5 6125 "Teaching assistants", modify
                    label def SOC10M5 6141 "Nursing auxiliaries and assistants", modify
                    label def SOC10M5 6145 "Care workers and home carers", modify
                    label def SOC10M5 6221 "Hairdressers and barbers", modify
                    label def SOC10M5 7111 "Sales and retail assistants", modify
                    label def SOC10M5 7112 "Retail cashiers and check-out operators", modify
                    label def SOC10M5 7130 "Sales supervisors", modify
                    label def SOC10M5 7211 "Call and contact centre occupations", modify
                    label def SOC10M5 8149 "Construction operatives n.e.c.", modify
                    label def SOC10M5 8213 "Bus and coach drivers", modify
                    label def SOC10M5 8214 "Taxi and cab drivers and chauffeurs", modify
                    label def SOC10M5 9233 "Cleaners and domestics", modify
                    label def SOC10M5 9251 "Shelf fillers", modify
                    label def SOC10M5 9274 "Bar staff", modify
                    label values SCHM12 SCHM125
                    label def SCHM125 -9 "Does not apply", modify
                    label def SCHM125 66 "or none of these?", modify
                    label values SECJMBR SECJMBR5
                    label def SECJMBR5 -9 "Does not apply", modify
                    label def SECJMBR5 1 "Employee", modify
                    label def SECJMBR5 2 "Self-employed", modify
                    label def SECJMBR5 5 "No second job", modify
                    label values SECJOB SECJOB5
                    label def SECJOB5 -9 "Does not apply", modify
                    label def SECJOB5 1 "Yes", modify
                    label def SECJOB5 2 "No", modify
                    label values AGE AGE5
                    label values FLEXW7 FLEXW75

                    Comment


                    • #11
                      Ali:
                      when I run your code on your dataset excerpt I get:
                      Code:
                      . xtdidregress (SUMHRS AGE SEX) (afterCovid19) [pweight = LGWT20], group( ZHC) time ( qtr )
                      variable SUMHRS not found
                      r(111);
                      Kind regards,
                      Carlo
                      (Stata 19.0)

                      Comment


                      • #12
                        Originally posted by Carlo Lazzaro View Post
                        Ali:
                        when I run your code on your dataset excerpt I get:
                        Code:
                        . xtdidregress (SUMHRS AGE SEX) (afterCovid19) [pweight = LGWT20], group( ZHC) time ( qtr )
                        variable SUMHRS not found
                        r(111);
                        Sorry I did not include the SUMHRS variable in the sample

                        here all variables
                        Code:
                        * Example generated by -dataex-. For more info, type help dataex
                        clear
                        input double(PERSID SUMHRS) byte(quarter FLOW anflow WEEK SEX QRTR OYFTPT1 YPTJOB TYEMPS TTUSHR STATR) int SOC10M byte(SCHM12 SECJOB AGE) float(ZHC afterCovid19 DiD) byte RECNO int QUOTA byte(HHLD IOTCOME Inde07m) double HRRATE byte(FTPTWK CORBEN20B1)
                         350692010103 40 1  3  1  6 1 2  1 -9 -9 40  1 3545 66  2 23 0 0 0 3  35 1 2  3                -9  1 .
                        4231092970102 40 1  3  1 10 2 2  1 -9 -9 40  1 7112 66  2 26 0 0 0 2 423 1 1  5                -9  1 .
                        3000892010102 -9 1 11  3  8 2 2 -9 -9 -9 -9 -9   -9 66 -9 64 0 0 0 2 300 1 1 -9                -9 -9 .
                        9360992020101 46 1  3  1  9 1 2  1 -9 -9 46  2 2434 66  2 56 0 0 0 1 936 1 1  7                -9  1 .
                         110392020101 15 1  3  1  3 2 2  2  4 -9 22  1 2119 66  2 33 0 0 0 1  11 1 1  8                -9  2 .
                        2670492020101 27 1  3  1  4 2 2  2  4 -9 27  1 4113 66  2 59 0 0 0 1 267 1 1  7                -9  2 .
                        2951292020101 -9 1 11  3 12 1 2 -9 -9 -9 -9 -9   -9 -9 -9 67 0 0 0 1 295 1 1 -9                -9  1 .
                          80392010102 18 1  3  1  3 2 2  2  4 -9 18  1 6125 66  1 58 0 0 0 2   8 1 1  8              9.28  2 .
                        1261092030101 20 1  3  1 10 2 2  2  4 -9 20  1 9274 66  2 62 0 0 0 1 126 1 1  5                 9  2 .
                        4230692310101 35 1  3  1  6 1 2  1 -9 -9 35  2 8214 66  2 52 0 0 0 1 423 1 2  6                -9  1 .
                         230192020102 30 1  3  1  1 1 2  1 -9 -9 42  1 7111 66  2 32 0 0 0 2  23 1 1  5              8.75  1 .
                        3090792020101 -9 1 11  3  7 1 2 -9 -9 -9 -9 -9   -9 66 -9 62 0 0 0 1 309 1 1 -9                -9  1 .
                         660692030102 41 1  3  1  6 2 2  1 -9  2 44  1 2315 66  2 27 0 0 0 2  66 1 1  8               998  1 .
                        2451192010101 -9 1 11  3 11 1 2 -9 -9 -9 -9 -9   -9 -9 -9 66 0 0 0 1 245 1 1 -9                -9  1 .
                        4231192140102 40 1  3  1 11 1 2  1 -9 -9 40  2 8149 66  2 56 0 0 0 2 423 1 1  8                -9  1 .
                        2760692040102 70 1  3  1  6 1 2  1 -9 -9 70  2 5330 66  2 52 0 0 0 2 276 1 2  4                -9  1 .
                        2420792010101 64 1  3  1  7 2 2  1 -9 -9 64  1 2315 66  2 47 0 0 0 1 242 1 1  8                -9  1 .
                         530692010101 40 1  3  1  6 2 2  1 -9  2 40  1 4122 66  2 25 0 0 0 1  53 1 1  7               998  1 .
                         690392040103 -9 1  2  0  3 1 2 -9 -9 -9 -9 -9   -9 -9 -9 15 0 0 0 3  69 1 4 -9                -9 -9 .
                         101192010101  8 1  3  1 11 1 2  1 -9 -9 40  1 2142 66  2 27 0 0 0 1  10 1 1  7                -9  1 .
                        1140192050101 28 1  3 10  1 1 2  1  4 -9 28  1 2316 66  2 57 0 0 0 1 114 1 1  7                -9  2 .
                        1661392060102 60 1  3  1 13 1 2  1 -9 -9 60  1 8213 66  2 34 0 0 0 2 166 1 2  6               998  1 .
                         260892020102 38 1  3  1  8 2 2  1 -9 -9 38  1 4211 66  2 54 0 0 0 2  26 1 1  8             10.58  1 .
                         670392010103 42 1  3  1  3 2 2  1 -9 -9 38  1 2462 66  2 61 0 0 0 3  67 1 1  8              22.1  1 .
                         870592020102 52 1  3  1  5 1 2  1 -9 -9 52  1 2137 66  2 37 0 0 0 2  87 1 2  5                -9  1 .
                         310792040101 -9 1  6  7  7 1 2  1 -9  2 -9 -9   -9 66 -9 30 0 0 0 1  31 1 1 -9                -9  1 .
                        1220292020101  8 1  3  1  2 2 2  1 -9 -9 38  1 2142 66  2 43 0 0 0 1 122 1 1  8               998  1 .
                         120492010102 50 1  3  1  4 1 2  1 -9 -9 40  1 1122 66  2 54 0 0 0 2  12 1 2  4                -9  1 .
                         980792030102 -9 1 11  3  7 2 2 -9 -9 -9 -9 -9   -9 -9 -9 65 0 0 0 2  98 1 2 -9                -9 -9 .
                        9191092020101 -9 1 12 23 10 1 2 -9 -9 -9 -9 -9   -9 -9 -9 69 0 0 0 1 919 1 1 -9                -9  1 .
                        2331392020102 -9 1 11  3 13 2 2 -9 -9 -9 -9 -9   -9 -9 -9 65 0 0 0 2 233 1 2 -9                -9 -9 .
                        7690992010103 30 1  3  1  9 2 2  1 -9 -9 37  1 4131 66  2 35 0 0 0 3 769 1 1  8                -9  1 .
                        2191392060102 -9 1 11  3 13 1 2 -9 -9 -9 -9 -9   -9 -9 -9 65 0 0 0 2 219 1 1 -9                -9  1 .
                        9331392010101 32 1  3  1 13 2 2  1 -9 -9 40  1 5434 -9  2 68 0 0 0 1 933 1 1  5              8.21  1 .
                        2491392050101 -9 1 11  3 13 2 2 -9 -9 -9 -9 -9   -9 66 -9 64 0 0 0 1 249 1 1 -9                -9 -9 .
                        2410192040101 55 1  3  1  1 1 2  1 -9 -9 55  2 3416 66  2 52 0 0 0 1 241 1 1  3                -9  1 .
                        1521092030101 16 1  3  1 10 2 2  2  4 -9 12  2 5241 66  2 41 0 0 0 1 152 1 1  9                -9  2 .
                         750192010101 23 1  3  1  1 2 2  1 -9 -9 41  1 2424 66  2 64 0 0 0 1  75 1 1  3                -9  1 .
                        9310792040103 18 1  3  1  7 2 2  1 -9 -9 46  1 9251 66  2 26 0 0 0 3 931 1 1  5              7.86  1 .
                        7821392020101 37 1  3  1 13 1 2  1 -9 -9 37  1 1121 66  2 39 0 0 0 1 782 1 2  3                -9  1 .
                         310992030102 30 1  3  1  9 2 2  1 -9 -9 40  1 2136 66  2 30 0 0 0 2  31 1 1  6                -9  1 .
                        2171092010102 50 1  3  1 10 1 2  1 -9 -9 45  1 3546 66  2 37 0 0 0 2 217 1 2  7                -9  1 .
                        1800592030103 -9 1 11 15  5 2 2  2 -9 -9 -9 -9   -9 66 -9 51 0 0 0 3 180 1 2 -9                -9  2 .
                        3110492030101  0 1  3  1  4 2 2  1 -9 -9 45  1 3542 66  2 27 0 0 0 1 311 1 1  3                -9  1 .
                        4230992800102  0 1  3  1  9 1 2  2  4 -9 20  2 5323 66  2 55 0 0 0 2 423 1 1  3                -9  2 .
                        7910892010101 -9 1 11  3  8 1 2  1 -9 -9 -9 -9   -9 66 -9 55 0 0 0 1 791 1 1 -9                -9  1 .
                        1250592020101  0 1  3  1  5 2 2  1 -9 -9 47  1 2314 66  2 32 0 0 0 1 125 1 1  8                -9  1 .
                        2380492020102 -9 1 10  9  4 1 2 -9 -9 -9 -9 -9   -9 66 -9 47 0 0 0 2 238 1 1 -9                -9  1 .
                        3170892010101 -9 1 11  3  8 2 2 -9 -9 -9 -9 -9   -9 66 -9 47 0 0 0 1 317 1 1 -9                -9 -9 .
                         431192030102 39 1  3  1 11 2 2  1 -9 -9 39  1 6125 66  2 52 0 0 0 2  43 1 2  8                -9  1 .
                         310492040101 32 1  3  1  4 2 2  1 -9 -9 40  2 6122 66  2 32 0 0 0 1  31 1 1  8                -9  1 .
                         291392010103 -9 1 11  3 13 1 2 -9 -9 -9 -9 -9   -9 66 -9 33 0 0 0 3  29 1 1 -9                -9  2 .
                        4230292120102 40 1  3  1  2 2 2  1 -9 -9 40  2 6221 66  2 24 0 0 0 2 423 1 2  9                -9  1 .
                        2040292050101 55 1  3  1  2 1 2  1 -9 -9 60  1 8213 66  2 56 0 0 0 1 204 1 1  6              10.5  1 .
                         490392020102 38 1  3  1  3 2 2  2  2 -9 38  1 4114 66  2 58 0 0 0 2  49 1 2  8                 9  2 .
                         650592030103 -9 1  8 22  5 1 2  1 -9  2 -9 -9   -9 66 -9 21 0 0 0 3  65 1 2 -9                -9  1 .
                        4230692850101 44 1  3  1  6 2 2  1 -9 -9 44  2 3534 66  2 51 0 0 0 1 423 1 1  7                -9  1 .
                        4230592550102  6 1  3  1  5 2 2 -9  4 -9 -8  1 6145 66  2 28 0 0 0 2 423 1 1  8               8.9  2 .
                        2390492030101 30 1  3  1  4 2 2  1 -9 -9 38  1 2319 66  2 51 0 0 0 1 239 1 1  8                -9  1 .
                        2781392010101 -9 1 11  3 13 1 2  2 -9 -9 -9 -9   -9 -9 -9 68 0 0 0 1 278 1 1 -9                -9  2 .
                         330692020101 -9 1 11  3  6 2 2 -9 -9 -9 -9 -9   -9 66 -9 63 0 0 0 1  33 1 1 -9                -9  2 .
                        1781392010101 -9 1 11  3 13 2 2 -9 -9 -9 -9 -9   -9 66 -9 46 0 0 0 1 178 1 1 -9                -9 -9 .
                        9120192030101 39 1  3  1  1 1 2  1 -9 -9 37  1 3535 66  2 38 0 0 0 1 912 1 1  8                -9  1 .
                        4230592580103 57 1  3  1  5 1 2  1 -9 -9 57  1 5215 66  2 53 0 0 0 3 423 1 2  5                -9  1 .
                        2390892020101 31 1  3  1  8 2 2  1  3 -9 31  1 4212 66  2 58 0 0 0 1 239 1 1  7              8.21  2 .
                         890992050101 16 1 12 23  9 2 2  2  4 -9 16  1 4161 -9  2 69 0 0 0 1  89 1 1  7                -9  2 .
                        2160692010102 32 1  3  1  6 1 2  1 -9 -9 32  1 1190 66  2 48 0 0 0 2 216 1 2  7                -9  1 .
                        3151092010101 46 1  3  1 10 1 2  1 -9 -9 46  1 5314 66  2 45 0 0 0 1 315 1 1  4                18  1 .
                        4230892560102 40 1  3  1  8 2 2  1 -9 -9 40  1 1131 66  2 52 0 0 0 2 423 1 1  7                -9  1 .
                         990892040101 38 1  3  1  8 2 2  1 -9 -9 38  1 4129 66  2 48 0 0 0 1  99 1 1  8                -9  1 .
                          81392020101 -9 1 12 23 13 1 2 -9 -9 -9 -9 -9   -9 -9 -9 69 0 0 0 1   8 1 1 -9                -9  2 .
                         890192040102 25 1  3  1  1 2 2  2 -9 -9 21  1 1139 66  1 60 0 0 0 2  89 1 1  8                -9  1 .
                        2160692040101 25 1  3  1  6 1 2  2  4 -9 20  1 3546 66  2 24 0 0 0 1 216 1 1  6              9.25  2 .
                        2110692020101  4 1  5  5  6 1 2 -9  1 -9  4  2 3443 66  2 23 0 0 0 1 211 1 1  9                -9  2 .
                         680792020101  0 1  3  1  7 2 2  1 -9 -9 37  1 1135 66  2 31 0 0 0 1  68 1 1  9                -9  1 .
                        2970592040101  0 1  3  1  5 1 2  1 -9 -9 65  1 2319 66  2 31 0 0 0 1 297 1 1  8                -9  1 .
                        2511292010101 40 1  3  1 12 1 2  1 -9 -9 40  1 9233 66  2 56 0 0 0 1 251 1 1  9                 9  1 .
                        1010792010101 42 1  3  1  7 1 2  1 -9 -9 44  1 4133 66  2 34 0 0 0 1 101 1 1  1                -9  1 .
                        4231392010101 45 1  3  1 13 1 2  1 -9 -9 45  1 4114 66  2 32 0 0 0 1 423 1 1  9                -9  1 .
                        2040792020102 50 1  3  1  7 1 2  1 -9 -9 50  2 5319 66  2 54 0 0 0 2 204 1 2  4                -9  1 .
                         221092010102 24 1  3  1 10 2 2  2  4 -9 24  1 7211 66  2 53 0 0 0 2  22 1 2  8               998  2 .
                        2080492040102 25 1  3  1  4 2 2  2  4 -9 27  1 6145 66  2 53 0 0 0 2 208 1 1  8                10  2 .
                         320992030101 34 1  3  1  9 1 2  1 -9 -9 34  1 6141 -9  2 65 0 0 0 1  32 1 1  8                -9  1 .
                        2710292010101 -9 1 11  3  2 2 2 -9 -9 -9 -9 -9   -9 -9 -9 66 0 0 0 1 271 1 1 -9                -9 -9 .
                        7600492010103 37 1  3  1  4 2 2  2  4 -9 30  1 6121 66  2 22 0 0 0 3 760 1 1  8              7.38  2 .
                        4230192150102 30 1  3  1  1 2 2  1 -9 -9 34  1 7130 66  2 50 0 0 0 2 423 1 2  5              8.03  1 .
                        2850592040102 -9 1 11  3  5 1 2 -9 -9 -9 -9 -9   -9 66 -9 64 0 0 0 2 285 1 1 -9                -9  1 .
                        7750392020102 -9 1 11  3  3 2 2 -9 -9 -9 -9 -9   -9 -9 -9 66 0 0 0 2 775 1 1 -9                -9 -9 .
                        2081192030101 30 1  3  1 11 2 2  1 -9  2 44  1 4129 66  2 58 0 0 0 1 208 1 1  8                -9  1 .
                        2121092020101 45 1  3  1 10 2 2  2 -9 -9 45  1 1252 66  2 40 0 0 0 1 212 1 1  5                -9  1 .
                        4231392750101 -9 1 11  3 13 2 2 -9 -9 -9 -9 -9   -9 66 -9 54 0 0 0 1 423 1 2 -9                -9 -9 .
                        2001092030102 20 1  5  5 10 2 2  2  4 -9 20  1 2462 -9  2 67 0 0 0 2 200 1 1  7                -9  2 .
                        9311192050101 -9 1 11  3 11 2 2 -9 -9 -9 -9 -9   -9 66 -9 62 0 0 0 1 931 1 1 -9                -9  1 .
                        2150692010101 -9 1  8 18  6 1 2  1 -9  2 -9 -9   -9 66 -9 58 0 0 0 1 215 1 1 -9                -9  1 .
                        1461392030101 -9 1 12 23 13 2 2 -9 -9 -9 -9 -9   -9 -9 -9 69 0 0 0 1 146 1 1 -9                -9  2 .
                        4230292180101 -9 1 11  3  2 2 2 -9 -9 -9 -9 -9   -9 66 -9 46 0 0 0 1 423 1 1 -9                -9 -9 .
                        4230492100103 55 1  3  1  4 1 2  1 -9 -9 50  1 5225 66  2 22 0 0 0 3 423 1 2  4                -9  1 .
                          60892020101 -9 1 11  3  8 1 2  1 -9 -9 -9 -9   -9 66 -9 62 0 0 0 1   6 1 1 -9                -9  1 .
                        9201392040101 21 1  3  1 13 1 2  2  1  1 21  1 3561 66  2 40 0 0 0 1 920 1 1  8 9.950000000000001  2 .
                        1261192020101  7 1  5  5 11 2 2  2  4 -9  7  1 9233 66  2 64 0 0 0 1 126 1 1  7               998  2 .
                        end
                        label values SUMHRS SUMHRS5
                        label def SUMHRS5 -9 "Does not apply", modify
                        label values FLOW FLOW
                        label def FLOW 2 "Entrant to working-age between first and final quarter", modify
                        label def FLOW 3 "In employment at first quarter; in employment at final quarter (EE)", modify
                        label def FLOW 5 "In employment at first quarter; inactive at final quarter (EN)", modify
                        label def FLOW 6 "Unemployed at first quarter; in employment at final quarter (UE)", modify
                        label def FLOW 8 "Unemployed at first quarter; inactive at final quarter (UN)", modify
                        label def FLOW 10 "Inactive at first quarter; unemployed at final quarter (NU)", modify
                        label def FLOW 11 "Inactive at first quarter; inactive at final quarter (NN)", modify
                        label def FLOW 12 "Reached retirement age by final quarter", modify
                        label values anflow anflow
                        label def anflow 0 "Entering", modify
                        label def anflow 1 "In employment in all quarters (E)", modify
                        label def anflow 3 "Inactive in all quarters (N)", modify
                        label def anflow 5 "In employment at first quarter; inactive at final quarter (EN)", modify
                        label def anflow 7 "Unemployed at first quarter; in employment at final quarter (UE)", modify
                        label def anflow 9 "Inactive at first quarter; unemployed at final quarter (NU)", modify
                        label def anflow 10 "Employed at first; unemployed; in employment at final quarter(EUE)", modify
                        label def anflow 15 "Inactive at first; unemployed; inactive at last quarter (NUN)", modify
                        label def anflow 18 "Unemployed at first; employed; inactive at final quarter (UEN)", modify
                        label def anflow 22 "3 or 4 moves between categories", modify
                        label def anflow 23 "Leaving", modify
                        label values WEEK WEEK
                        label values SEX SEX
                        label def SEX 1 "Male", modify
                        label def SEX 2 "Female", modify
                        label values QRTR QRTR
                        label def QRTR 2 "AJ (April to June)", modify
                        label values OYFTPT1 OYFTPT1
                        label def OYFTPT1 -9 "Does not apply", modify
                        label def OYFTPT1 1 "Full time", modify
                        label def OYFTPT1 2 "Part time", modify
                        label values YPTJOB YPTJOB5
                        label def YPTJOB5 -9 "Does not apply", modify
                        label def YPTJOB5 1 "Student or at school", modify
                        label def YPTJOB5 2 "Ill or disabled", modify
                        label def YPTJOB5 3 "Could not find full-time job", modify
                        label def YPTJOB5 4 "Did not want full-time job", modify
                        label values TYEMPS TYEMPS5
                        label def TYEMPS5 -9 "Does not apply", modify
                        label def TYEMPS5 1 "Self-employment", modify
                        label def TYEMPS5 2 "Full-time employee", modify
                        label values TTUSHR TTUSHR5
                        label def TTUSHR5 -9 "Does not apply", modify
                        label def TTUSHR5 -8 "No answer", modify
                        label values STATR STATR5
                        label def STATR5 -9 "Does not apply", modify
                        label def STATR5 1 "Employee", modify
                        label def STATR5 2 "Self-employed", modify
                        label values SOC10M SOC10M5
                        label def SOC10M5 -9 "Does not apply", modify
                        label def SOC10M5 1121 "Production managers and directors in manufacturing", modify
                        label def SOC10M5 1122 "Production managers and directors in construction", modify
                        label def SOC10M5 1131 "Financial managers and directors", modify
                        label def SOC10M5 1135 "Human resource managers and directors", modify
                        label def SOC10M5 1139 "Functional managers and directors n.e.c.", modify
                        label def SOC10M5 1190 "Managers and directors in retail and wholesale", modify
                        label def SOC10M5 1252 "Garage managers and proprietors", modify
                        label def SOC10M5 2119 "Natural and social science professionals n.e.c.", modify
                        label def SOC10M5 2136 "Programmers and software development professionals", modify
                        label def SOC10M5 2137 "Web design and development professionals", modify
                        label def SOC10M5 2142 "Environment professionals", modify
                        label def SOC10M5 2314 "Secondary education teaching professionals", modify
                        label def SOC10M5 2315 "Primary and nursery education teaching professionals", modify
                        label def SOC10M5 2316 "Special needs education teaching professionals", modify
                        label def SOC10M5 2319 "Teaching and other educational professionals n.e.c.", modify
                        label def SOC10M5 2424 "Business and financial project management professionals", modify
                        label def SOC10M5 2434 "Chartered surveyors", modify
                        label def SOC10M5 2462 "Quality assurance and regulatory professionals", modify
                        label def SOC10M5 3416 "Arts officers, producers and directors", modify
                        label def SOC10M5 3443 "Fitness instructors", modify
                        label def SOC10M5 3534 "Finance and investment analysts and advisers", modify
                        label def SOC10M5 3535 "Taxation experts", modify
                        label def SOC10M5 3542 "Business sales executives", modify
                        label def SOC10M5 3545 "Sales accounts and business development managers", modify
                        label def SOC10M5 3546 "Conference and exhibition managers and organisers", modify
                        label def SOC10M5 3561 "Public services associate professionals", modify
                        label def SOC10M5 4113 "Local government administrative occupations", modify
                        label def SOC10M5 4114 "Officers of non-governmental organisations", modify
                        label def SOC10M5 4122 "Book-keepers, payroll managers and wages clerks", modify
                        label def SOC10M5 4129 "Financial administrative occupations n.e.c.", modify
                        label def SOC10M5 4131 "Records clerks and assistants", modify
                        label def SOC10M5 4133 "Stock control clerks and assistants", modify
                        label def SOC10M5 4161 "Office managers", modify
                        label def SOC10M5 4211 "Medical secretaries", modify
                        label def SOC10M5 4212 "Legal secretaries", modify
                        label def SOC10M5 5215 "Welding trades", modify
                        label def SOC10M5 5225 "Air-conditioning and refrigeration engineers", modify
                        label def SOC10M5 5241 "Electricians and electrical fitters", modify
                        label def SOC10M5 5314 "Plumbers and heating and ventilating engineers", modify
                        label def SOC10M5 5319 "Construction and building trades n.e.c.", modify
                        label def SOC10M5 5323 "Painters and decorators", modify
                        label def SOC10M5 5330 "Construction and building trades supervisors", modify
                        label def SOC10M5 5434 "Chefs", modify
                        label def SOC10M5 6121 "Nursery nurses and assistants", modify
                        label def SOC10M5 6122 "Childminders and related occupations", modify
                        label def SOC10M5 6125 "Teaching assistants", modify
                        label def SOC10M5 6141 "Nursing auxiliaries and assistants", modify
                        label def SOC10M5 6145 "Care workers and home carers", modify
                        label def SOC10M5 6221 "Hairdressers and barbers", modify
                        label def SOC10M5 7111 "Sales and retail assistants", modify
                        label def SOC10M5 7112 "Retail cashiers and check-out operators", modify
                        label def SOC10M5 7130 "Sales supervisors", modify
                        label def SOC10M5 7211 "Call and contact centre occupations", modify
                        label def SOC10M5 8149 "Construction operatives n.e.c.", modify
                        label def SOC10M5 8213 "Bus and coach drivers", modify
                        label def SOC10M5 8214 "Taxi and cab drivers and chauffeurs", modify
                        label def SOC10M5 9233 "Cleaners and domestics", modify
                        label def SOC10M5 9251 "Shelf fillers", modify
                        label def SOC10M5 9274 "Bar staff", modify
                        label values SCHM12 SCHM125
                        label def SCHM125 -9 "Does not apply", modify
                        label def SCHM125 66 "or none of these?", modify
                        label values SECJOB SECJOB5
                        label def SECJOB5 -9 "Does not apply", modify
                        label def SECJOB5 1 "Yes", modify
                        label def SECJOB5 2 "No", modify
                        label values AGE AGE5
                        label values RECNO RECNO
                        label values QUOTA QUOTA
                        label values HHLD HHLD
                        label values IOTCOME IOTCOME5
                        label def IOTCOME5 1 "Personal response", modify
                        label def IOTCOME5 2 "Proxy response", modify
                        label def IOTCOME5 4 "Child under 16", modify
                        label values Inde07m Inde07m5
                        label def Inde07m5 -9 "Does not apply", modify
                        label def Inde07m5 1 "A - Agriculture, forestry and fishing", modify
                        label def Inde07m5 3 "C -Manufacturing", modify
                        label def Inde07m5 4 "F - Construction", modify
                        label def Inde07m5 5 "G,I -Distribution, hotels and restaurants", modify
                        label def Inde07m5 6 "H,J -Transport and communication", modify
                        label def Inde07m5 7 "K,L,M,N - Banking and finance", modify
                        label def Inde07m5 8 "O,P,Q - Public admin, education and health", modify
                        label def Inde07m5 9 "R,S,T,U - Other services", modify
                        label values HRRATE HRRATE5
                        label def HRRATE5 -9 "Does not apply", modify
                        label def HRRATE5 998 "Don't know", modify
                        label values FTPTWK FTPTWK5
                        label def FTPTWK5 -9 "Does not apply", modify
                        label def FTPTWK5 1 "Full-time", modify
                        label def FTPTWK5 2 "Part-time", modify
                        label values CORBEN20B1 CORBEN20B1

                        Comment


                        • #13
                          Ali:
                          set aside:
                          Code:
                          . xtdidregress (SUMHRS AGE SEX) (afterCovid19) [pweight = LGWT20], group( ZHC) time ( qtr )
                          LGWT20 not found
                          r(111);
                          the substantive issue is the one highlighted by -table- output:
                          Code:
                          . xtset PERSID WEEK
                          
                          Panel variable: PERSID (weakly balanced)
                           Time variable: WEEK, 1 to 13
                                   Delta: 1 unit
                          
                          . xtdidregress (SUMHRS AGE SEX) (afterCovid19) , group( ZHC) time ( qtr )
                          invalid treatment variable
                              Either the treatment does not vary or it is never zero. The treatment variable is either zero for controlled observations or 1 for
                              treated observations. To use a continuous treatment, specify (afterCovid19, continuous) for your treatment specification.
                          r(2000);
                          
                          . tab ZHC
                          
                                  ZHC |      Freq.     Percent        Cum.
                          ------------+-----------------------------------
                                    0 |        100      100.00      100.00
                          ------------+-----------------------------------
                                Total |        100      100.00
                          Kind regards,
                          Carlo
                          (Stata 19.0)

                          Comment


                          • #14
                            Originally posted by Carlo Lazzaro View Post
                            Ali:
                            set aside:
                            Code:
                            . xtdidregress (SUMHRS AGE SEX) (afterCovid19) [pweight = LGWT20], group( ZHC) time ( qtr )
                            LGWT20 not found
                            r(111);
                            the substantive issue is the one highlighted by -table- output:
                            Code:
                            . xtset PERSID WEEK
                            
                            Panel variable: PERSID (weakly balanced)
                            Time variable: WEEK, 1 to 13
                            Delta: 1 unit
                            
                            . xtdidregress (SUMHRS AGE SEX) (afterCovid19) , group( ZHC) time ( qtr )
                            invalid treatment variable
                            Either the treatment does not vary or it is never zero. The treatment variable is either zero for controlled observations or 1 for
                            treated observations. To use a continuous treatment, specify (afterCovid19, continuous) for your treatment specification.
                            r(2000);
                            
                            . tab ZHC
                            
                            ZHC | Freq. Percent Cum.
                            ------------+-----------------------------------
                            0 | 100 100.00 100.00
                            ------------+-----------------------------------
                            Total | 100 100.00
                            Thanks, Carlo, for your help with that. However, I think the data I listed here is just the first 100 obs, so in my data, I have 82230 obs. This is why you get the ZHC variable as just zero because the 100 obs for ZHC indicated value = 0 see below:

                            Code:
                            . tab ZHC
                            
                                    ZHC |      Freq.     Percent        Cum.
                            ------------+-----------------------------------
                                      0 |     80,996       98.50       98.50
                                      1 |      1,234        1.50      100.00
                            ------------+-----------------------------------
                                  Total |     82,230      100.00

                            Alos, the variable WEEK is repeated in the datasets ( the first 100 obs dese not show that )

                            Code:
                            xtset PERSID WEEK
                            repeated time values within panel
                            r(451);
                            What do you think I can do about this problem? Alternatively, is this model estimate give me a diff-in-diff estimation or not?
                            Code:
                            xtreg SUMHRS afterCovid19 ZHC DiD   i.quarter i.AGES  , fe

                            Note that DiD variable is created dummy variable, which indicates treatment group * time

                            Is this model the same as using xtdidregress?
                            Last edited by Ali Abutaleb; 15 Oct 2022, 10:34.

                            Comment


                            • #15
                              Ali;
                              1) this nuisance is really easy to manage. Just -xtset- your dataset with your -panelid- only, with the proviso that this fix comes at the cost of making time-series related operators (such as lags and leads) unfeasible;
                              2) a diff in diff can be run via -xtreg-. As usual the recipe implies treated/untreated and before/after dimensions.
                              Kind regards,
                              Carlo
                              (Stata 19.0)

                              Comment

                              Working...
                              X