Skip to content

Plotting the probability curve from a logit model with 10 predictors

7 messages · Abraham Mathew, Bert Gunter, Greg Snow +2 more

#
Look at the Predict.Plot and TkPredict functions in the TeachingDemos
package.  These will not plot all 11 dimensions at once, but will plot
2 of the dimensions conditioned on the others.  You can then change
the conditioning to see relationships.

These use base rather than ggplot graphics.
On Thu, Jul 5, 2012 at 3:39 PM, Abraham Mathew <abmathewks at gmail.com> wrote:

  
    
#
On Jul 6, 2012, at 4:30 PM, Abraham Mathew wrote:

            
Assuming, that is, you also understand what Y is. From you comments so  
far, I have some nagging worries regarding your understanding of that  
point.
#
Try the following:

 library(TeachingDemos)
 ?TkPredict
      fit.glm1 <- glm( Species=='virginica' ~ Sepal.Width+Sepal.Length,
              data=iris, family=binomial)
       TkPredict(fit.glm1)

(you may need to install the TeachingDemos package first if you don't
already have it installed)

You will now see a plot that shows the predicted probability compared
to one of the predictor variables, there are controls that you can
then change which variable is shown on the x axis and what the value
of the other variables are.  Play with the controls to see the effects
of the different variables.  You can now do the same thing with other
logistic regression models.  This also works to show nonlinear
(polynomial, spline, etc.) fits of the variables and interactions.
There is a button that you can click that will show the command to
create the same plot in regular R graphics, and you can then use that
command (and change add=TRUE to overlay multiple ones) to create a
static plot showing the relationship.
On Fri, Jul 6, 2012 at 2:30 PM, Abraham Mathew <abmathewks at gmail.com> wrote:

  
    
1 day later
#
Also: require(rms); ?plot.Predict
Frank

Greg Snow wrote
-----
Frank Harrell
Department of Biostatistics, Vanderbilt University
--
View this message in context: http://r.789695.n4.nabble.com/Plotting-the-probability-curve-from-a-logit-model-with-10-predictors-tp4635563p4635846.html
Sent from the R help mailing list archive at Nabble.com.