/****************************************************************** CHAPTER 11, EXAMPLE 1 Fit a logistic regression model to the myocardial infarction data. ******************************************************************/ options ls=80 ps=59 nodate; run; /****************************************************************** The data look like (first 10 records) Obs id oral age smoke mi 1 1 1 33 1 0 2 2 0 32 0 0 3 3 1 37 0 1 4 4 0 36 0 0 5 5 1 50 1 1 6 6 1 40 0 0 ... [Discard Obs] column 1 subject id column 2 oral contraceptive indicator (0=no,1=yes) column 3 age (years) column 4 smoking indicator (0=no,1=yes) column 5 binary response -- whether MI has been suffered (0=no,1=yes) ******************************************************************/ data mi; infile 'infarc.dat'; input id oral age smoke mi; run; proc print data=mi; run; /****************************************************************** Simple model,with 1 covariate (Age) Model: logit(P(MI_j=1)) = beta_0 +beta_1 Age_j ******************************************************************/ proc genmod data=mi descending; model mi = age / dist = binomial link = logit; estimate "age log odds ratio" int 1 age 34 / exp; run; /****************************************************************** Analysis Of Maximum Likelihood Parameter Estimates Standard Wald 95% Wald Parameter DF Estimate Error Confidence Limits Chi-Square Pr > ChiSq Intercept 1 -6.9987 1.4226 -9.7869 -4.2106 24.20 <.0001 age 1 0.1586 0.0384 0.0835 0.2338 17.11 <.0001 Scale 0 1.0000 0.0000 1.0000 1.0000 NOTE: The scale parameter was held fixed. ## Write down the estimated logistis regression: Label Estimate Confidence Limits Estimate Error age log odds ratio 0.1673 0.1173 0.2330 -1.6049 0.2109 Exp(age log odds ratio) 0.2009 0.0424 Contrast Estimate Results L'Beta Chi- Label Alpha Confidence Limits Square Pr > ChiSq age log odds ratio 0.05 -2.0182 -1.1916 57.93 <.0001 Exp(age log odds ratio) 0.05 0.1329 0.3037 ******************************************************************/ /****************************************************************** Full model,with all covariates Model: logit(P(MI_j=1)) = beta_0 +beta_1 Age_j + beta_2 OralC_j+beta_3 Smoke_j ******************************************************************/ /***************************************************************** Fit the logistic regression model using PROC GENMOD. We do not use a CLASS statement here, as the covariates are either continuous (AGE) or already in "dummy" form (ORAL, SMOKE). The model statement with the LINK=LOGIT option results in the logistic regression model in equation (10.21). The DIST=BINOMIAL specifies the Bernoulli distribution, which is the simplest case of a binomial distribution. In versions 7 and higher of SAS, PROC GENMOD will model by default the probability that the response y=0 rather than the conventional y=1! To make PROC GENMOD model probability y=1, as is standard, one must include the DESCENDING option in the PROC GENMOD statement. In earlier versions of SAS, the probability y=1 is modeled by default, as would be expected. If the user is unsure which probability is being modeled, one can check the .log file. In later versions of SAS, an explicit statement about what is being modeled will appear. PROC GENMOD output should also contain a statement about what is being modeled. ******************************************************************/ proc genmod data=mi descending; model mi = oral age smoke / dist = binomial link = logit; estimate "smk log odds ratio" int 0 oral 0 age 0 smoke 1 / exp; run; /***************************************************************** Analysis Of Maximum Likelihood Parameter Estimates Standard Wald 95% Wald Parameter DF Estimate Error Confidence Limits Chi-Square Pr > ChiSq Intercept 1 -9.1140 1.7571 -12.5579 -5.6702 26.90 <.0001 oral 1 1.9799 0.4697 1.0593 2.9005 17.77 <.0001 age 1 0.1626 0.0445 0.0753 0.2498 13.32 0.0003 smoke 1 1.8122 0.4294 0.9706 2.6538 17.81 <.0001 Scale 0 1.0000 0.0000 1.0000 1.0000 Write down the estimated logistic regression model Interpret the parameters *****************************************************************/