A Generalized Linear Model for Bernoulli Response Data

A Generalized Linear Model for Bernoulli Response Data

A Generalized Linear Model for Bernoulli Response Data Copyright c 2017 Dan Nettleton (Iowa State University) Statistics 510 1 / 46 Consider the Gauss-Markov linear model with normal errors: y = Xβ + ✏, ✏ N(0,σ2I). ⇠ Another way to write this model is 2 i = 1,...,n, y N(µ ,σ ),µ= x0β, 8 i ⇠ i i i and y1,...,yn are independent. Copyright c 2017 Dan Nettleton (Iowa State University) Statistics 510 2 / 46 This is a special case of what is known as a generalized linear model. Here is another special case: i = 1,...,n, y Bernoulli(⇡ ), 8 i ⇠ i exp(xi0β) ⇡i = , 1 +exp(xi0β) and y1,...,yn are independent. Copyright c 2017 Dan Nettleton (Iowa State University) Statistics 510 3 / 46 In each example, all responses are independent, and each response is a draw from one type of distribution whose parameters may depend on explanatory variables through a linear predictor xi0β. Copyright c 2017 Dan Nettleton (Iowa State University) Statistics 510 4 / 46 The second model, for the case of a binary response, is often called a logistic regression model. Binary responses are common (success/failure, survive/die, good customer/bad customer, win/lose, etc.) The logistic regression model can help us understand how explanatory variables are related to the probability of “success.” Copyright c 2017 Dan Nettleton (Iowa State University) Statistics 510 5 / 46 Example: Disease Outbreak Study Source: Applied Linear Statistical Models, 4th edition, by Neter, Kutner, Nachtsheim, Wasserman (1996) In a health study to investigate an epidemic outbreak of a disease that is spread by mosquitoes, individuals were randomly sampled within two sectors in a city to determine if the person had recently contracted the disease under study. Copyright c 2017 Dan Nettleton (Iowa State University) Statistics 510 6 / 46 Response Variable yi = 0 (person i does not have the disease) yi = 1 (person i has the disease) Copyright c 2017 Dan Nettleton (Iowa State University) Statistics 510 7 / 46 Potential Explanatory Variables age in years socioeconomic status 1 = upper 2 = middle 3 = lower sector (1 or 2) Copyright c 2017 Dan Nettleton (Iowa State University) Statistics 510 8 / 46 Questions of Interest The potential explanatory variables and the response were recorded for 196 randomly selected individuals. Are any of these variables associated with the probability of disease and if so how? Copyright c 2017 Dan Nettleton (Iowa State University) Statistics 510 9 / 46 We will demonstrate how to use R to fit a logistic regression model to this dataset. Before delving more deeply into logistic regression, we will review the basic facts of the Bernoulli distribution. Copyright c 2017 Dan Nettleton (Iowa State University) Statistics 510 10 / 46 y Bernoulli(⇡) has probability mass function ⇠ k 1 k ⇡ (1 ⇡) − for k 0, 1 Pr(y = k)=f (k)= − 2{ } ( 0 otherwise Thus, 0 1 0 Pr(y = 0)=f (0)=⇡ (1 ⇡) − = 1 ⇡ − − and 1 1 1 Pr(y = 1)=f (1)=⇡ (1 ⇡) − = ⇡. − Copyright c 2017 Dan Nettleton (Iowa State University) Statistics 510 11 / 46 The variance of y is a function of the mean of y. 1 E(y)= kf (k)=0 (1 ⇡)+1 ⇡ = ⇡ · − · Xk=0 1 E(y2)= k2f (k)=02 (1 ⇡)+12 ⇡ = ⇡ · − · Xk=0 Var(y)=E(y2) [E(y)]2 = ⇡ ⇡2 = ⇡(1 ⇡) − − − Copyright c 2017 Dan Nettleton (Iowa State University) Statistics 510 12 / 46 The Logistic Regression Model For i = 1,...,n, y Bernoulli(⇡ ), i ⇠ i where exp(xi0β) ⇡i = 1 +exp(xi0β) and y1,...,yn are independent. Copyright c 2017 Dan Nettleton (Iowa State University) Statistics 510 13 / 46 The Logit Function The function ⇡ g(⇡)=log 1 ⇡ ✓ − ◆ is called the logit function. The logit function maps the interval (0, 1) to the real line ( , ). 1 1 ⇡ ⇡ is a probability, so log(1 ⇡ ) is the log(odds), where − Pr(A) the odds of an event A 1 Pr(A). ⌘ − Copyright c 2017 Dan Nettleton (Iowa State University) Statistics 510 14 / 46 Note that ⇡ g(⇡ )=log i i 1 ⇡ ✓ − i ◆ exp(x0β) 1 =log i 1 +exp(x0β) 1 +exp(x0β) i i =log[exp(xi0β)] = xi0β. Copyright c 2017 Dan Nettleton (Iowa State University) Statistics 510 15 / 46 Thus, the logistic regression model says that, y Bernoulli(⇡ ), where i ⇠ i ⇡i log = x0β 1 ⇡ i ✓ − i ◆ In Generalized Linear Models terminology, the logit is called the link function because it “links” the mean of yi (i.e., ⇡i) to the linear predictor xi0β. Copyright c 2017 Dan Nettleton (Iowa State University) Statistics 510 16 / 46 For Generalized Linear Models, it is not necessary that the mean of yi be a linear function of β. Rather, some function of the mean of yi is a linear function of β. For logistic regression, that function is ⇡i logit(⇡ ) = log = x0β. i 1 ⇡ i ✓ − i ◆ Copyright c 2017 Dan Nettleton (Iowa State University) Statistics 510 17 / 46 When the response is Bernoulli or more generally, binomial, the logit link function is one natural choice. However, other link functions can be considered. Some common choices (that are also available in R) include the following: 1 Copyright c 2017 Dan Nettleton (Iowa State University) Statistics 510 18 / 46 1 logit: ⇡ log = x0β. 1 ⇡ ✓ − ◆ 2 probit: 1 Φ− (⇡)=x0β, 1 where Φ− ( ) is the inverse of N(0, 1) CDF. · 3 Complementary log-log (cloglog in R): log( log(1 ⇡)) = x0β. − − Copyright c 2017 Dan Nettleton (Iowa State University) Statistics 510 19 / 46 Although any of these link functions (or others) can be used, the logit link has some advantages when it comes to interpreting the results (as we will discuss later). Thus, the logit link is a good choice if it can provide a good fit to the data. Copyright c 2017 Dan Nettleton (Iowa State University) Statistics 510 20 / 46 The log likelihood function for logistic regression is n yi 1 y `(β y)= log[⇡ (1 ⇡ ) − i ] | i − i i=1 Xn = [y log(⇡ )+(1 y )log(1 ⇡ )] i i − i − i i=1 Xn = [y log(⇡ ) log(1 ⇡ ) +log(1 ⇡ )] i{ i − − i } − i i=1 Xn ⇡i = yi log +log(1 ⇡i) 1 ⇡i − i=1 ✓ − ◆ Xn = [y x0β log(1 +exp x0β )] i i − { i } = Xi 1 Copyright c 2017 Dan Nettleton (Iowa State University) Statistics 510 21 / 46 For Generalized Linear Models, Fisher’s Scoring Method is typically used to obtain an MLE for β, denoted as βˆ. Fisher’s Scoring Method is a variation of the Newton-Raphson algorithm in which the Hessian matrix (matrix of second partial derivatives) is replaced by its expected value (-Fisher Information matrix). Copyright c 2017 Dan Nettleton (Iowa State University) Statistics 510 22 / 46 For generalized Linear Models, Fisher’s scoring method results in an iterative weighted least squares procedure. The algorithm is presented for the general case in Section 2.5 of Generalized Linear Models 2nd Edition (1989) by McCullough and Nelder. Copyright c 2017 Dan Nettleton (Iowa State University) Statistics 510 23 / 46 For sufficiently large samples, βˆ is approximately normal with mean β and a variance-covariance matrix that can be approximated by the estimated inverse of the Fisher Information Matrix; i.e., 1 βˆ · N(β,ˆI− (βˆ)) ⇠ Copyright c 2017 Dan Nettleton (Iowa State University) Statistics 510 24 / 46 Inference can be conducted using the Wald approach or via likelihood ratio testing as discussed in our course notes on likelihood-related topics. For example, a Wald confidence interval for c0β with approximate coverage probability of 0.95 is given by 1 c0βˆ 1.96 c ˆI− (βˆ)c ± 0 q Copyright c 2017 Dan Nettleton (Iowa State University) Statistics 510 25 / 46 Interpretation of Logistic Regression Parameters Let x =[x1, x2,...,xj 1, xj , xj+1,...,xp]0. − Let x˜ =[x1, x2,...,xj 1, xj + 1, xj+1,...,xp]0. − In other words, x˜ is the same as x except that the jth explanatory variable has been increased by one unit. Let ⇡ = exp(x0β) and ⇡˜ = exp(x˜0β) . 1+exp(x0β) 1+exp(x˜0β) Copyright c 2017 Dan Nettleton (Iowa State University) Statistics 510 26 / 46 The Odds Ratio ⇡˜ ⇡ ⇡˜ ⇡ =exp log 1 ⇡˜ 1 ⇡ 1 ⇡˜ 1 ⇡ − − ⇢ ✓ − − ◆ ⇡˜ ⇡ =exp log log 1 ⇡˜ − 1 ⇡ ⇢ ✓ − ◆ ✓ − ◆ =expx˜0β x0β { − } =exp(x + 1)β x β { j j − j j} =expβ . { j} Copyright c 2017 Dan Nettleton (Iowa State University) Statistics 510 27 / 46 ⇡˜ ⇡ Thus, 1 ⇡˜ =exp(βj)1 ⇡ . − − All other explanatory variables held constant, the odds of success at xj + 1 are exp(βj) times the odds of success at xj. This is true regardless of the initial value xj. Copyright c 2017 Dan Nettleton (Iowa State University) Statistics 510 28 / 46 A one unit increase in the jth explanatory variable (with all other explanatory variables held constant) is associated with a multiplicative change in the odds of success by the factor exp(βj). Copyright c 2017 Dan Nettleton (Iowa State University) Statistics 510 29 / 46 P L E E = 100 ( i - a) % ( ; p ; Uj ) U = # L E ( p ;) E ( 100 It a) % P ( exp ( ;) exp exp ;) ) If (L , U ) is a 100(1 ↵)% confidence interval for β , j j − j then (exp(Lj), exp(Uj)) is a 100(1 ↵)% confidence interval for exp(β ). − j Copyright c 2017 Dan Nettleton (Iowa State University) Statistics 510 30 / 46 Also, note that exp(x0β) 1 ⇡ = = 1 1 +exp(x0β) + 1 exp(x0β) 1 = . 1 +exp( x β) − 0 Thus, if (L ,U ) is a 100(1 ↵)% confidence interval for j j − x0β, then a 100(1 ↵)% confidence interval for ⇡ is − 1 1 , . 1 +exp( L ) 1 +exp( U ) ✓ − j − j ◆ Copyright c 2017 Dan Nettleton (Iowa State University) Statistics 510 31 / 46 > d=read.delim("http://dnett.github.io/S510/Disease.txt") > head(d) Ianort THIS id age ses sector disease savings VARIABLE IN 1 1 33 1 1 0 1 LwtTHIS EXAMPLE .

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    46 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us