Docsity

Lecture Notes on Generalized Linear Models | STAT 8320, Exams of Statistics

Toggle sidebar
bg1
Generalized Linear Models
Lets begin with a simple example. Suppose that we
are interested in studying the likelihood of an individual
getting lung cancer. We measure a variety of variables
for each individual, including age, gender, number of
cigarettes smoked per day, etc. For each individual, we
also measure if the person develops lung cancer (we
cannot actually measure their chances of getting it).
In this case, we have a binary response variable,
Yi=½0,if the individual does not develop cancer,
1,if the individual does develop cancer.
In this case, Yiis a Bernoulli random variable with
pr(Yi= 1) = piand pr(Yi=0)=1−pi.
It is easy to see that E(Yi) = piand var(Yi) = pi(1 −pi).
Thus, we have a situation where the variance of the
response is a function of the mean.
This is a situation which we have not previously consid-
ered, but obviously causes problems with linear or non-
linear regression. Both of those methods assume that
the errors are independent and identically distributed,
which cannot be true of they are a function of the mean.
Typically in studies of this form, we will want to relate
the mean, pi(probability of developing cancer) to some
explanatory variables xi. One possible way to do this is
using a logistic regression model.
G.1
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19

Partial preview of the text

Download Lecture Notes on Generalized Linear Models | STAT 8320 and more Exams Statistics in PDF only on Docsity!

Generalized Linear Models

Lets begin with a simple example. Suppose that we are interested in studying the likelihood of an individual getting lung cancer. We measure a variety of variables for each individual, including age, gender, number of cigarettes smoked per day, etc. For each individual, we also measure if the person develops lung cancer (we cannot actually measure their chances of getting it).

In this case, we have a binary response variable,

Yi =

0 , if the individual does not develop cancer, 1 , if the individual does develop cancer.

In this case, Yi is a Bernoulli random variable with

pr(Yi = 1) = pi and pr(Yi = 0) = 1 − pi.

It is easy to see that E(Yi) = pi and var(Yi) = pi(1 − pi). Thus, we have a situation where the variance of the response is a function of the mean.

This is a situation which we have not previously consid- ered, but obviously causes problems with linear or non- linear regression. Both of those methods assume that the errors are independent and identically distributed, which cannot be true of they are a function of the mean.

Typically in studies of this form, we will want to relate the mean, pi (probability of developing cancer) to some explanatory variables xi. One possible way to do this is using a logistic regression model.

Logistic Regression

The form of a logistic regression is

pi = f (xi; θ) =

exp(x′ iθ) 1 + exp(x′ iθ)

There are several things to note about this form: 0 ≤ pi ≤ 1, for all θ and xi. Second, notice that this curve has a sigmoidal shape. To see this, let’s draw the shape for a single regressor xi.

We could equivalently write the logistic regression model by

logit(pi) = log

pi 1 − pi

= x′ iθ.

Here the form pi/(1 − pi) is called the odds. Intuitively, if pi = .8, then the odds is. 8 /.2 = 4, and we are four times more likely to be a 1 than a 0.

Additionally, notice that this form for the model high- lights the fact that a function of the mean response is linear. This is a property common to generalized linear models (and hence the name).

MLEs for Logistic Regression, Cont.

From the likelihood, we can show that

Q(θ) = log{L(θ)} =

∑^ n

i=

Yix′ iθ −

∑^ n

i=

log{1 + exp(x′ iθ)}.

We can maximize this function numerically using the optimization methods which we discussed in nonlinear regression. This will allow us to find the numerical MLE, θˆ.

Additionally, recall the useful property of MLEs that the large sample variance-covariance matrix is just the inverse Fisher Information matrix. Additionally,

