|
|
|
||||
|
|
|||||
This page shows how to use some macros that we have developed for graphing regression lines from Logistic regression. These graphs allow you to display the relationship between the P(Y=1) and X, and how that relationship varies as a function of the regression coefficients a and b. These macros create .gif files that you can display over the web, and can create animated .gif files that show movies of how the regression curve changes as a changes, or as b changes.
The follwoing links will take you to SAS macros with the respective names; %grlog, %grloga, and %gifinit. You can learn more about using these macros from the help file for %grlog , %grloga, or %gifinit.
Once you have downloaded this package, let's use the %gifinit and %grlog macros to make a graph showing a logistic regression curve using the commands shown below.
%gifinit; %grlog;
This creates a file called c:\graph.gif as shown below. This graph shows a logistic regression curve with the probability that Y=1 on the left, and the predictor, x, on the bottom. Since we did not specify the values for the coefficients, the default values (a=0 and b=.5) were selected.

You probably do not always want to have a graph called c:\graph.gif and probably do not always want a graph where a=0 and b=.5. Below, we make a graph called c:\teaching\log1.gif with a=.3 and b=1.2.
%gifinit(fname=c:\teaching\log1.gif); %grlog(a=.3,b=1.2);
Below we see this graph. We should clarify that the graph did have the name c:\teaching\log1.gif , and then we copied the file log1.gif to our web server, and that file is shown below.

You could make a series of graphs that show how the regression curve changes as b changes. Below we make four small graphs that show the logistic curve when b is .8, .3, -.3 and -.8.
%gifinit(fname=c:\teaching\log3a.gif,h=300,v=200); %grlog(a=.3,b= .8); %gifinit(fname=c:\teaching\log3b.gif,h=300,v=200); %grlog(a=.3,b= .3); %gifinit(fname=c:\teaching\log3c.gif,h=300,v=200); %grlog(a=.3,b= -.3); %gifinit(fname=c:\teaching\log3d.gif,h=300,v=200); %grlog(a=.3,b= -.8);
And below we can see the graph looks just the same, but just with smaller dimensions. This could be useful if you wanted to have a small thumbnail graph like the one below, which links to a larger version. In fact, we have linked the graph below to the larger size graph, so we could have just included this thumbnail graph, which people could have clicked on if they wanted to see a bigger version.




You can make as many of these as you like, but if a picture is worth a thousand words, would a movie be worth a million words? You can make animated graphs (that look like little movies) that show how the logistic regression curve changes as b goes from 1 to -1, as shown below using the %grloga macro.
%gifinit(fname=c:\teaching\log4.gif,h=300,v=200); %grloga(a=.3,vary=b);
You can view the animated gif by clicking on log4.gif
The previous gif varied b from 1 to -1 in increments of .1. Below, we vary b from 2 to -2 in increments of .05, and we reduce the delay between frames to 10 (from the default of 50).
%gifinit(fname=c:\teaching\log5.gif,h=300,v=200); goptions delay=10; %grloga(a=.3,vary=b,hi=2,lo=-2,inc=0.05);
You can view the animated gif by clicking on log5.gif
UCLA Researchers are invited to our Statistical Consulting Services
We recommend others to our list of Other Resources for Statistical Computing Help
These pages are Copyrighted (c) by UCLA Academic Technology Services