BookmarkSubscribeRSS Feed
Kyra
Quartz | Level 8

Hi,

 

I want to calculate Confidence interval for attributable risk percent and population attributable risk percent ,in multivariable model.

 

I have used the following formulas to calculate the risks. I derived adjusted OR using proc logistic.

I was wondering how should i calculate CI for them ?

 

Adjusted Odds Ratio and CI from SAS

neverexposed 0 vs 1

1.2711.1781.371

 

Attributable risk percent is ( AOR-1/AOR) = (1.271-1/1.271)*100= 21.3%
Population Attributable risk percent   PEC × (AOR – 1)/AOR= (6029/8839) (1.271- 1/1.271)*100= 14.5%.
 
Thanks
 
Odds Ratio EstimatesEffect Point Estimate 95% WaldConfidence Limitsstudyname Centraleurope vs Western Europestudyname France multi (1989-1 vs Western Europestudyname France multi (2001-2 vs Western Europestudyname Germany-Heidelberg vs Western Europestudyname Germany-Saarland vs Western Europestudyname Latin America vs Western Europestudyname MSKCC vs Western Europestudyname New York Multicenter vs Western Europestudyname SaoPaulo vs Western Europestudyname Seattle-Leo vs Western Europestudyname Tampa vs Western Europeageq 40-44 vs <40ageq 45-49 vs <40ageq 50-54 vs <40ageq 55-59 vs <40ageq 60-64 vs <40ageq 65-69 vs <40ageq 70-74 vs <40ageq 75+ vs <40sex Male vs Femaleeducation_levelmi1 =College graduate vs No educationeducation_levelmi1 =Junior high school vs No educationeducation_levelmi1 High school graduate vs No educationeducation_levelmi1 Missing vs No educationeducation_levelmi1 Some high school vs No educationeducation_levelmi1 Technical school, some college vs No educationrace Asian and Pacific Islanders vs Whiterace Black vs Whiterace Hispanic vs Whiterace Missing vs Whiterace Others vs Whitedrink_dayq 4 vs 0 (Non-drinkers)drink_dayq 0.1-0.9 vs 0 (Non-drinkers)drink_dayq 1.0-2.9 vs 0 (Non-drinkers)drink_dayq 3.0-4.9 vs 0 (Non-drinkers)drink_dayq Missing vs 0 (Non-drinkers)tobaccoyearq 0-10.0 vs 0 (Never smoker)tobaccoyearq 10.1-20.0 vs 0 (Never smoker)tobaccoyearq 20.1-30.0 vs 0 (Never smoker)tobaccoyearq 30.1-40.0 vs 0 (Never smoker)tobaccoyearq 40.1-50.0 vs 0 (Never smoker)tobaccoyearq 50.0+ vs 0 (Never smoker)tobaccoyearq Missing vs 0 (Never smoker)neverexposed 0 vs 1
5.0144.2595.903
4.4303.6365.396
4.0943.6014.655
1.1900.9731.454
4.8133.3396.937
4.3333.7545.002
6.2634.7048.340
0.7220.6020.867
4.8144.1545.578
1.8961.5262.355
1.9721.5932.440
0.9420.7501.181
1.2911.0481.589
1.4921.2211.824
1.2991.0651.584
1.2221.0001.493
1.1270.9191.382
1.0840.8801.337
1.4041.1121.773
0.7050.6410.776
0.2400.1820.317
0.5580.4340.718
0.4050.3100.529
>999.999<0.001>999.999
0.4190.3230.545
0.3150.2390.416
1.3240.3115.636
1.0370.7281.477
2.0791.1813.659
1.8200.4617.194
1.8710.5606.246
3.7793.3264.295
1.0530.9331.188
1.6061.4161.820
2.4222.0982.795
3.0272.5053.658
1.6531.4291.913
2.9902.6093.427
5.5804.8856.374
8.1637.1399.334
9.6168.32011.114
11.0419.73312.524
7.6746.4949.068
1.2711.1781.371
5 REPLIES 5
StatDave
SAS Super FREQ

As shown in this note, the attributable risk is defined as (R_e - R_u)/R_e, where R_e is the risk in the exposed group and R_u is the risk in the unexposed group. In a logistic model, these risks would be predicted event probabilities for your two groups and can be estimated (averaged over the other predictors) using the LSMEANS/ILINK statement. Since each risk is just a nonlinear function of the model parameters, the attributable risk is also a nonlinear function of the parameters. Such functions can be estimated using the NLEST macro. In the current release, SAS 9.4 TS1M6, the NLEST macro is available for immediate calling. In earlier releases, where it is known as the NLEstimate macro, it is available for download in this SAS Sample program

 

The following statements fit a logistic model to the seed germination data in the Example titled "Overdispersion" in the LOGISTIC documentation. For this example, we will use the SOIL variable as the exposure indicator variable, where SOIL =1 represents the exposed group. The LSMEANS statement provides estimates of the risk of response (germination) in each group averaged over the levels of the other predictor, CULT. The E option shows the coefficients of the linear combination of model parameters used for each estimate. In the DATA FD step below, the risk for each group is recomputed using those coefficients and the nonlinear inverse of the logit. The third row of that data set defines the attributable risk as shown above. The NLEST macro is then called to re-estimate the two risks (note the agree with the Mean column in the LSMEANS table) and estimate the attributable risk, along with tests and confidence intervals.

 

For the population attributable risk, the overall risk, R, is estimated by applying the inverse logit function to the average of the log odds for the two SOIL levels. The average log odds is the average of the two linear combinations shown in the LSMEANS coefficients table. For this model, that average is the intercept plus one-half of each of the CULT and SOIL parameter estimates.

 

proc logistic data=seeds;
   class cult soil / param=glm;
   model r/n=cult soil;
   lsmeans soil / e ilink;
   store out=log;
   run;
data fd; 
   length label f $32767; 
   infile datalines delimiter=',';
   input label f; 
   datalines;
   Risk soil=1,1/(1+exp(-(B_p1+0.5*B_p2+0.5*B_p3+B_p5)))
   Risk soil=0,1/(1+exp(-(B_p1+0.5*B_p2+0.5*B_p3+B_p4)))
   Attributable Risk,( 1/(1+exp(-(B_p1+0.5*B_p2+0.5*B_p3+B_p5)))-1/(1+exp(-(B_p1+0.5*B_p2+0.5*B_p3+B_p4))) ) / ( 1/(1+exp(-(B_p1+0.5*B_p2+0.5*B_p3+B_p5))) )
   Pop. Attr. Risk, ( 1/(1+exp(-(B_p1+0.5*B_p2+0.5*B_p3+0.5*B_p4+0.5*B_p5)))-1/(1+exp(-(B_p1+0.5*B_p2+0.5*B_p3+B_p4))) ) / ( 1/(1+exp(-(B_p1+0.5*B_p2+0.5*B_p3+0.5*B_p4+0.5*B_p5))) )
; %NLEst( instore=log, fdata=fd )

 

Kyra
Quartz | Level 8

Hi,

 

I tried running the SAS with your help. still have few questions. Please help!

 

I have SAS (r) Proprietary Software 9.4 (TS1M4). Outcome is case. exposure variable is neverexposed.

other variables are-   studyname  ageq  sex  Education_levelmi1  race  region  drink_dayq  tobaccoyearq

 

i tried running the following SAS codes -

proc logistic data=red.merged3;
class studyname ageq sex Education_levelmi1 race region drink_dayq tobaccoyearq neverexposed/ param=glm;
model case=studyname ageq sex Education_levelmi1 race region drink_dayq tobaccoyearq neverexposed;
lsmeans studyname ageq sex Education_levelmi1 race region drink_dayq tobaccoyearq / e ilink diff exp;
store out=log;
run;


data fd;
length label f $32767;
infile datalines delimiter=',';
input label f;
datalines;
Risk neverexposed=1,1/(1+exp(-(B_p1+0.5*B_p2+0.5*B_p3+B_p5)))
Risk neverexposed=0,1/(1+exp(-(B_p1+0.5*B_p2+0.5*B_p3+B_p4)))
Attributable Risk,( 1/(1+exp(-(B_p1+0.5*B_p2+0.5*B_p3+B_p5)))-1/(1+exp(-(B_p1+0.5*B_p2+0.5*B_p3+B_p4))) ) / ( 1/(1+exp(-(B_p1+0.5*B_p2+0.5*B_p3+B_p5))) )
;


%NLEst( instore=log, fdata=fd )

 

 

Log i got is below;

proc logistic data=red.merged3;
523 class studyname ageq sex Education_levelmi1 race region drink_dayq
523! tobaccoyearq neverexposed/ param=glm;
524 model case=studyname ageq sex Education_levelmi1 race region
524! drink_dayq tobaccoyearq neverexposed;
525 lsmeans studyname ageq sex Education_levelmi1 race region drink_dayq
525! tobaccoyearq / e ilink diff exp;
526 store out=log;
527 run;

NOTE: PROC LOGISTIC is modeling the probability that case='1'. One way
to change this to model the probability that case='2' is to
specify the response variable option EVENT='2'.
NOTE: Convergence criterion (GCONV=1E-8) satisfied.
NOTE: The LOGISTIC procedure generated the model item store WORK.LOG.
NOTE: There were 22569 observations read from the data set RED.MERGED3.
NOTE: PROCEDURE LOGISTIC used (Total process time):
real time 7.19 seconds
cpu time 1.40 seconds


528 data fd;
529 length label f $32767;
530 infile datalines delimiter=',';
531 input label f;
532 datalines;

NOTE: The data set WORK.FD has 3 observations and 2 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds


WARNING: Apparent invocation of macro NLEST not resolved.
536 ;
537
538
539 %NLEst( instore=log, fdata=fd )
-
180

ERROR 180-322: Statement is not valid or it is used out of proper order.

 

Plese let me know what should i do.

 

Thanks

 

StatDave
SAS Super FREQ

As I said, the NLEst (or equivalent NLEstimate) macro is only immediately available for use in the current release, SAS 9.4 TS1M6. For your earlier release, you will need to download the macro from the link I provided. Follow the instructions in the Usage section to make it available during your SAS session. 

 

You will not be able to simply copy and paste the code I used for the example I gave. What you specify in the f variable in the fdata= data set (or in the f= option) of the macro depends on the model that you are working with. This is all described and illustrated in the macro documentation and the many notes that show examples of using the macro.

StatDave
SAS Super FREQ

Note that your formula based on the odds ratio is only an approximation of the attributable risk when the event probability is small so that the odds ratio approximates the relative risk. In that case, your formula is approximately the same as an alternative formula for the attributable risk, (RR-1)/RR, where RR is the relative risk. 

Kyra
Quartz | Level 8

Thank you very much for your patience and quick response.

 

I was able to download the macro and make it available to use as you said. However , i still need to figure out what to put in below part as my model has multiple variables. If you have any resources for that, that will be great help. Thanks in advance.

 

Risk neverexposed=1,1/(1+exp(-(B_p1+0.5*B_p2+0.5*B_p3+B_p5)))
Risk neverexposed=0,1/(1+exp(-(B_p1+0.5*B_p2+0.5*B_p3+B_p4)))
Attributable Risk,( 1/(1+exp(-(B_p1+0.5*B_p2+0.5*B_p3+B_p5)))-1/(1+exp(-(B_p1+0.5*B_p2+0.5*B_p3+B_p4))) ) / ( 1/(1+exp(-(B_p1+0.5*B_p2+0.5*B_p3+B_p5))) )

 

 

%inc "C:\Users\khetap03\Desktop\three\nlestimate.sas";

proc logistic data=red.merged3;
class studyname ageq sex Education_levelmi1 race region drink_dayq tobaccoyearq neverexposed/ param=glm;
model case= studyname ageq sex Education_levelmi1 race region drink_dayq tobaccoyearq neverexposed;
lsmeans studyname ageq sex Education_levelmi1 race region drink_dayq tobaccoyearq / e ilink diff exp;
store out=log;
run;

data fd;
length label f $32767;
infile datalines delimiter=',';
input label f;
datalines;
Risk neverexposed=1,1/(1+exp(-(B_p1+0.5*B_p2+0.5*B_p3+B_p5)))
Risk neverexposed=0,1/(1+exp(-(B_p1+0.5*B_p2+0.5*B_p3+B_p4)))
Attributable Risk,( 1/(1+exp(-(B_p1+0.5*B_p2+0.5*B_p3+B_p5)))-1/(1+exp(-(B_p1+0.5*B_p2+0.5*B_p3+B_p4))) ) / ( 1/(1+exp(-(B_p1+0.5*B_p2+0.5*B_p3+B_p5))) )
;

%NLEstimate( instore=log, fdata=fd )

 

 

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 5 replies
  • 1191 views
  • 0 likes
  • 2 in conversation