Announcement

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

  • Reproduce SAS Genmod in Stata

    I am trying to reproduce a GLM in Stata that I originally created in SAS. Although my estimates are exactly the same, the standard errors are not, and I'm not quite sure why. I tested all of the vce options in Stata, but the errors still do not match. Note that cost is continuous while treatment, var1, and var2 are all categorical. Here is both codes:

    SAS
    Code:
    proc genmod data=data;
     class clinician treatment var1 var2 / param=ref;
     model cost = treatment var1 var2/ link=LOG dist=gamma;
    repeated SUBJECT=clinician/ PRINTMLE TYPE=ind;
    run;
    Stata
    Code:
    glm cost i.treatment i.var1 i.var2, f(gam) l(log) cluster(clinician)
    Appreciate the help.
    Last edited by Jon Heintz; 07 Sep 2022, 07:23.

  • #2
    I can't really answer your question except to suggest perhaps looking at the code underlying the glm command in Stata:

    Code:
    viewsource glm.ado

    Comment


    • #3
      Originally posted by Jon Heintz View Post
      I am trying to reproduce a GLM in Stata that I originally created in SAS. Although my estimates are exactly the same, the standard errors are not, and I'm not quite sure why. . . .
      Code:
      proc genmod  . . .;
      . . .;
      repeated SUBJECT=. . .;
      I take it that you've already looked at this xtgee-related FAQ on StataCorp's website, and perhaps this post on the old Statlist.

      Comment


      • #4
        Joseph Coveney, thank you, and yes I looked at both of those. I understand the estimation algorithm is slightly different; however, the errors are different enough to change the significance and I'm not which to trust.

        Comment


        • #5
          It turns out that the intro to PROC GENMOD, which does fit GLMs, says this:

          The GENMOD procedure can fit models to correlated responses by the GEE method. You can use PROC GENMOD to fit models with most of the correlation structures from Liang and Zeger (1986) by using GEEs. For more details on GEEs, see Hardin and Hilbe (2003); Diggle, Liang, and Zeger (1994); Lipsitz et al. (1994).
          and the REPEATED statement does seem to cause it to fit a GEE. Yours specifies type = independent, I.e. independence working correlation.
          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


          • #6
            Figured it out. The answer is twofold.

            1) As Joseph Coveney said, Genmod and Stata estimate the scale parameter and correlation structure slightly differently. Details are given on xtgee-related FAQ.

            2) Genmod by default produces score tests while Stata produces Wald tests. Wald tests can be requested for SAS, but score tests cannot be produced by Stata.

            Comment

            Working...
            X