data challenger;
infile 'challenger2.txt' firstobs=2;
input temp fail;
run;
/* a couple of SAS procs fit logistic regression */
proc logistic;
model fail(descending) = temp /clparm = both;
output out=diags predicted = pred xbeta=linpred
reschi=Pearson resdev=deviance;
run;
/* by default, SAS gives the probability of the smallest level of FAIL */
/* so model fail=temp; would model P[fail=0] = P[not failing] */
/* fail(descending) flips that around, so have model of P[fail=1] = P[fail] */
/* fail(event=1) does the same thing by explicitly indicating the event of interest */
/* can include a class statement to create and fit design matrices */
/* clparm calculates confidence intervals for parameters */
/* = wald gives Wald intervals, =pl gives profile likelihood and =both gives both */
/* to change the link, add /link=probit or /link=cloglog */
/* lots of bells and whistles: variable seletion, calculations of odds ratios */
/* the output statement writes observation-specific information to a data set */
/* the keywords identify want is requested */
/* in the order of the above output statement, they are:
predicted probability, linear predictor, pearson Chi-square residual
and Deviance residual */
/* LOTS of other statements for specific tasks, including exact (non-asymptotic) inference */
/* can also use the generalized linear model procedure. */
proc genmod data=challenger descending;
model fail = temp / d=binomial lrci;
output out= resids pred=pred xbeta = linear
reschi = pearson resdev = deviance;
run;
/* differences from logistic:
descending goes in the proc statement
/d = binomial specifies the distribution of Y
many more diagnostics available in output
the lrci option provides the profile confidence interval
the cl option provides the wald confidence interval
*/