θˆ ∼ AN(θ, [I(θ)]−^1 ,

where

I(θ) = E

[

∂ log{L(θ)} ∂θ

∂ log{L(θ)} ∂θ′

]

= E

[{

∂ log{L(θ)} ∂θi

∂ log{L(θ)} ∂θj

ij

]

In some cases, (under some regularity conditions) this is also equivalent to

I(θ) = −E

[

∂^2 log{L(θ)} ∂θ∂θ′

]

= −E

[{

∂^2 log{L(θ)} ∂θi∂θj

ij

]

MLEs for Logistic Regression, Cont.

For example, if we consider the model x′ iθ = θ 0 + θ 1 xi, it can be shown that

I(θ) =

[ ∑

i pi(1^ −^ pi)^

∑^ i^ xipi(1^ −^ pi) i xipi(1^ −^ pi)^

i x

2 i pi(1^ −^ pi)

]

and we could estimate this matrix using I(ˆθ).

Likelihood Ratio Tests:

We can then perform inference on θ based upon likeli- hood ratio tests. Recall, these compare the maximized value of the log-likelihood under both the null hypoth- esis, H 0 , and the unrestricted alternative. If the differ- ence is large, then the unrestricted model fits the data far better and we would reject H 0.

To formulate this test, let θ = [θ′ 1 , θ′ 2 ]′, and assume that we are interested in testing a hypothesis about θ 1. We will leave θ 2 unspecified; we call these parameters nui- sance parameters. Note that both θ 1 and θ 2 can be either a vector or a scalar, and θ 2 can be null.

Suppose that H 0 : θ 1 = θ 1 , 0 , and let ˆθ 2 , 0 be the MLE of θ 2 under the restriction. The likelihood ratio test statistic is given by

−2 log Λ = −2[log{L(θ 1 , 0 , θˆ 2 , 0 ) − L(ˆθ 1 , θˆ 2 )}].

We would reject the null hypotheis, H 0 , when −2 log Λ > χ^2 ν, 1 −α, where ν is the dimension of θ 1.

Interpretation of θ, Cont.

To understand the interpretation of the parameters, con- sider the simple case of a logistic regression with a single regressor. In this case, the model is

logit(ˆpi) = log

pˆi 1 − pˆi

= ˆθ 0 + ˆθ 1 xi.

Now, consider the value when x = xi + 1. Here,

logit{pˆ(xi + 1)} = ˆθ 0 + ˆθ 1 (xi + 1) = logit{pˆ(xi)} + ˆθ 1.

Next, recall that we called pi/(1 − pi) the odds. Then, notice that we can write

logit{pˆ(xi + 1)} − logit{ˆp(xi)} = log{odds[p(xi + 1)]} − log{o

= log

odds[p(xi + 1)] odds[p(xi)]

= ˆθ 1 ,

and

exp(ˆθ 1 ) =

odds[p(xi + 1)] odds[p(xi)]

the estimated odds ratio.

Then, if the estimate of exp(θ 1 ) is, for example, 2, we would say that the odds of success increase by 100% for each unit increase in the value of x.

Conversely, suppose that the estimate of θ 1 is less than 1, for example, 0.50. This would mean that the odds of success are halved for each unit increase in the value of x.

Interpretation of θ, Cont.

In general, the estimated odds ratio, when there is a difference of c units in the regressor x, is exp(cθˆ 1.

In general, exp(θk) is the estimated odds ratio for the variable xk, assuming that all of the other variables are held constant.

Inference on a mean response:

Let xh = (1, xh 1 , · · · , xh,p− 1 )′. Then, we have that

ˆph =

exp(x′ hˆθ) 1 + exp(x′ hˆθ)

and s^2 (ˆph) = x′ h[I(ˆθ)]−^1 xh. We could use this informa- tion to form approximate confidence intervals for the mean response in our model.

Additionally, suppose that we want to predict a new observation. We know that the observation must have value either 0 or 1, so we would predict the value of 1 when the estimated probability of success is large, and we would predict a 0 otherwise.

Other Functions:

We might be interested in some function other than the logistic. For example, we might believe that E(Yi) = pi = Φ(x′ iθ), where Φ() is the cdf of a N(0, 1). This is called the probit model. Other such models are also possible, but the logistic and probit are the most com- mon for this situation.

Generalized Linear Models

The problem for Poisson regression is actually quite sim- ilar to the logistic regression problem. In fact, we can generalize this to include a vast array of modelling op- tions. These are known as generalized linear models or GLMs.

Exponential Family:

There are many different ways to express the exponen- tial distribution. We are going to consider a special form which is useful for GLMs.

f (y; θ, φ) = exp

[

θy − b(θ) a(φ)

  • c(y, φ)

]

Here, θ is called the natural parameter and φ is called the dispersion parameter. This family includes the normal distribution, the binomial, the Poisson, the gamma, and the inverse gamma distributions.

Let’s show this for the normal distribution by finding the forms above.

Exponential Family, Cont.

GLM exponential families have the nice properties that

  1. E(Y ) = b′(θ) where b′(θ) = ∂b(θ)/∂θ.
  2. var(Y ) = a(φ)b′′(θ) = a(φ)V (μ). Here V (μ) is called the variance function, though it is not the variance unless a(φ) = 1.
  3. Thus, if we identify a(), b(), and c(), we can get the expected value and variance of Y.

Let’s use this to find the mean and variance for the nor- mal distribution (and compare them to what we know).

We could also do this for another distribution, perhaps for the Poisson distribution.

Notation

For the random component:

  • Assume that there are n independent response vari- ables, Y 1 , · · · , Yn with densities

f (y; θi, φ) = exp

[

θiy − b(θi) a(φ)

  • c(y, φ)

]

  • Assume that φ is constant for all i = 1, · · · , n, but allow θi to vary. μi = E(Yi) for all i.

For the systematic component, assume g(μi) = x′ iβ = ηi,

where β = (β 1 , · · · , βp)′. The parameters to be estimated are β 1 , · · · , βp, φ.

The Canonical Link:

If the link function g(·) is such that g(μi) = θi, the natural parameter, then g(·) is called the canonical link.

Examples:

  • Normal random component is μi = θi. Then, the canonical link is g(μi) = μi, the identity link.
  • Binomial random component is μi = ni exp(θi)/{1+ exp(θi)}, so the canonical link is

g(μi) = log

μi ni − μi

the logit link.

The Canonical Link, Cont.

  • Poisson random component is μi = exp(θi). Then the canonical link is g(μi) = log(μi).
  • Gamma random component model has canonical link g(μi) = 1/μi.
  • Inverse gaussian random component model has canon- ical link g(μi) = 1/μ^2 i.

Estimation:

  • We can use the MLE for parameters of the system- atic component β.
  • The exponential form allows for unification of deriva- tion and computation of the MLEs.
  • Similar unification is not available for estimation of the dispersion parameter φ. This is a limitation.

Estimation of β:

For the random component: Y 1 , · · · , Yn are independent with densities

f (y; θi, φ) = exp

[

θiy − b(θi) a(φ)

  • c(y, φ)

]

Recall that E(Yi) = μi = b′(θ) and var(Yi) = b′′(θ)a(φ) = V (μi)a(φ). The systematic component is g(μi) = x′ iβ = ηi.

Estimation of β, Cont.

Similarly, we can get expressions for the second deriva- tives. However, if we wish to use a Newton-Raphson algorithm, we really only need

−E

∂^2 `(β, φ) ∂βj∂βk

We can show that this is equal to

∑^ n

i=

wi a(φ)

xijxik,

for the i, jth element.

Then, the “Fisher-score” algorithm for the MLE of β is

  

β 1 β 2 ... βp

(m+1)

β 1 β 2 ... βp

(m)

  • I n− 1 (β)

∂(β,φ) ∂β 1 ∂(β,φ) ∂β 2 ... ∂`(β,φ) ∂βp

β=β(m)

Note the similarity of this algorithm to the Newton- Raphson algorithm that we discussed earlier.

It is also possible to write this as a weighted least squares problem with weights wi. See McCulloch and Searle,

  1. This is easy to implement.

Notes on a(φ): if a(φ) is a constant or of the form miφ with mi known, then φ cancels.

Estimation of φ

There are two approaches that we could consider

  1. MLE: Recall that ∂`i ∂φ

{θiyi − b(θi)}a′(φ) a^2 (φ)

∂c(yi, φ) ∂φ

and the MLE of φ solves

a^2 (φ) a′(φ)

∑^ n

i=

∂c(yi, φ) ∂φ

∑^ n

i=

{θiyi − b(θi)}.

  • For many situations (most other than the nor- mal case) expressions for ∂c(y, φ)/∂φ are not simple.
  • Even for the canonical link at a(φ) constant, there is no nice general expression for −E(∂^2 `/∂φ^2 ), so the unification GLMs provide for estimation of β breaks down for φ.
  1. Moment Estimation (Bias Corrected χ^2 ): The MLE is not the conventional approach to estimation of φ in GLMs. Recall that for the exponential family var(y) = V (μ)a(φ). This implies that

a(φ) =

var(y) V (μ)

E(y − μ)^2 V (μ)

Deviance, Cont.

  • For exponential families, μ = E(y) = b′(θ), so the natural parameter is a function of μ: θ = θ(μ) = b

′− 1 (μ), so the likelihood ration is then

∑^ n

i=

yi{θ(˜μi) − θ(ˆμi)} − b{θ(˜μi)} + b{θ(ˆμi)} ai(φ)

  • Now, think about comparing a fitted residual model to a saturated model (˜μi = yi, i = 1, · · · , n). If we now let ˜θ∗ i = θ(yi) and ˆθ∗ i = θ(μi), we can write the likelihood ratio as

∑^ n

i=

yi(˜θ∗ i − ˆθ∗ i ) − b(˜θ∗ i ) + b(ˆθ∗ i ) ai(φ)

  • Finally, McCullagh and Nelder (1989) specify that if a(φ) = φ/wi, then the likelihood ratio can be written as

∑^ n

i=

wi{yi(˜θ i∗ − θˆ i∗ ) − b(˜θ∗ i ) + b(ˆθ∗ i )}/φ.

They call this quantity the “scaled deviance”.

  • Notation:
    • Deviance: D(y, μˆ) = 2

∑n i=1 wi{yi(˜θ

∗ i −ˆθ

∗ i )−b(˜θ

∗ i )+ b(ˆθ∗ i )}.

Deviance, Cont.

  • Notation, Cont.
    • Scaled Deviance: D∗(y, μˆ) = D(y, ˆμ)/φ.
    • Deviance contribution of an observation: di, where D =

∑n i=1 di.

  • Usually,
    • D is used in model selection.
    • D∗^ is used in goodness of fit tests (as it is a likelihood ratio statistic).
    • di are used to form the deviance residuals.

Let’s find the form of the deviance for a sample from the normal distribution:

Also, let’s do this for a sample from the Poisson distri- bution: