Logit Lab material borrowed from tutorial by William B

Slides:



Advertisements
Similar presentations
Linear regression models in R (session 1) Tom Price 3 March 2009.
Advertisements

Lecture 11 (Chapter 9).
© Department of Statistics 2012 STATS 330 Lecture 32: Slide 1 Stats 330: Lecture 32.
Multinomial Logistic Regression David F. Staples.
Logistic Regression I Outline Introduction to maximum likelihood estimation (MLE) Introduction to Generalized Linear Models The simplest logistic regression.
Binary Logistic Regression: One Dichotomous Independent Variable
Inference for Regression
Logistic Regression Chapter 5, DDS. Introduction What is it? – It is an approach for calculating the odds of event happening vs other possibilities…Odds.
Logistic Regression Predicting Dichotomous Data. Predicting a Dichotomy Response variable has only two states: male/female, present/absent, yes/no, etc.
SLIDE 1IS 240 – Spring 2010 Logistic Regression The logistic function: The logistic function is useful because it can take as an input any.
Multinomial Logistic Regression
BIO503: Lecture 4 Harvard School of Public Health Wintersession 2009 Jess Mar Department of Biostatistics
Log-linear and logistic models
Copyright (c) Bani K. Mallick1 STAT 651 Lecture #20.
Nemours Biomedical Research Statistics April 23, 2009 Tim Bunnell, Ph.D. & Jobayer Hossain, Ph.D. Nemours Bioinformatics Core Facility.
C82MCP Diploma Statistics School of Psychology University of Nottingham 1 Linear Regression and Linear Prediction Predicting the score on one variable.
Generalized Linear Models
Use of Quantile Functions in Data Analysis. In general, Quantile Functions (sometimes referred to as Inverse Density Functions or Percent Point Functions)
Statistics for Business and Economics 8 th Edition Chapter 11 Simple Regression Copyright © 2013 Pearson Education, Inc. Publishing as Prentice Hall Ch.
MATH 3359 Introduction to Mathematical Modeling Project Multiple Linear Regression Multiple Logistic Regression.
© Department of Statistics 2012 STATS 330 Lecture 26: Slide 1 Stats 330: Lecture 26.
Review of Statistical Models and Linear Regression Concepts STAT E-150 Statistical Methods.
6/7/2014 CSE6511.  What is it? ◦ It is an approach for calculating the odds of event happening vs other possibilities…Odds ratio is an important concept.
University of Warwick, Department of Sociology, 2014/15 SO 201: SSAASS (Surveys and Statistics) (Richard Lampard) Week 7 Logistic Regression I.
AN INTRODUCTION TO LOGISTIC REGRESSION ENI SUMARMININGSIH, SSI, MM PROGRAM STUDI STATISTIKA JURUSAN MATEMATIKA UNIVERSITAS BRAWIJAYA.
When and why to use Logistic Regression?  The response variable has to be binary or ordinal.  Predictors can be continuous, discrete, or combinations.
Linear vs. Logistic Regression Log has a slightly better ability to represent the data Dichotomous Prefer Don’t Prefer Linear vs. Logistic Regression.
Week 5: Logistic regression analysis Overview Questions from last week What is logistic regression analysis? The mathematical model Interpreting the β.
© Department of Statistics 2012 STATS 330 Lecture 20: Slide 1 Stats 330: Lecture 20.
Time Series Analysis – Chapter 6 Odds and Ends
Business Statistics: A Decision-Making Approach, 6e © 2005 Prentice-Hall, Inc. Chap 13-1 Introduction to Regression Analysis Regression analysis is used.
STA 286 week 131 Inference for the Regression Coefficient Recall, b 0 and b 1 are the estimates of the slope β 1 and intercept β 0 of population regression.
Worked Example Using R. > plot(y~x) >plot(epsilon1~x) This is a plot of residuals against the exploratory variable, x.
Correlation and Regression: The Need to Knows Correlation is a statistical technique: tells you if scores on variable X are related to scores on variable.
A preliminary exploration into the Binomial Logistic Regression Models in R and their potential application Andrew Trant PPS Arctic - Labrador Highlands.
Logistic Regression. Linear Regression Purchases vs. Income.
AP STATISTICS LESSON 14 – 1 ( DAY 1 ) INFERENCE ABOUT THE MODEL.
Multiple Logistic Regression STAT E-150 Statistical Methods.
Basic Statistics Linear Regression. X Y Simple Linear Regression.
Subjects Review Introduction to Statistical Learning Midterm: Thursday, October 15th :00-16:00 ADV2.
© Department of Statistics 2012 STATS 330 Lecture 22: Slide 1 Stats 330: Lecture 22.
Logistic Regression. Linear regression – numerical response Logistic regression – binary categorical response eg. has the disease, or unaffected by the.
Logistic Regression Analysis Gerrit Rooks
Example x y We wish to check for a non zero correlation.
Remembering way back: Generalized Linear Models Ordinary linear regression What if we want to model a response that is not Gaussian?? We may have experiments.
Logistic regression (when you have a binary response variable)
Logistic Regression Saed Sayad 1www.ismartsoft.com.
1 Say good things, think good thoughts, and do good deeds.
Linear Models Binary Logistic Regression. One-Way IVR 2 Hawaiian Bats Examine data.frame on HO Section 1.1 Questions –Is subspecies related to canine.
Regression Analysis in Microsoft Excel MS&T Physics 1135 and 2135 Labs.
Occasionally, we are able to see clear violations of the constant variance assumption by looking at a residual plot - characteristic “funnel” shape… often.
Roger B. Hammer Assistant Professor Department of Sociology Oregon State University Conducting Social Research Logistic Regression Categorical Data Analysis.
Logistic Regression and Odds Ratios Psych DeShon.
1 Experimental Statistics - week 12 Chapter 11: Linear Regression and Correlation Chapter 12: Multiple Regression.
Introduction Many problems in Engineering, Management, Health Sciences and other Sciences involve exploring the relationships between two or more variables.
Before the class starts: Login to a computer Read the Data analysis assignment 1 on MyCourses If you use Stata: Start Stata Start a new do file Open the.
Predicting Energy Consumption in Buildings using Multiple Linear Regression Introduction Linear regression is used to model energy consumption in buildings.
CHAPTER 3 Describing Relationships
Logistic Regression.
Basic Estimation Techniques
Drop-in Sessions! When: Hillary Term - Week 1 Where: Q-Step Lab (TBC) Sign up with Alice Evans.
Chapter 12: Regression Diagnostics
Generalized Linear Models
Generalized Linear Models (GLM) in R
Introduction to logistic regression a.k.a. Varbrul
Basic Estimation Techniques
Scatter Plots of Data with Various Correlation Coefficients
(& Generalized Linear Models)
Tutorial 8 Table 3.10 on Page 76 shows the scores in the final examination F and the scores in two preliminary examinations P1 and P2 for 22 students in.
Simple Linear Regression
Presentation transcript:

Logit Lab material borrowed from tutorial by William B Logit Lab material borrowed from tutorial by William B. King Coastal Carolina see: ww2.coastal.edu/kingw/statistics/R-tutorials/logistic.html

# Start by loading MASS library # Note: Functions and datasets to support Venables and Ripley, 'Modern Applied Statistics with S’ library("MASS") #Load data set for analysis data(menarche) #View structure of data str(menarche)

# There are 3 variables with 25 observations: Age: average age of each cohort, i.e., partitioned by age Total: total number of girls in each cohort Menarche: number of girls that have reached menarche # Get summary statistics summary(menarche) # See ranges for each variable along with distributions info

# Plot data plot(Menarche/Total ~ Age, data=menarche) # Wow # Plot data plot(Menarche/Total ~ Age, data=menarche) # Wow! Looks like a really good data set for logistic regression # What does the logistic regression command look like? glm. out = glm(cbind(Menarche, Total-Menarche) ~ Age, family=binomial(logit), data=menarche) # So what is glm? ?glm # we see that this is a generalized linear model function.

# Lets parse the command glm # Lets parse the command glm. out = glm(cbind(Menarche, Total-Menarche) ~ Age, family=binomial(logit), data=menarche) # glm – generalized linear model # What is cbind(Menarche, Total-Menarche) ~ Age? # Type in cbind(Menarche, Total-Menarche) # Why do you get an error?

# You get an error because Menarche & Total are variables in a frame and # not top-level variables. # Recall the plot command we used: plot(Menarche/Total ~ Age, data=menarche) # Notice: data = menarche. This specifies the data frame # this is equivalent to plot(menarche$Menarche/menarche$Total ~ menarche$Age)

# What is cbind(Menarche, Total-Menarche) # What is cbind(Menarche, Total-Menarche)? # when data=menarche, cbind(Menarche, Total-Menarche) is # cbind(menarche$Menarche, menarche$Total-menarche$Menarche) # Type it in cbind(menarche$Menarche, menarche$Total-menarche$Menarche) # We see that these are the Y values of the points representing the dichotomy # Thus cbind(Menarche, Total-Menarche) ~ Age, # are the Y ~ X values that are arguments to the model # What about family=binomial(logit)? # This tells the glm function to fit the data using the logit model

# Altogether glm. out = glm(cbind(Menarche, Total-Menarche) ~ Age, family=binomial(logit), data=menarche) # Ok, let’s examine the result of fitting the data with the logit model plot(Menarche/Total ~ Age, data=menarche) lines(menarche$Age, glm.out$fitted, type="l", col="red") title(main="Menarche Data with Fitted Logistic Regression Line") #Good fit!!!

# Check the statistics summary(glm # Check the statistics summary(glm.out) # Observe that the Estimated coefficient of Age is 1.63197 # Recall that the response variable is log odds so # so the change in odds is exp(1.632) = 5.11 times. # Interpretation: for every year increase in age the odds of having reached # menarche increase by exp(1.632) = 5.11 times.