Table of Contents. Logistic Regression- Illustration Carol Bigelow March 21, 2017
|
|
- Leslie Hall
- 5 years ago
- Views:
Transcription
1 Logistic Regression- Illustration Carol Bigelow March 21, 2017 Table of Contents Preliminary - Attach packages needed using command library( )... 2 Must have installed packages in console window first... 2 Upload data and check structure (continuous v factor, etc)... 2 Create Quartile Groupings of a Continuous Variable age (age_quartile)... 2 Create Medians of Continuous Variable ag, over quartile Groupings (age_qmedian)... 3 Create 0/1 Indicator of Heavy Drinking (alcohol_80plus). Check Create 0/1 Indicator of Heavy Smoking (smoking_30plus). Check Create Interaction of Heavy Drinking and Heavy Smoking (drinker_smoker) Convert agegp to a factor variable and label MODEL 1: Predictors = agegp (R knows it is a factor), heavy drinking MODEL 2: Predictors = agegp (as factor), heavy smoking MODEL 3: Predictors = agegp (as factor), heavy drinking, heavy smoking MODEL 4: Predictors = age (as factor), heavy drinking, heavy smoking, + Interaction Side- by- side Comparison of Models: BETAs Side- by- side Comparison of Models: ODDS RATIOs Likelihood Ratio Test for 2 "Hierarchical" (NULL: Beta for interaction = 0) - Easy Likelihood Ratio Test for 2 "Hierarchical" (NULL: Beta for interaction = 0) - Brute Force REGRESSION DIAGNOSTIC for Model 3: Numerical Measures of Fit REGRESSION DIAGNOSTIC for Model 3: Test of Model Adequacy (Link Test: NULL: beta hatsq=0) REGRESSION DIAGNOSTIC for Model 3: Hosmer Lemeshow GOF Test with 9 bins (NULL: Fit is good) REGRESSION DIAGNOSTIC for Model 3: Plot of ROC Curve (AUC = % Correctly Classified) REGRESSION DIAGNOSTIC for Model 3: Plot of Cook's Distances v Observation Number R Handouts \R for Logistic Regression 2017.docx Page 1 of 14
2 Preliminary - Attach packages needed using command library( ) Must have installed packages in console window first library(car) library(desctools) library(foreign) library(readstata13) library(ggplot2) library(gmodels) library(dplyr) library(mosaic) library(stargazer) library(lmtest) library(proc) library(rms) library(resourceselection) Upload data and check structure (continuous v factor, etc) link <- " dat <- read.dta13(link) glimpse(dat) Observations: 975 Variables: 7 $ case <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,... $ age <dbl> 42, 45, 35, 78, 45, 64, 76, 42, 48, 42, 37, 45, 60, 54,... $ agegp <dbl> 2, 3, 2, 6, 3, 4, 6, 2, 3, 2, 2, 3, 4, 3, 5, 4, 3, 4, 3,... $ tob <dbl> 0.0, 7.5, 0.0, 0.0, 7.5, 17.5, 2.5, 0.0, 12.5, 25.0, $ tobgp <dbl> 1, 1, 1, 1, 1, 2, 1, 1, 2, 3, 2, 2, 1, 3, 1, 1, 3, 1, 1,... $ alc <dbl> 139, 66, 24, 39, 64, 49, 1, 33, 55, 62, 77, 84, 4, 32, 2... $ alcgp <dbl> 4, 2, 1, 1, 2, 2, 1, 1, 2, 2, 2, 3, 1, 1, 1, 1, 1, 2, 1,... Create Quartile Groupings of a Continuous Variable age (age_quartile) This data set has two continuous variables: age (age, years) and tob (tobacco consumption, gm/day). It also contains two grouped versions: agegp and tobgp. Here we consider the variable age. In this lab session, let s create two new variables. Each is a two step process. age_quartile = Quartile of age, coded 1, 2, 3 or 4 age_qmedian = Median of age, within quartile of age 0. R Handouts \R for Logistic Regression 2017.docx Page 2 of 14
3 #1. Obtain Quartiles using command quantile(data$varibable, c(list )) quantile(dat$age, c(0,.25,.50,.75,1)) 0% 25% 50% 75% 100% #2. Create new variable with values = quartile using command cut( ) dat$age_quartile <- cut(dat$age, breaks=c(0,41,52,63,91), labels=c(1,2, 3,4)) Create Medians of Continuous Variable ag, over quartile Groupings (age_qmedian) #1. Determine median age in each quartile by(data = dat$age, INDICES = dat$age_quartile, FUN = function(x) median (x)) dat$age_quartile: 1 [1] dat$age_quartile: 2 [1] dat$age_quartile: 3 [1] dat$age_quartile: 4 [1] 69 #2. Create new variable with values = median in quartile dat$age_qmedian <- cut(dat$age, breaks = c(0, 41, 52, 63, 91), labels = c(35, 47, 59, 69)) #3. Check tally(age_quartile~age_qmedian,data=dat) age_qmedian age_quartile Ille- et- Vilaine Data: Illustration After creating some new variables for illustration purposes, 4 logistic regression models are fit and then compared side- by- side. Model 1: Predictors = heavy drinking, age Model 2: Predictors = heavy smoking, age Model 3: Predictors = heavy drinking, heavy smoking, age Model 4: Predictors = heavy drinking, heavy smoking, drinking x smoking interaction, age 0. R Handouts \R for Logistic Regression 2017.docx Page 3 of 14
4 Create 0/1 Indicator of Heavy Drinking (alcohol_80plus). Check. dat$alcohol_80plus <- ifelse(as.numeric(dat$alcgp)>=3,1,0) tally(alcgp~alcohol_80plus,data=dat) alcohol_80plus alcgp Create 0/1 Indicator of Heavy Smoking (smoking_30plus). Check. dat$smoking_30plus <- ifelse(as.numeric(dat$tobgp)==4,1,0) tally(tobgp~smoking_30plus,data=dat) smoking_30plus tobgp Create Interaction of Heavy Drinking and Heavy Smoking (drinker_smoker). dat$drinker_smoker <- as.numeric(dat$alcohol_80plus) * as.numeric(dat$s moking_30plus) Convert agegp to a factor variable and label. dat$agegp <- factor(dat$agegp, levels=c(1,2,3,4,5,6), labels=c("25-34","35-44","45-54","55-64","65-74","7 5+")) MODEL 1: Predictors = agegp (R knows it is a factor), heavy drinking. # NAME <- glm(yvariable ~ X1 + X2 + etc, data=dataframename, family=bin omial) model1 <- glm(case ~ agegp + alcohol_80plus, data = dat, family = binom ial) summary(model1) Call: glm(formula = case ~ agegp + alcohol_80plus, family = binomial, data = dat) Deviance Residuals: Min 1Q Median 3Q Max Coefficients: Estimate Std. Error z value Pr(> z ) 0. R Handouts \R for Logistic Regression 2017.docx Page 4 of 14
5 (Intercept) e- 07 *** agegp agegp ** agegp *** agegp *** agegp *** alcohol_80plus < 2e- 16 *** Signif. codes: 0 '***' '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 (Dispersion parameter for binomial family taken to be 1) Null deviance: on 974 degrees of freedom Residual deviance: on 968 degrees of freedom AIC: Number of Fisher Scoring iterations: 7 exp(cbind(or = coef(model1), confint(model1))) OR 2.5 % 97.5 % (Intercept) e agegp e agegp e agegp e agegp e agegp e alcohol_80plus e MODEL 2: Predictors = agegp (as factor), heavy smoking. model2 <- glm(case ~ agegp + smoking_30plus, data = dat, family = binom ial) summary(model2) Call: glm(formula = case ~ agegp + smoking_30plus, family = binomial, data = dat) Deviance Residuals: Min 1Q Median 3Q Max Coefficients: Estimate Std. Error z value Pr(> z ) (Intercept) e- 07 *** agegp agegp *** agegp e- 05 *** agegp e- 05 *** agegp *** smoking_30plus e- 07 *** Signif. codes: 0 '***' '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 (Dispersion parameter for binomial family taken to be 1) Null deviance: on 974 degrees of freedom Residual deviance: on 968 degrees of freedom 0. R Handouts \R for Logistic Regression 2017.docx Page 5 of 14
6 AIC: Number of Fisher Scoring iterations: 7 exp(cbind(or = coef(model2), confint(model2))) OR 2.5 % 97.5 % (Intercept) e e- 02 agegp e e+02 agegp e e+02 agegp e e+03 agegp e e+03 agegp e e+03 smoking_30plus e e+00 MODEL 3: Predictors = agegp (as factor), heavy drinking, heavy smoking. model3 <- glm(case ~ agegp + alcohol_80plus + smoking_30plus, data = da t, family = binomial) summary(model3) Call: glm(formula = case ~ agegp + alcohol_80plus + smoking_30plus, family = binomial, data = dat) Deviance Residuals: Min 1Q Median 3Q Max Coefficients: Estimate Std. Error z value Pr(> z ) (Intercept) e- 08 *** agegp agegp *** agegp e- 05 *** agegp e- 05 *** agegp e- 05 *** alcohol_80plus < 2e- 16 *** smoking_30plus e- 06 *** Signif. codes: 0 '***' '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 (Dispersion parameter for binomial family taken to be 1) Null deviance: on 974 degrees of freedom Residual deviance: on 967 degrees of freedom AIC: Number of Fisher Scoring iterations: 7 exp(cbind(or = coef(model3), confint(model3))) (Intercept) agegp35-44 agegp45-54 agegp55-64 agegp65-74 agegp75+ OR 2.5 % 97.5 % e e e e e e R Handouts \R for Logistic Regression 2017.docx Page 6 of 14
7 alcohol_80plus e+00 smoking_30plus e+00 MODEL 4: Predictors = agegp (as factor), heavy drinking, heavy smoking, + Interaction. model4 <- glm(case ~ agegp + alcohol_80plus + smoking_30plus + drinker_ smoker, data = dat, family = binomial) summary(model4) Call: glm(formula = case ~ agegp + alcohol_80plus + smoking_30plus + drinker_smoker, family = binomial, data = dat) Deviance Residuals: Min 1Q Median 3Q Max Coefficients: Estimate Std. Error z value Pr(> z ) (Intercept) e- 08 *** agegp agegp *** agegp e- 05 *** agegp e- 05 *** agegp e- 05 *** alcohol_80plus e- 15 *** smoking_30plus *** drinker_smoker Signif. codes: 0 '***' '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 (Dispersion parameter for binomial family taken to be 1) Null deviance: on 974 degrees of freedom Residual deviance: on 966 degrees of freedom AIC: Number of Fisher Scoring iterations: 7 exp(cbind(or = coef(model4), confint(model4))) OR 2.5 % 97.5 % (Intercept) e agegp e agegp e agegp e agegp e agegp e alcohol_80plus e smoking_30plus e drinker_smoker e R Handouts \R for Logistic Regression 2017.docx Page 7 of 14
8 Side- by- side Comparison of Models: BETAs. stargazer(model1, model2, model3, model4,title="logistic Regression of Esophageal Cancer - BETAs",type="text") Logistic Regression of Esophageal Cancer - BETAs ========================================================= Dependent variable: case (1) (2) (3) (4) agegp * 1.841* 1.882* (1.066) (1.065) (1.077) (1.088) agegp *** 3.648*** 3.500*** 3.533*** (1.023) (1.024) (1.037) (1.046) agegp *** 4.177*** 4.029*** 4.063*** (1.018) (1.020) (1.034) (1.043) agegp *** 4.412*** 4.394*** 4.425*** (1.023) (1.026) (1.041) (1.050) agegp *** 4.085*** 4.269*** 4.306*** (1.065) (1.065) (1.081) (1.090) alcohol_80plus 1.654*** 1.634*** 1.613*** (0.189) (0.192) (0.202) smoking_30plus 1.438*** 1.384*** 1.316*** (0.286) (0.307) (0.370) drinker_smoker (0.671) Constant *** *** *** *** (1.009) (1.013) (1.030) (1.038) Observations Log Likelihood Akaike Inf. Crit ========================================================= Note: *p<0.1; **p<0.05; ***p< R Handouts \R for Logistic Regression 2017.docx Page 8 of 14
9 Side- by- side Comparison of Models: ODDS RATIOs. OR <- function(x) exp(x) stargazer(model1, model2, model3, model4,apply.coef=or, title="logistic Regression of Esophageal Cancer - ODDS RATIOs", type="text") Logistic Regression of Esophageal Cancer - ODDS RATIOs ========================================================= Dependent variable: case (1) (2) (3) (4) agegp *** 6.268*** 6.300*** 6.563*** (1.066) (1.065) (1.077) (1.088) agegp *** *** *** *** (1.023) (1.024) (1.037) (1.046) agegp *** *** *** *** (1.018) (1.020) (1.034) (1.043) agegp *** *** *** *** (1.023) (1.026) (1.041) (1.050) agegp *** *** *** *** (1.065) (1.065) (1.081) (1.090) alcohol_80plus 5.228*** 5.122*** 5.018*** (0.189) (0.192) (0.202) smoking_30plus 4.211*** 3.990*** 3.727*** (0.286) (0.307) (0.370) drinker_smoker 1.252* (0.671) Constant (1.009) (1.013) (1.030) (1.038) Observations Log Likelihood Akaike Inf. Crit ========================================================= Note: *p<0.1; **p<0.05; ***p< R Handouts \R for Logistic Regression 2017.docx Page 9 of 14
10 Likelihood Ratio Test for 2 "Hierarchical" (NULL: Beta for interaction = 0) - Easy. It is of interest to know whether the inclusion of extra predictors to a model is statistically significant. The smaller model ( reduced ) contains the control variables. The larger model ( full ) contains the control variables plus the extra variables in question. Models. Reduced: logit[π X,X...,X ] = β +β X +...+β X 1 2 p p p Full: logit[π X,X...,X, X,X,...,X ] = β +β X+...+βX+ β X +...+β X 1 2 p p+1 p+2 p+k p p p+1 p+1 p+k p+ k Null and Alternative Hypotheses: H: β = β =... = β = 0 O p+1 p+2 p+k H: not A Definition Likelihood Ratio Test (LR) LR statistic = DevianceREDUCED - DevianceFULL = [ (- 2) ln (Likelihood) REDUCED ] - [ (- 2) ln (Likelihood) FULL ] Under the null hypothesis, LR is distributed Chi SquareDF=k Ille- et- Vilaine Data: Illustration A likelihood ratio test is performed to assess the stastistical significance of the interaction of heavy drinking and heavy smoking in the model, controlling for age and the main effects of each of heavy drinking and heavy smoking. Thus, Model reduced : Predictors = age, heavy drinking, heavy smoking Model full : Predictors = age, heavy drinking, heavy smoking + (drinking x smoking) 0. R Handouts \R for Logistic Regression 2017.docx Page 10 of 14
11 # lrtest(reduced, FULL) lrtest(model3, model4) Model 1: case ~ agegp + alcohol_80plus + smoking_30plus Model 2: case ~ agegp + alcohol_80plus + smoking_30plus + drinker_smoker L.R. Chisq d.f. P Likelihood Ratio Test for 2 "Hierarchical" (NULL: Beta for interaction = 0) - Brute Force. LR.statistic.1 <- model3$deviance - model4$deviance pchisq(lr.statistic.1, 1, lower.tail = FALSE) [1] LR.statistic.2 <- - 2*logLik(model3)[1] - (- 2*logLik(model4)[1]) pchisq(lr.statistic.2, 1, lower.tail = FALSE) [1] REGRESSION DIAGNOSTIC for Model 3: Numerical Measures of Fit. Now you have a model that is your candidate final model. There are lots of further explorations you can do to assess whether this really is a good final model. Ille- et- Vilaine Data: Illustration Having retained the null hypothesis in our likelihood ratio test of the interaction of heavy smoking and heavy drinking, our candidate final model is model 3, containing: heavy drinking, heavy smoking, and age. lrm(model3) Logistic Regression Model lrm(formula = model3) Model Likelihood Discrimination Rank Discrim. Ratio Test Indexes Indexes Obs 975 LR chi R C d.f. 7 g Dxy Pr(> chi2) < gr gamma max deriv 2e- 09 gp tau- a Brier Coef S.E. Wald Z Pr(> Z ) Intercept < agegp= R Handouts \R for Logistic Regression 2017.docx Page 11 of 14
12 agegp= agegp= < agegp= < agegp= < alcohol_80plus < smoking_30plus < REGRESSION DIAGNOSTIC for Model 3: Test of Model Adequacy (Link Test: NULL: beta hatsq=0). hat <- predict(model3) hatsq <- hat^2 linktest <- summary(glm(case ~ hat + hatsq, data=dat, family=binomial)) linktest Call: glm(formula = case ~ hat + hatsq, family = binomial, data = dat) Deviance Residuals: Min 1Q Median 3Q Max Coefficients: Estimate Std. Error z value Pr(> z ) (Intercept) hat e- 13 *** hatsq Signif. codes: 0 '***' '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 (Dispersion parameter for binomial family taken to be 1) Null deviance: on 974 degrees of freedom Residual deviance: on 972 degrees of freedom AIC: Number of Fisher Scoring iterations: 7 WHAT TO LOOK FOR: We expect the p- value for _HAT to be highly significant. Evidence of a GOOD FIT is reflected in a NON- SIGNIFICANT _HATSQ. Here the p- value for _HATSQ is.934. This suggests good model adequacy REGRESSION DIAGNOSTIC for Model 3: Hosmer Lemeshow GOF Test with 9 bins (NULL: Fit is good). hoslem.test(model3$y,fitted(model3),g=9) Hosmer and Lemeshow goodness of fit (GOF) test data: model3$y, fitted(model3) X- squared = , df = 7, p- value = R Handouts \R for Logistic Regression 2017.docx Page 12 of 14
13 WHAT TO LOOK FOR: Evidence of a OVERALL GOODNESS OF FIT is reflected in a NON- SIGNIFICANT p- value Here the Hosmer- Lemeshow test p- value is This suggests good overall fit REGRESSION DIAGNOSTIC for Model 3: Plot of ROC Curve (AUC = % Correctly Classified). roc1 <- roc(dat$case, fitted(model3)) plot.roc(roc1, print.auc=true, legacy.axes=true, identity=true, main="l ogistic Regression of Esophageal Cancer") WHAT TO LOOK FOR: Classification that is no better than a coin toss is reference in the 45 degree line Evidence of GOOD FIT is reflected in an ROC curve that lies above the 45 degree line reference Area under the ROC curve =.812 says that 81% of the observations are correctly classified. REGRESSION DIAGNOSTIC for Model 3: Plot of Cook's Distances v Observation Number. plot(cooks.distance(model3), ylab="cook Distance", xlab="observation #", main="logistic Regression of Esophageal Cancer") 0. R Handouts \R for Logistic Regression 2017.docx Page 13 of 14
14 WHAT TO LOOK FOR: Look for an even ribbon of cook distance values with no spikes. 0. R Handouts \R for Logistic Regression 2017.docx Page 14 of 14
Unit 5 Logistic Regression Practice Problems
Unit 5 Logistic Regression Practice Problems SOLUTIONS R Users Source: Afifi A., Clark VA and May S. Computer Aided Multivariate Analysis, Fourth Edition. Boca Raton: Chapman and Hall, 2004. Exercises
More informationIntroduction to logistic regression
Introduction to logistic regression Tuan V. Nguyen Professor and NHMRC Senior Research Fellow Garvan Institute of Medical Research University of New South Wales Sydney, Australia What we are going to learn
More information7/28/15. Review Homework. Overview. Lecture 6: Logistic Regression Analysis
Lecture 6: Logistic Regression Analysis Christopher S. Hollenbeak, PhD Jane R. Schubart, PhD The Outcomes Research Toolbox Review Homework 2 Overview Logistic regression model conceptually Logistic regression
More informationExperimental Design and Statistical Methods. Workshop LOGISTIC REGRESSION. Jesús Piedrafita Arilla.
Experimental Design and Statistical Methods Workshop LOGISTIC REGRESSION Jesús Piedrafita Arilla jesus.piedrafita@uab.cat Departament de Ciència Animal i dels Aliments Items Logistic regression model Logit
More informationLinear Regression Models P8111
Linear Regression Models P8111 Lecture 25 Jeff Goldsmith April 26, 2016 1 of 37 Today s Lecture Logistic regression / GLMs Model framework Interpretation Estimation 2 of 37 Linear regression Course started
More informationLogistic Regression 21/05
Logistic Regression 21/05 Recall that we are trying to solve a classification problem in which features x i can be continuous or discrete (coded as 0/1) and the response y is discrete (0/1). Logistic regression
More informationExercise 5.4 Solution
Exercise 5.4 Solution Niels Richard Hansen University of Copenhagen May 7, 2010 1 5.4(a) > leukemia
More informationssh tap sas913, sas https://www.statlab.umd.edu/sasdoc/sashtml/onldoc.htm
Kedem, STAT 430 SAS Examples: Logistic Regression ==================================== ssh abc@glue.umd.edu, tap sas913, sas https://www.statlab.umd.edu/sasdoc/sashtml/onldoc.htm a. Logistic regression.
More informationAge 55 (x = 1) Age < 55 (x = 0)
Logistic Regression with a Single Dichotomous Predictor EXAMPLE: Consider the data in the file CHDcsv Instead of examining the relationship between the continuous variable age and the presence or absence
More informationLogistic Regressions. Stat 430
Logistic Regressions Stat 430 Final Project Final Project is, again, team based You will decide on a project - only constraint is: you are supposed to use techniques for a solution that are related to
More informationSTA 4504/5503 Sample Exam 1 Spring 2011 Categorical Data Analysis. 1. Indicate whether each of the following is true (T) or false (F).
STA 4504/5503 Sample Exam 1 Spring 2011 Categorical Data Analysis 1. Indicate whether each of the following is true (T) or false (F). (a) (b) (c) (d) (e) In 2 2 tables, statistical independence is equivalent
More informationStatistical Modelling with Stata: Binary Outcomes
Statistical Modelling with Stata: Binary Outcomes Mark Lunt Arthritis Research UK Epidemiology Unit University of Manchester 21/11/2017 Cross-tabulation Exposed Unexposed Total Cases a b a + b Controls
More informationLogistic Regression - problem 6.14
Logistic Regression - problem 6.14 Let x 1, x 2,, x m be given values of an input variable x and let Y 1,, Y m be independent binomial random variables whose distributions depend on the corresponding values
More informationExam Applied Statistical Regression. Good Luck!
Dr. M. Dettling Summer 2011 Exam Applied Statistical Regression Approved: Tables: Note: Any written material, calculator (without communication facility). Attached. All tests have to be done at the 5%-level.
More informationR Hints for Chapter 10
R Hints for Chapter 10 The multiple logistic regression model assumes that the success probability p for a binomial random variable depends on independent variables or design variables x 1, x 2,, x k.
More informationSTA 4504/5503 Sample Exam 1 Spring 2011 Categorical Data Analysis. 1. Indicate whether each of the following is true (T) or false (F).
STA 4504/5503 Sample Exam 1 Spring 2011 Categorical Data Analysis 1. Indicate whether each of the following is true (T) or false (F). (a) T In 2 2 tables, statistical independence is equivalent to a population
More informationRegression models. Generalized linear models in R. Normal regression models are not always appropriate. Generalized linear models. Examples.
Regression models Generalized linear models in R Dr Peter K Dunn http://www.usq.edu.au Department of Mathematics and Computing University of Southern Queensland ASC, July 00 The usual linear regression
More informationSTAC51: Categorical data Analysis
STAC51: Categorical data Analysis Mahinda Samarakoon April 6, 2016 Mahinda Samarakoon STAC51: Categorical data Analysis 1 / 25 Table of contents 1 Building and applying logistic regression models (Chap
More informationPoisson Regression. The Training Data
The Training Data Poisson Regression Office workers at a large insurance company are randomly assigned to one of 3 computer use training programmes, and their number of calls to IT support during the following
More informationOn the Inference of the Logistic Regression Model
On the Inference of the Logistic Regression Model 1. Model ln =(; ), i.e. = representing false. The linear form of (;) is entertained, i.e. ((;)) ((;)), where ==1 ;, with 1 representing true, 0 ;= 1+ +
More informationModeling Overdispersion
James H. Steiger Department of Psychology and Human Development Vanderbilt University Regression Modeling, 2009 1 Introduction 2 Introduction In this lecture we discuss the problem of overdispersion in
More informationUnit 5 Logistic Regression
PubHlth 640 - Spring 2014 5. Logistic Regression Page 1 of 63 Unit 5 Logistic Regression To all the ladies present and some of those absent - Jerzy Neyman What behaviors influence the chances of developing
More informationUnit 5 Logistic Regression
BIOSTATS 640 - Spring 2017 5. Logistic Regression Page 1 of 65 Unit 5 Logistic Regression To all the ladies present and some of those absent - Jerzy Neyman What behaviors influence the chances of developing
More informationIntroduction to General and Generalized Linear Models
Introduction to General and Generalized Linear Models Generalized Linear Models - part III Henrik Madsen Poul Thyregod Informatics and Mathematical Modelling Technical University of Denmark DK-2800 Kgs.
More informationInteractions in Logistic Regression
Interactions in Logistic Regression > # UCBAdmissions is a 3-D table: Gender by Dept by Admit > # Same data in another format: > # One col for Yes counts, another for No counts. > Berkeley = read.table("http://www.utstat.toronto.edu/~brunner/312f12/
More informationStat 579: Generalized Linear Models and Extensions
Stat 579: Generalized Linear Models and Extensions Yan Lu Jan, 2018, week 3 1 / 67 Hypothesis tests Likelihood ratio tests Wald tests Score tests 2 / 67 Generalized Likelihood ratio tests Let Y = (Y 1,
More informationUNIVERSITY OF TORONTO Faculty of Arts and Science
UNIVERSITY OF TORONTO Faculty of Arts and Science December 2013 Final Examination STA442H1F/2101HF Methods of Applied Statistics Jerry Brunner Duration - 3 hours Aids: Calculator Model(s): Any calculator
More informationGeneralized linear models
Generalized linear models Douglas Bates November 01, 2010 Contents 1 Definition 1 2 Links 2 3 Estimating parameters 5 4 Example 6 5 Model building 8 6 Conclusions 8 7 Summary 9 1 Generalized Linear Models
More informationPubHlth Intermediate Biostatistics Spring 2015 Exam 2 (Units 3, 4 & 5) Study Guide
PubHlth 640 - Intermediate Biostatistics Spring 2015 Exam 2 (Units 3, 4 & 5) Study Guide Unit 3 (Discrete Distributions) Take care to know how to do the following! Learning Objective See: 1. Write down
More informationBooklet of Code and Output for STAD29/STA 1007 Midterm Exam
Booklet of Code and Output for STAD29/STA 1007 Midterm Exam List of Figures in this document by page: List of Figures 1 NBA attendance data........................ 2 2 Regression model for NBA attendances...............
More informationLecture 12: Effect modification, and confounding in logistic regression
Lecture 12: Effect modification, and confounding in logistic regression Ani Manichaikul amanicha@jhsph.edu 4 May 2007 Today Categorical predictor create dummy variables just like for linear regression
More informationAnalysing categorical data using logit models
Analysing categorical data using logit models Graeme Hutcheson, University of Manchester The lecture notes, exercises and data sets associated with this course are available for download from: www.research-training.net/manchester
More informationAssessing the Calibration of Dichotomous Outcome Models with the Calibration Belt
Assessing the Calibration of Dichotomous Outcome Models with the Calibration Belt Giovanni Nattino The Ohio Colleges of Medicine Government Resource Center The Ohio State University Stata Conference -
More informationClassification. Chapter Introduction. 6.2 The Bayes classifier
Chapter 6 Classification 6.1 Introduction Often encountered in applications is the situation where the response variable Y takes values in a finite set of labels. For example, the response Y could encode
More informationGeneralised linear models. Response variable can take a number of different formats
Generalised linear models Response variable can take a number of different formats Structure Limitations of linear models and GLM theory GLM for count data GLM for presence \ absence data GLM for proportion
More informationUnit 5 Logistic Regression
BIOSTATS 640 - Spring 2018 5. Logistic Regression Page 1 of 66 Unit 5 Logistic Regression To all the ladies present and some of those absent - Jerzy Neyman What behaviors influence the chances of developing
More informationcor(dataset$measurement1, dataset$measurement2, method= pearson ) cor.test(datavector1, datavector2, method= pearson )
Tutorial 7: Correlation and Regression Correlation Used to test whether two variables are linearly associated. A correlation coefficient (r) indicates the strength and direction of the association. A correlation
More informationGeneralized linear models for binary data. A better graphical exploratory data analysis. The simple linear logistic regression model
Stat 3302 (Spring 2017) Peter F. Craigmile Simple linear logistic regression (part 1) [Dobson and Barnett, 2008, Sections 7.1 7.3] Generalized linear models for binary data Beetles dose-response example
More informationA Generalized Linear Model for Binomial Response Data. Copyright c 2017 Dan Nettleton (Iowa State University) Statistics / 46
A Generalized Linear Model for Binomial Response Data Copyright c 2017 Dan Nettleton (Iowa State University) Statistics 510 1 / 46 Now suppose that instead of a Bernoulli response, we have a binomial response
More informationTento projekt je spolufinancován Evropským sociálním fondem a Státním rozpočtem ČR InoBio CZ.1.07/2.2.00/
Tento projekt je spolufinancován Evropským sociálním fondem a Státním rozpočtem ČR InoBio CZ.1.07/2.2.00/28.0018 Statistical Analysis in Ecology using R Linear Models/GLM Ing. Daniel Volařík, Ph.D. 13.
More informationHomework 5 - Solution
STAT 526 - Spring 2011 Homework 5 - Solution Olga Vitek Each part of the problems 5 points 1. Agresti 10.1 (a) and (b). Let Patient Die Suicide Yes No sum Yes 1097 90 1187 No 203 435 638 sum 1300 525 1825
More informationBMI 541/699 Lecture 22
BMI 541/699 Lecture 22 Where we are: 1. Introduction and Experimental Design 2. Exploratory Data Analysis 3. Probability 4. T-based methods for continous variables 5. Power and sample size for t-based
More informationSCHOOL OF MATHEMATICS AND STATISTICS. Linear and Generalised Linear Models
SCHOOL OF MATHEMATICS AND STATISTICS Linear and Generalised Linear Models Autumn Semester 2017 18 2 hours Attempt all the questions. The allocation of marks is shown in brackets. RESTRICTED OPEN BOOK EXAMINATION
More informationMSH3 Generalized linear model
Contents MSH3 Generalized linear model 5 Logit Models for Binary Data 173 5.1 The Bernoulli and binomial distributions......... 173 5.1.1 Mean, variance and higher order moments.... 173 5.1.2 Normal limit....................
More informationA Handbook of Statistical Analyses Using R. Brian S. Everitt and Torsten Hothorn
A Handbook of Statistical Analyses Using R Brian S. Everitt and Torsten Hothorn CHAPTER 6 Logistic Regression and Generalised Linear Models: Blood Screening, Women s Role in Society, and Colonic Polyps
More informationIntroduction to the Generalized Linear Model: Logistic regression and Poisson regression
Introduction to the Generalized Linear Model: Logistic regression and Poisson regression Statistical modelling: Theory and practice Gilles Guillot gigu@dtu.dk November 4, 2013 Gilles Guillot (gigu@dtu.dk)
More informationLogistic Regression. Building, Interpreting and Assessing the Goodness-of-fit for a logistic regression model
Logistic Regression In previous lectures, we have seen how to use linear regression analysis when the outcome/response/dependent variable is measured on a continuous scale. In this lecture, we will assume
More informationUsing R in 200D Luke Sonnet
Using R in 200D Luke Sonnet Contents Working with data frames 1 Working with variables........................................... 1 Analyzing data............................................... 3 Random
More informationBIOSTATS Intermediate Biostatistics Spring 2017 Exam 2 (Units 3, 4 & 5) Practice Problems SOLUTIONS
BIOSTATS 640 - Intermediate Biostatistics Spring 2017 Exam 2 (Units 3, 4 & 5) Practice Problems SOLUTIONS Practice Question 1 Both the Binomial and Poisson distributions have been used to model the quantal
More informationLeftovers. Morris. University Farm. University Farm. Morris. yield
Leftovers SI 544 Lada Adamic 1 Trellis graphics Trebi Wisconsin No. 38 No. 457 Glabron Peatland Velvet No. 475 Manchuria No. 462 Svansota Trebi Wisconsin No. 38 No. 457 Glabron Peatland Velvet No. 475
More informationIntroduction to the Analysis of Tabular Data
Introduction to the Analysis of Tabular Data Anthropological Sciences 192/292 Data Analysis in the Anthropological Sciences James Holland Jones & Ian G. Robertson March 15, 2006 1 Tabular Data Is there
More informationModule 4: Regression Methods: Concepts and Applications
Module 4: Regression Methods: Concepts and Applications Example Analysis Code Rebecca Hubbard, Mary Lou Thompson July 11-13, 2018 Install R Go to http://cran.rstudio.com/ (http://cran.rstudio.com/) Click
More informationR Output for Linear Models using functions lm(), gls() & glm()
LM 04 lm(), gls() &glm() 1 R Output for Linear Models using functions lm(), gls() & glm() Different kinds of output related to linear models can be obtained in R using function lm() {stats} in the base
More informationReaction Days
Stat April 03 Week Fitting Individual Trajectories # Straight-line, constant rate of change fit > sdat = subset(sleepstudy, Subject == "37") > sdat Reaction Days Subject > lm.sdat = lm(reaction ~ Days)
More informationMatched Pair Data. Stat 557 Heike Hofmann
Matched Pair Data Stat 557 Heike Hofmann Outline Marginal Homogeneity - review Binary Response with covariates Ordinal response Symmetric Models Subject-specific vs Marginal Model conditional logistic
More informationBooklet of Code and Output for STAD29/STA 1007 Midterm Exam
Booklet of Code and Output for STAD29/STA 1007 Midterm Exam List of Figures in this document by page: List of Figures 1 Packages................................ 2 2 Hospital infection risk data (some).................
More informationR code and output of examples in text. Contents. De Jong and Heller GLMs for Insurance Data R code and output. 1 Poisson regression 2
R code and output of examples in text Contents 1 Poisson regression 2 2 Negative binomial regression 5 3 Quasi likelihood regression 6 4 Logistic regression 6 5 Ordinal regression 10 6 Nominal regression
More informationStatistics. Introduction to R for Public Health Researchers. Processing math: 100%
Statistics Introduction to R for Public Health Researchers Statistics Now we are going to cover how to perform a variety of basic statistical tests in R. Correlation T-tests/Rank-sum tests Linear Regression
More informationCount data page 1. Count data. 1. Estimating, testing proportions
Count data page 1 Count data 1. Estimating, testing proportions 100 seeds, 45 germinate. We estimate probability p that a plant will germinate to be 0.45 for this population. Is a 50% germination rate
More information12 Modelling Binomial Response Data
c 2005, Anthony C. Brooms Statistical Modelling and Data Analysis 12 Modelling Binomial Response Data 12.1 Examples of Binary Response Data Binary response data arise when an observation on an individual
More informationAnalysis of Categorical Data. Nick Jackson University of Southern California Department of Psychology 10/11/2013
Analysis of Categorical Data Nick Jackson University of Southern California Department of Psychology 10/11/2013 1 Overview Data Types Contingency Tables Logit Models Binomial Ordinal Nominal 2 Things not
More informationPAPER 218 STATISTICAL LEARNING IN PRACTICE
MATHEMATICAL TRIPOS Part III Thursday, 7 June, 2018 9:00 am to 12:00 pm PAPER 218 STATISTICAL LEARNING IN PRACTICE Attempt no more than FOUR questions. There are SIX questions in total. The questions carry
More informationRegression so far... Lecture 21 - Logistic Regression. Odds. Recap of what you should know how to do... At this point we have covered: Sta102 / BME102
Background Regression so far... Lecture 21 - Sta102 / BME102 Colin Rundel November 18, 2014 At this point we have covered: Simple linear regression Relationship between numerical response and a numerical
More informationNeural networks (not in book)
(not in book) Another approach to classification is neural networks. were developed in the 1980s as a way to model how learning occurs in the brain. There was therefore wide interest in neural networks
More informationECLT 5810 Linear Regression and Logistic Regression for Classification. Prof. Wai Lam
ECLT 5810 Linear Regression and Logistic Regression for Classification Prof. Wai Lam Linear Regression Models Least Squares Input vectors is an attribute / feature / predictor (independent variable) The
More informationSTAT 526 Spring Midterm 1. Wednesday February 2, 2011
STAT 526 Spring 2011 Midterm 1 Wednesday February 2, 2011 Time: 2 hours Name (please print): Show all your work and calculations. Partial credit will be given for work that is partially correct. Points
More informationDescription Syntax for predict Menu for predict Options for predict Remarks and examples Methods and formulas References Also see
Title stata.com logistic postestimation Postestimation tools for logistic Description Syntax for predict Menu for predict Options for predict Remarks and examples Methods and formulas References Also see
More informationUsing the same data as before, here is part of the output we get in Stata when we do a logistic regression of Grade on Gpa, Tuce and Psi.
Logistic Regression, Part III: Hypothesis Testing, Comparisons to OLS Richard Williams, University of Notre Dame, https://www3.nd.edu/~rwilliam/ Last revised January 14, 2018 This handout steals heavily
More informationLogistic Regression. James H. Steiger. Department of Psychology and Human Development Vanderbilt University
Logistic Regression James H. Steiger Department of Psychology and Human Development Vanderbilt University James H. Steiger (Vanderbilt University) Logistic Regression 1 / 38 Logistic Regression 1 Introduction
More informationrobmixglm: An R package for robust analysis using mixtures
robmixglm: An R package for robust analysis using mixtures 1 Introduction 1.1 Model Ken Beath Macquarie University Australia Package robmixglm implements the method of Beath (2017). This assumes that data
More informationLogistic Regression. Interpretation of linear regression. Other types of outcomes. 0-1 response variable: Wound infection. Usual linear regression
Logistic Regression Usual linear regression (repetition) y i = b 0 + b 1 x 1i + b 2 x 2i + e i, e i N(0,σ 2 ) or: y i N(b 0 + b 1 x 1i + b 2 x 2i,σ 2 ) Example (DGA, p. 336): E(PEmax) = 47.355 + 1.024
More informationPoisson Regression. James H. Steiger. Department of Psychology and Human Development Vanderbilt University
Poisson Regression James H. Steiger Department of Psychology and Human Development Vanderbilt University James H. Steiger (Vanderbilt University) Poisson Regression 1 / 49 Poisson Regression 1 Introduction
More informationYou can specify the response in the form of a single variable or in the form of a ratio of two variables denoted events/trials.
The GENMOD Procedure MODEL Statement MODEL response = < effects > < /options > ; MODEL events/trials = < effects > < /options > ; You can specify the response in the form of a single variable or in the
More informationSample solutions. Stat 8051 Homework 8
Sample solutions Stat 8051 Homework 8 Problem 1: Faraway Exercise 3.1 A plot of the time series reveals kind of a fluctuating pattern: Trying to fit poisson regression models yields a quadratic model if
More informationSTA 450/4000 S: January
STA 450/4000 S: January 6 005 Notes Friday tutorial on R programming reminder office hours on - F; -4 R The book Modern Applied Statistics with S by Venables and Ripley is very useful. Make sure you have
More informationLOGISTIC REGRESSION. Lalmohan Bhar Indian Agricultural Statistics Research Institute, New Delhi
LOGISTIC REGRESSION Lalmohan Bhar Indian Agricultural Statistics Research Institute, New Delhi- lmbhar@gmail.com. Introduction Regression analysis is a method for investigating functional relationships
More informationLogistic & Tobit Regression
Logistic & Tobit Regression Different Types of Regression Binary Regression (D) Logistic transformation + e P( y x) = 1 + e! " x! + " x " P( y x) % ln$ ' = ( + ) x # 1! P( y x) & logit of P(y x){ P(y
More informationNATIONAL UNIVERSITY OF SINGAPORE EXAMINATION. ST3241 Categorical Data Analysis. (Semester II: ) April/May, 2011 Time Allowed : 2 Hours
NATIONAL UNIVERSITY OF SINGAPORE EXAMINATION Categorical Data Analysis (Semester II: 2010 2011) April/May, 2011 Time Allowed : 2 Hours Matriculation No: Seat No: Grade Table Question 1 2 3 4 5 6 Full marks
More informationPAPER 206 APPLIED STATISTICS
MATHEMATICAL TRIPOS Part III Thursday, 1 June, 2017 9:00 am to 12:00 pm PAPER 206 APPLIED STATISTICS Attempt no more than FOUR questions. There are SIX questions in total. The questions carry equal weight.
More information7. Assumes that there is little or no multicollinearity (however, SPSS will not assess this in the [binary] Logistic Regression procedure).
1 Neuendorf Logistic Regression The Model: Y Assumptions: 1. Metric (interval/ratio) data for 2+ IVs, and dichotomous (binomial; 2-value), categorical/nominal data for a single DV... bear in mind that
More informationAdministration. Homework 1 on web page, due Feb 11 NSERC summer undergraduate award applications due Feb 5 Some helpful books
STA 44/04 Jan 6, 00 / 5 Administration Homework on web page, due Feb NSERC summer undergraduate award applications due Feb 5 Some helpful books STA 44/04 Jan 6, 00... administration / 5 STA 44/04 Jan 6,
More informationSection IX. Introduction to Logistic Regression for binary outcomes. Poisson regression
Section IX Introduction to Logistic Regression for binary outcomes Poisson regression 0 Sec 9 - Logistic regression In linear regression, we studied models where Y is a continuous variable. What about
More information9 Generalized Linear Models
9 Generalized Linear Models The Generalized Linear Model (GLM) is a model which has been built to include a wide range of different models you already know, e.g. ANOVA and multiple linear regression models
More informationCorrelation and regression
1 Correlation and regression Yongjua Laosiritaworn Introductory on Field Epidemiology 6 July 2015, Thailand Data 2 Illustrative data (Doll, 1955) 3 Scatter plot 4 Doll, 1955 5 6 Correlation coefficient,
More informationAnalysis of binary repeated measures data with R
Analysis of binary repeated measures data with R Right-handed basketball players take right and left-handed shots from 3 locations in a different random order for each player. Hit or miss is recorded.
More information1. Hypothesis testing through analysis of deviance. 3. Model & variable selection - stepwise aproaches
Sta 216, Lecture 4 Last Time: Logistic regression example, existence/uniqueness of MLEs Today s Class: 1. Hypothesis testing through analysis of deviance 2. Standard errors & confidence intervals 3. Model
More informationRegression Methods for Survey Data
Regression Methods for Survey Data Professor Ron Fricker! Naval Postgraduate School! Monterey, California! 3/26/13 Reading:! Lohr chapter 11! 1 Goals for this Lecture! Linear regression! Review of linear
More informationSTA102 Class Notes Chapter Logistic Regression
STA0 Class Notes Chapter 0 0. Logistic Regression We continue to study the relationship between a response variable and one or more eplanatory variables. For SLR and MLR (Chapters 8 and 9), our response
More informationGeneralized Linear Models. stat 557 Heike Hofmann
Generalized Linear Models stat 557 Heike Hofmann Outline Intro to GLM Exponential Family Likelihood Equations GLM for Binomial Response Generalized Linear Models Three components: random, systematic, link
More informationClinical Trials. Olli Saarela. September 18, Dalla Lana School of Public Health University of Toronto.
Introduction to Dalla Lana School of Public Health University of Toronto olli.saarela@utoronto.ca September 18, 2014 38-1 : a review 38-2 Evidence Ideal: to advance the knowledge-base of clinical medicine,
More informationSTAT 510 Final Exam Spring 2015
STAT 510 Final Exam Spring 2015 Instructions: The is a closed-notes, closed-book exam No calculator or electronic device of any kind may be used Use nothing but a pen or pencil Please write your name and
More informationNotes for week 4 (part 2)
Notes for week 4 (part 2) Ben Bolker October 3, 2013 Licensed under the Creative Commons attribution-noncommercial license (http: //creativecommons.org/licenses/by-nc/3.0/). Please share & remix noncommercially,
More informationVarious Issues in Fitting Contingency Tables
Various Issues in Fitting Contingency Tables Statistics 149 Spring 2006 Copyright 2006 by Mark E. Irwin Complete Tables with Zero Entries In contingency tables, it is possible to have zero entries in a
More informationSAS Analysis Examples Replication C8. * SAS Analysis Examples Replication for ASDA 2nd Edition * Berglund April 2017 * Chapter 8 ;
SAS Analysis Examples Replication C8 * SAS Analysis Examples Replication for ASDA 2nd Edition * Berglund April 2017 * Chapter 8 ; libname ncsr "P:\ASDA 2\Data sets\ncsr\" ; data c8_ncsr ; set ncsr.ncsr_sub_13nov2015
More informationUNIVERSITY OF TORONTO. Faculty of Arts and Science APRIL 2010 EXAMINATIONS STA 303 H1S / STA 1002 HS. Duration - 3 hours. Aids Allowed: Calculator
UNIVERSITY OF TORONTO Faculty of Arts and Science APRIL 2010 EXAMINATIONS STA 303 H1S / STA 1002 HS Duration - 3 hours Aids Allowed: Calculator LAST NAME: FIRST NAME: STUDENT NUMBER: There are 27 pages
More informationStatistical Prediction
Statistical Prediction P.R. Hahn Fall 2017 1 Some terminology The goal is to use data to find a pattern that we can exploit. y: response/outcome/dependent/left-hand-side x: predictor/covariate/feature/independent
More informationLab 3 A Quick Introduction to Multiple Linear Regression Psychology The Multiple Linear Regression Model
Lab 3 A Quick Introduction to Multiple Linear Regression Psychology 310 Instructions.Work through the lab, saving the output as you go. You will be submitting your assignment as an R Markdown document.
More informationChapter 14 Logistic and Poisson Regressions
STAT 525 SPRING 2018 Chapter 14 Logistic and Poisson Regressions Professor Min Zhang Logistic Regression Background In many situations, the response variable has only two possible outcomes Disease (Y =
More informationST3241 Categorical Data Analysis I Logistic Regression. An Introduction and Some Examples
ST3241 Categorical Data Analysis I Logistic Regression An Introduction and Some Examples 1 Business Applications Example Applications The probability that a subject pays a bill on time may use predictors
More informationECLT 5810 Linear Regression and Logistic Regression for Classification. Prof. Wai Lam
ECLT 5810 Linear Regression and Logistic Regression for Classification Prof. Wai Lam Linear Regression Models Least Squares Input vectors is an attribute / feature / predictor (independent variable) The
More information