Announcement

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

  • How to recreate longitudinal analyses from SAS in STATA using xtgee only using SAS output???

    Hello all,

    I have been trying to recreate SAS output in Stata but keep getting discrepancies.

    First, I tried to check skewness and kurtosis and there was quite a discrepancy but I soon learned that is because SAS and Stata use different formulas.

    Now, I am trying to create GEE analyses but I am not getting the same results. SAS code below:

    %macro linearm(y);
    proc genmod data=a; class SBA Gcode (ref="Gentrifying") /param=ref;
    model &y = tm tm5 tm10 tm19 Gcode|tm Gcode|tm5 Gcode|tm10 Gcode|tm19 /dist=normal link=identity type3;
    repeated subject= SBA/type=AR ;
    %mend;
    %linearm(sallfd); %linearm(sallfd_d); run;
    %linearm(lhealthy); %linearm(sHealthyD); run;
    %linearm(lunhealthy); %linearm(sUnhealthyD); run;

    I have tried the following in Stata 16:
    xtset SBA year
    xtgee sAllfd tm tm5 tm10 tm19 i.Gcode Gcode#c.tm Gcode#c.tm5 Gcode#c.tm10 Gcode#c.tm19, family(gaussian) link(identity) corr(ar1)


    Would this be incorrect since xtgee provides fit population-averaged panel-data models by using GEE?

    Any help is most welcomed.
    Last edited by Brennan RBratton; 29 Oct 2019, 12:33. Reason: (edited bc I was able to get code from biostatistician )

  • #2
    Originally posted by Brennan RBratton View Post
    Would this be incorrect since xtgee provides fit population-averaged panel-data models by using GEE?
    But that's what PROC GENMOD; . . . REPEATED SUBJECT=. . .; fits, too, doesn't it?

    As far as getting discrepancies between SAS's PROC GENMOD and Stata's -xtgee-, especially with autoregressive correlation structures, you might want to take a look at this FAQ on StataCorp's website and scroll down to the heading Why do my xtgee results differ from the results produced by SAS Genmod?.

    Also, be sure to check whether the reference (omitted) category for the gentrification categorical explanatory variable is the same between SAS and Stata.

    Comment


    • #3
      That FAQ might not be pertinent to Stata 16, but it might be worth looking at that section anyway for some background into how things can differ.

      Comment


      • #4
        Hi Joseph,

        Thank you so much for your resource. It states, "With balanced data, xtgee and SAS version 6.12 Genmod will produce the same results if the correct options are specified. For models with family(Gaussian) and link(identity), the default options for each correlation structure produce matching results." My data is "strongly balanced" and I use family(Gaussian) and link(identity). Given this, I was sure to have the same results. However, it does state "For more complex correlation structures, it is not possible to back out the specific differences between the packages." Since I use autocorrelation (ar1) I think this may be the cause of the discrepancies.

        I will try to get to someone with SAS and rerun with and without ar(1) and compare the results to see if that is the cause.

        In regards to the reference category for the gentrification categorical explanatory variable, it is the same between SAS and Stata.

        Thanks!
        Brennan

        Comment

        Working...
        X