STA 242/ENV 255: April 15, 1998

Logistic Regression

Assignment: Due THURSDAY April 23

  1. Problems 6-11 in Chapter 7
Suggested Reading:

Create the dataset

Create a SAS data set for the problem t.244 The variables are: donor age new treated dieldrin

Problem 6

To fit the model:

  1. Choose Analyze:Fit (Y X)
  2. Put Dieldrin in Y; Age, New and Treated in X
  3. Click on the Method button
  4. Click on Binomial under Response Dist.:
  5. Click the OK button in the Method window
  6. Click the Apply button
To determine which predictors are significant, look at the Pr > Chi-Sq colunm in the Parameter Estimates table. For the null hypothesis that all three are zero, look at the Pr > Scaled Deviance colunm in the Analysis of Deviance Table.


Problem 7

Interpret output. Remember the beta's measure the change in log odds, so you need to calculate exp(beta_i).

Problem 8

We need to get fitted values for the average age woman under the two scenarios. First thing to do is find the mean age. To do this, just use Analyze:Distribution

Use this to calculate the logit, b0 + b1*mean(Age) + b2*New + b3*Treated, under the different scenarios for New and Treated. Then transform the logit to get probabilities, p(high Dieldrin) = 1/(1 + exp(-logit)). You just need a calculator for this!


Problem 9

Create the two logits,
a)	la <- b0 + b1*Age + b2*0 + b3*0
b)	lb <- b0 + b1*Age + b2*1 + b3*1
and then transform to probabilities as in 7, pa = 1/(1 + exp(-la)) and pb = 1/(1 + exp(-lb)), Like so:

	data sasuser.rwg244;
	set sasuser.rwg244;
	la = -8.9734 + 0.2084*age;
	lb = -8.9734  + 0.2084*age +2.1408 + 2.5972;
	pa = 1/(1 + exp(-la));
	pb = 1/(1 + exp(-lb));
	run;
Now, to get the Conditional Effects Plot, Submit the following:

title1 'Conditional Effects Plot';
footnote1 f=special  'J J J' f=swiss ' Old Suburb, No Treatment';
footnote2  f=special 'D D D' f=swiss '  New Suburb, Treated';
symbol1 c=black  i=splines value=dot;
symbol2 c=black  i=splines value=diamond;
axis1 label=('Age');
axis2 label=('High' justify=left 'Dieldrin');
proc gplot data=sasuser.rwg244;
plot pa*age pb*age/overlay haxis=axis1  vaxis=axis2;
run;
This is like the plot commands we did last week!

Problem 10

First thing, you need to have some new variables!! You need the Standardized Pearson and Standardized Deviance Residuals. To get these, select Vars from the Fit SASUSER.RWG244 window (from problem 6). From there, choose Genearlized Residuals, then the Standardized residuals. They will show up in your data set as RPS_DIEL and RDS_DIEL. You also need to get the Hat Diag - select it from the Vars menu. It will show up as H_DIELDR.

Now, you are ready to construct your diagnostic variables. This requires some code to be entered into the Program Editor. First thing to do is to save your dataset under a new name (I used bob). Then, exit INSIGHT and Submit the following lines:


	data sasuser.bob;
	set sasuser.bob;
	deltaxp = rps_diel**2/(1-h_dieldr);
	deltaxd = rds_diel**2/(1-h_dieldr);
	deltab  =((rps_diel)**2*h_dieldr)/(1-h_dieldr)**2;
	run;
10a, is a pretty simple plot, but b & c require some SAS code to make the bubbles. Here's how to do it:

For 10b:
	title1 'Bubble Plot';
	footnote1 ' ';
	footnote2 ' ';
	proc gplot data=sasuser.bob;
	bubble deltaxp*p_dieldr=deltab;
	run;

Now, a similar idea for problem 10c:

For 10c:
	proc gplot data=sasuser.bob;
	bubble deltaxd*p_dieldr=deltab;
	run;


Problem 11

Refer to previous plots and output.