Announcement

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

  • margins after svy

    I am looking at the differences in wages for specific occupations by marital status. Note marital status is coded as 0=married, 1=single, 2=divorced/separated/widowed. My code for the regression is:

    xi: svy, subpop(if occ1==1): glm wages i.maritalstatus age agesq experience female i.race metro hrsworked familyincome, family(gamma) link(log)

    After running the above (which runs successfully), I try to get the predicted mean wages for specific occupation by marital status for female. My code is as follows:

    margins, dydx(maritalstatus) subpop(if occ1==1) at(female==1)

    The margins command is unable to recognize maritalstatus as a categorical variable and gives me the following error:

    invalid dydx() option;
    'maritalstatus' not found in list of covariates


    What am I doing wrong? Thank you for your help.

  • #2
    Drop the xi prefix. It is outdated and usually unneeded. See if it runs then.
    -------------------------------------------
    Richard Williams, Notre Dame Dept of Sociology
    StataNow Version: 19.5 MP (2 processor)

    EMAIL: [email protected]
    WWW: https://academicweb.nd.edu/~rwilliam/

    Comment


    • #3
      While you're at it, let's fully bring this code into the modern era. Don't use age and agesq, use c.age##c.age. That way, if you later do some -margins- calculations that involve age, Stata will handle the quadratic term correctly.

      Comment


      • #4
        While you are at it, if they are dichotomies then do i.female and i.metro.

        I also don't think your use of subpop on the margins command is legal. At least I've never seen it used that way. Once you have cleaned up the xi: related error you'll be able to see if you have other errors.
        -------------------------------------------
        Richard Williams, Notre Dame Dept of Sociology
        StataNow Version: 19.5 MP (2 processor)

        EMAIL: [email protected]
        WWW: https://academicweb.nd.edu/~rwilliam/

        Comment

        Working...
        X