• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
The Analysis Factor

The Analysis Factor

Statistical Consulting, Resources, and Statistics Workshops for Researchers

  • Home
  • Our Programs
    • Membership
    • Online Workshops
    • Free Webinars
    • Consulting Services
  • About
    • Our Team
    • Our Core Values
    • Our Privacy Policy
    • Employment
    • Collaborate with Us
  • Statistical Resources
  • Contact
  • Blog
  • Login

OptinMon 02 - Binary, Ordinal, and Multinomial Logistic Regression...

Link Functions and Errors in Logistic Regression

by Karen Grace-Martin 5 Comments

I recently held a free webinar in our The Craft of Statistical Analysis program about Binary, Ordinal, and Nominal Logistic Regression.

It was a record crowd and we didn’t get through everyone’s questions, so I’m answering some here on the site. They’re grouped by topic, and you will probably get more out of it if you watch the webinar recording. It’s free.

The following questions refer to this logistic regression model: [Read more…] about Link Functions and Errors in Logistic Regression

Tagged With: Binary Logistic Regression, error term, link function, logit, logit link

Related Posts

  • What is a Logit Function and Why Use Logistic Regression?
  • How to Decide Between Multinomial and Ordinal Logistic Regression Models
  • The Difference Between Logistic and Probit Regression
  • Logistic Regression Models for Multinomial and Ordinal Variables

Generalized Linear Models in R, Part 5: Graphs for Logistic Regression

by guest contributer 2 Comments

by David Lillis, Ph.D.

In my last post I used the glm() command in R to fit a logistic model with binomial errors to investigate the relationships between the numeracy and anxiety scores and their eventual success.

Now we will create a plot for each predictor. This can be very helpful for helping us understand the effect of each predictor on the probability of a 1 response on our dependent variable.

We wish to plot each predictor separately, so first we fit a separate model for each predictor. This isn’t the only way to do it, but one that I find especially helpful for deciding which variables should be entered as predictors.

model_numeracy <- glm(success ~ numeracy, binomial)
 summary(model_numeracy)
Call:
glm(formula = success ~ numeracy, family = binomial)

Deviance Residuals: 
   Min       1Q   Median       3Q     Max 
-1.5814 -0.9060   0.3207   0.6652   1.8266 

Coefficients:
           Estimate Std. Error z value Pr(>|z|)   
(Intercept) -6.1414     1.8873 -3.254 0.001138 ** 
numeracy     0.6243     0.1855   3.366 0.000763 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

(Dispersion parameter for binomial family taken to be 1)

   Null deviance: 68.029 on 49 degrees of freedom
Residual deviance: 50.291 on 48 degrees of freedom
AIC: 54.291

Number of Fisher Scoring iterations: 5

We do the same for anxiety.

model_anxiety <- glm(success ~ anxiety, binomial)

summary(model_anxiety)
Call:
glm(formula = success ~ anxiety, family = binomial)

Deviance Residuals: 
   Min       1Q   Median       3Q     Max 
-1.8680 -0.3582   0.1159   0.6309   1.5698 

Coefficients:
           Estimate Std. Error z value Pr(>|z|)   
(Intercept) 19.5819     5.6754   3.450 0.000560 ***
anxiety     -1.3556    0.3973 -3.412 0.000646 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

(Dispersion parameter for binomial family taken to be 1)

   Null deviance: 68.029 on 49 degrees of freedom
Residual deviance: 36.374 on 48 degrees of freedom
AIC: 40.374

Number of Fisher Scoring iterations: 6

Now we create our plots. First we set up a sequence of length values which we will use to plot the fitted model. Let’s find the range of each variable.

range(numeracy)
 [1] 6.6 15.7

range(anxiety)
 [1] 10.1 17.7

Given the range of both numeracy and anxiety. A sequence from 0 to 15 is about right for plotting numeracy, while a range from 10 to 20 is good for plotting anxiety.

xnumeracy <-seq (0, 15, 0.01)

ynumeracy <- predict(model_numeracy, list(numeracy=xnumeracy),type="response")

Now we use the predict() function to set up the fitted values. The syntax type = “response” back-transforms from a linear logit model to the original scale of the observed data (i.e. binary).

plot(numeracy, success, pch = 16, xlab = "NUMERACY SCORE", ylab = "ADMISSION")

lines(xnumeracy, ynumeracy, col = "red", lwd = 2)

image001The model has produced a curve that indicates the probability that success = 1 to the numeracy score.  Clearly, the higher the score, the more likely it is that the student will be accepted.

Now we plot for anxiety.

xanxiety <- seq(10, 20, 0.1)

yanxiety <- predict(model_anxiety, list(anxiety=xanxiety),type="response")

plot(anxiety, success, pch = 16, xlab = "ANXIETY SCORE", ylab = "SUCCESS")

lines(xanxiety, yanxiety, col= "blue", lwd = 2)

image002Clearly, those who score high on anxiety are unlikely to be admitted, possibly because their admissions test results are affected by their high level of anxiety.

****

See our full R Tutorial Series and other blog posts regarding R programming.

About the Author: David Lillis has taught R to many researchers and statisticians. His company, Sigma Statistics and Research Limited, provides both on-line instruction and face-to-face workshops on R, and coding services in R. David holds a doctorate in applied statistics.

Bookmark and Share

Tagged With: generalized linear models, GLM, logistic regression, predicted probability, R

Related Posts

  • Generalized Linear Models (GLMs) in R, Part 4: Options, Link Functions, and Interpretation
  • Generalized Linear Models in R, Part 2: Understanding Model Fit in Logistic Regression Output
  • Generalized Linear Models in R, Part 1: Calculating Predicted Probability in Binary Logistic Regression
  • Generalized Linear Models in R, Part 3: Plotting Predicted Probabilities

Measures of Predictive Models: Sensitivity and Specificity

by Karen Grace-Martin 5 Comments

Not too long ago, I was  in Syracuse for a family trip to the zoo. Syracuse is about 60 miles from where I live and it has a very nice little zoo.

This year was particularly exciting because a Trader Joe’s just opened in Syracuse.  We don’t have one where we live (sadly!)  so we always stock up on our favorite specialty groceries when we’re near a Trader Joe’s.

On this particular trip, though, we had an unwelcome surprise.  My credit card card company believed my Trader Joe’s spree was fraudulent and declined the transaction.  I got a notice on my phone and was able to fix it right away, so it wasn’t the big inconvenience it could have been.

But this led us to wonder what it was about the transaction that led the bank to believe it was fraudulent.  Do credit card thieves often skip town and go grocery shopping?

The bank was clearly betting so.  It must have a model for aspects of a transaction that are likely enough to be fraudulent that it shuts it down.  [Read more…] about Measures of Predictive Models: Sensitivity and Specificity

Tagged With: logistic regression, model accuracy, ROC Curve, sensitivity, specificity

Related Posts

  • What Is an ROC Curve?
  • Member Training: Explaining Logistic Regression Results to Non-Researchers
  • How to Decide Between Multinomial and Ordinal Logistic Regression Models
  • When to Use Logistic Regression for Percentages and Counts

What is a Logit Function and Why Use Logistic Regression?

by Karen Grace-Martin 16 Comments

One of the big assumptions of linear models is that the residuals are normally distributed.  This doesn’t mean that Y, the response variable, has to also be normally distributed, but it does have to be continuous, unbounded and measured on an interval or ratio scale.

Unfortunately, categorical response variables are none of these. [Read more...] about What is a Logit Function and Why Use Logistic Regression?

Tagged With: Binary Logistic Regression, logit, logit function, logit link

Related Posts

  • Link Functions and Errors in Logistic Regression
  • How to Decide Between Multinomial and Ordinal Logistic Regression Models
  • Logistic Regression Models for Multinomial and Ordinal Variables
  • When Linear Models Don’t Fit Your Data, Now What?

Generalized Linear Models in R, Part 2: Understanding Model Fit in Logistic Regression Output

by guest contributer 3 Comments

by David Lillis, Ph.D.

In the last article, we saw how to create a simple Generalized Linear Model on binary data using the glm() command. We continue with the same glm on the mtcars data set [Read more…] about Generalized Linear Models in R, Part 2: Understanding Model Fit in Logistic Regression Output

Tagged With: AIC, Akaike Information Criterion, deviance, generalized linear models, GLM, Hosmer Lemeshow Goodness of Fit, logistic regression, R

Related Posts

  • Generalized Linear Models in R, Part 5: Graphs for Logistic Regression
  • Generalized Linear Models (GLMs) in R, Part 4: Options, Link Functions, and Interpretation
  • Generalized Linear Models in R, Part 3: Plotting Predicted Probabilities
  • Generalized Linear Models in R, Part 1: Calculating Predicted Probability in Binary Logistic Regression

SPSS Procedures for Logistic Regression

by Karen Grace-Martin 7 Comments

Need to run a logistic regression in SPSS? Turns out, SPSS has a number of procedures for running different types of logistic regression.

Some types of logistic regression can be run in more than one procedure.  For some unknown reason, some procedures produce output others don’t.  So it’s helpful to be able to use more than one.

Logistic Regression

SPSS Binary Logistic Regression MenuLogistic Regression can be used only for binary dependent [Read more…] about SPSS Procedures for Logistic Regression

Tagged With: genlin, logistic regression, nomreg, plum, SPSS

Related Posts

  • Opposite Results in Ordinal Logistic Regression, Part 2
  • Opposite Results in Ordinal Logistic Regression—Solving a Statistical Mystery
  • Dummy Code Software Defaults Mess With All of Us
  • Member Training: Explaining Logistic Regression Results to Non-Researchers

  • « Go to Previous Page
  • Go to page 1
  • Go to page 2
  • Go to page 3
  • Go to page 4
  • Go to Next Page »

Primary Sidebar

This Month’s Statistically Speaking Live Training

  • Member Training: A Gentle Introduction to Bootstrapping

Upcoming Free Webinars

Getting Started with R
3 Overlooked Strengths of Structural Equation Modeling
4 Critical Steps in Building Linear Regression Models

Upcoming Workshops

    No Events

Copyright © 2008–2022 The Analysis Factor, LLC. All rights reserved.
877-272-8096   Contact Us

The Analysis Factor uses cookies to ensure that we give you the best experience of our website. If you continue we assume that you consent to receive cookies on all websites from The Analysis Factor.
Continue Privacy Policy
Privacy & Cookies Policy

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. This category only includes cookies that ensures basic functionalities and security features of the website. These cookies do not store any personal information.
Non-necessary
Any cookies that may not be particularly necessary for the website to function and is used specifically to collect user personal data via analytics, ads, other embedded contents are termed as non-necessary cookies. It is mandatory to procure user consent prior to running these cookies on your website.
SAVE & ACCEPT