| Date: | Wed, 11 Jun 2008 14:56:13 -0700 |
| Reply-To: | stringplayer_2@yahoo.com |
| Sender: | "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU> |
| From: | Dale McLerran <stringplayer_2@YAHOO.COM> |
| Subject: | Re: Relative risks and risk differences in SAS? |
| In-Reply-To: | <00b001c8cbfd$508c8550$832fa8c0@HP82083701405> |
| Content-Type: | text/plain; charset=us-ascii |
|---|
Mary,
You could generate both odds ratios and relative risks from a logistic
regression fitted using the procedure NLMIXED. Referencing the eyestudy
data available at the UCLA stats page which you linked to in your post,
one can fit
proc nlmixed data=eyestudy;
/* Code for fitting a logistic regression with logit link */
eta = b0 + b1*(carrot=0);
p = exp(eta) / (1 + exp(eta));
ll = (lenses=1)*log(p) + (lenses=0)*log(1-p);
model lenses ~ general(ll);
/* Code for obtaining risk estimates, RR, and OR */
py1_car0 = exp(b0 + b1) / (1 + exp(b0 + b1));
py1_car1 = exp(b0) / (1 + exp(b0));
estimate "P(y=1|carrot=0)" py1_car0;
estimate "P(y=1|carrot=1)" py1_car1;
estimate "Relative Risk " py1_car0 / py1_car1;
estimate "Odds Ratio " exp(b1);
run;
If you are using PROC GENMOD, you must invoke it twice, once with a
logit link and once with a log link, in order to obtain both odds
ratios and relative risks. You can compare the odds ratios and relative
risk estimates from the above code with estimates of those same
parameters obtained from the procedure GENMOD. The estimates are
identical for the problem where you have a single categorical predictor
variable.
Note that the log-link can be problematic if you have more than one
predictor or if you have a continuous predictor. With the log-link,
you can end up generating probability estimates which exceed 1. Thus,
it may be preferable to use the logit link to estimate the probabilities
of the response under various model conditions and then compute the
risk ratio with code similar to that demonstrated above.
Consider adding gender as a risk factor in the eye data referenced on
the UCLA stats page. Note that wben a second risk factor (gender) is
added to the model for carrot exposure, one can then compute risk
ratios for carrot exposure separately for different levels of the
second risk factor (males vs females) and one can construct a test
of the difference in these risk ratios. The code below demonstrates:
proc nlmixed data=eyestudy;
/* Code for fitting a logistic regression with logit link */
eta = b0 + b1*(carrot=0) + b2*(gender=1);
p = exp(eta) / (1 + exp(eta));
ll = (lenses=1)*log(p) + (lenses=0)*log(1-p);
model lenses ~ general(ll);
/* Code for obtaining risk estimates, RR, and OR */
py1_car0_sex1 = exp(b0 + b1 + b2) / (1 + exp(b0 + b1 + b2));
py1_car1_sex1 = exp(b0 + b2) / (1 + exp(b0 + b2));
py1_car0_sex2 = exp(b0 + b1) / (1 + exp(b0 + b1));
py1_car1_sex2 = exp(b0) / (1 + exp(b0));
/* Risk estimates for gender=1 */
estimate "P(y=1|carot=0, gender=1)" py1_car0_sex1;
estimate "P(y=1|carot=1, gender=1)" py1_car1_sex1;
estimate "Relative Risk| gender=1 " py1_car0_sex1 / py1_car1_sex1;
/* Risk estimates for gender=2 */
estimate "P(y=1|carot=0, gender=2)" py1_car0_sex2;
estimate "P(y=1|carot=1, gender=2)" py1_car1_sex2;
estimate "Relative Risk| gender=2 " py1_car0_sex2 / py1_car1_sex2;
/* Test of difference in relative risk across genders */
estimate "Relative Risk: male vs female"
(py1_car0_sex1/py1_car1_sex1) -
(py1_car0_sex2/py1_car1_sex2);
/* Within gender relative risk, averaged */
estimate "Average Relative Risk" ((py1_car0_sex1/py1_car1_sex1) +
(py1_car0_sex2/py1_car1_sex2)) / 2;
estimate "Odds Ratio for carrot" exp(b1);
run;
Besides possible numerical problems which could be encountered with
a log link (probability estimates which exceed 1), I don't believe
that one can compute a test of difference in risk ratios using the
GENMOD procedure. Thus, the NLMIXED procedure seems to me superior to
the GENMOD procedure for estimating and testing statements about relative
risk when you have multiple risk factors.
HTH,
Dale
---------------------------------------
Dale McLerran
Fred Hutchinson Cancer Research Center
mailto: dmclerra@NO_SPAMfhcrc.org
Ph: (206) 667-2926
Fax: (206) 667-5977
---------------------------------------
--- On Wed, 6/11/08, Mary <mlhoward@AVALON.NET> wrote:
> From: Mary <mlhoward@AVALON.NET>
> Subject: Re: Relative risks and risk differences in SAS?
> To: SAS-L@LISTSERV.UGA.EDU
> Date: Wednesday, June 11, 2008, 12:56 PM
> Thanks, and also to a few responses offlist.
>
> I did find a nice website with an example. It is:
> http://www.ats.ucla.edu/STAT/sas/faq/relative_risk.htm
>
> Though I found that I wanted to use the reference parameter
> in my class statement, so I wound up with:
>
> proc genmod data=set2 descending;
>
> class var1(param=ref ref='0') ;
>
> model disease=var1/dist=binomial link=log;
>
> estimate 'Beta' var1 1 -1 /exp;
>
> run;
>
> -Mary
>
> ----- Original Message -----
> From: Nordlund, Dan (DSHS/RDA)
> To: SAS-L@LISTSERV.UGA.EDU
> Sent: Wednesday, June 11, 2008 2:34 PM
> Subject: Re: Relative risks and risk differences in SAS?
>
>
> > -----Original Message-----
> > From: SAS(r) Discussion
> [mailto:SAS-L@LISTSERV.UGA.EDU] On
> > Behalf Of Mary
> > Sent: Wednesday, June 11, 2008 11:04 AM
> > To: SAS-L@LISTSERV.UGA.EDU
> > Subject: Relative risks and risk differences in SAS?
> >
> > Hi,
> >
> > I just got a request for relative risks- here is is:
> >
> > Do you know if your statistics package can estimate
> relative risks and
> >
> > risk differences based on odds ratios and known or
> estimated
> >
> > population fraction of cases (prevalence)? I was
> reading through a
> >
> > paper by Gary King
> (http://gking.harvard.edu/files/abs/1s-abs.shtml)
> >
> > and was wondering if the relative risk or risk
> reduction of having a
> >
> > particular SNP would be easier to understand than
> just p-values or
> >
> > odds ratios.
> >
> >
> >
> > I'm not familiar with this- does anyone know how
> this is done in SAS?
> >
> >
> >
> > -Mary
> >
>
> Mary,
>
> PROC FREQ will report relative risk if you have the
> counts. You will need more than an odds ratio and
> prevalence to get to relative risk. You will need the
> individual odds that make up the odds ratio.
>
> I'm not sure that relative risks are any more
> understandable than odds ratios (well maybe a little, but
> people can easily get confused with relative risks).
> Relative risks can change markedly depending on whether you
> are looking at the probabilility of occurrence or
> non-occurrence.
>
> Here is an excellent, simple comparison of odds ratios
> and relative risks.
>
> http://www.childrensmercy.org/stats/journal/oddsratio.asp
>
> Hope this is somewhat helpful,
>
> Dan
>
> Daniel J. Nordlund
> Washington State Department of Social and Health Services
> Planning, Performance, and Accountability
> Research and Data Analysis Division
> Olympia, WA 98504-5204
|