Docsity

Maximum Likelihood Estimation and Hypothesis Testing for Logistic Regression in BIOST 515, Study notes of Biostatistics

Partial preview of the text

Download Maximum Likelihood Estimation and Hypothesis Testing for Logistic Regression in BIOST 515 and more Study notes Biostatistics in PDF only on Docsity!

Lecture 13

Estimation and hypothesis testing for

logistic regression

BIOST 515

February 19, 2004

Outline

  • Review of maximum likelihood estimation
  • Maximum likelihood estimation for logistic regression
  • Testing in logistic regression

The joint probability of the data (the likelihood) is given by

L =

∏^ n

i=

pYi(1 − p)^1 −Yi

= p

Pn i=1 Yi(1 − p)n−

Pn i=1 Yi.

For estimation, we will work with the log-likelihood

l = log(L) =

∑^ n

i=

Yi log(p) + (n −

∑^ n

i=

Yi)log(1 − p).

The maximum likelihood estimate (MLE) of p is that value that maximizes l (equivalent to maximizing L).

The first derivative of l with respect to p is

U (p) =

∂l ∂p

∑^ n

i=

Yi/p − (n −

∑^ n

i=

Yi)/(1 − p)

and is referred to as the score funcion. To calculate the MLE of p, we set the score function, U (p) equal to 0 and solve for p. In this case, we get an MLE of p that is

p ˆ =

∑^ n

i=

Yi/n.

We can estimate the information by substituting the MLE of p into I(p), yielding I(ˆp) = (^) p ˆ(1n−pˆ).

Our next interest may be in making inference about the parameter p. We can use the the inverse of the information evaluated at the MLE to estimate the variance of pˆ as

var̂ (ˆp) = I(ˆp)−^1 =

pˆ(1 − pˆ) n

For large n, pˆ is approximately normally distributed with mean p and variance p(1 − p)/n. Therefore, we can construct a 100 × (1 − α)% confidence interval for p as

p ˆ ± Z 1 −α/ 2 [ˆp(1 − pˆ)/n]^1 /^2.

Hypothesis tests

  • Likelihood ratio tests
  • Wald tests
  • Score tests

For the binary outcome discussed above, if the hypothesis is H 0 : p = p 0 vs HA : p 6 = p 0 , then

l(H 0 ) =

∑^ n

i=

Yi log(p 0 ) + (n −

∑^ n

i=

Yi) log(1 − p 0 ),

l(M LE) =

∑^ n

i=

Yi log(ˆp) + (n −

∑^ n

i=

Yi) log(1 − pˆ)

and the LRT statistic is

LR = − 2

[ (^) n ∑

i=

Yi log(p 0 /pˆ) + (n −

∑^ n

i=

Yi) log{(1 − p 0 )(1 − pˆ)}

]

where LR ∼ χ^21.

Wald test

The Wald test statistic is a function of the difference in the MLE and the hypothesized value, normalized by an estimate of the standard deviation of the MLE. In our binary outcome example,

W =

(ˆp − p 0 )^2 p ˆ(1 − pˆ)/n

For large n, W ∼ χ^2 with 1 degree of freedom. In R, you will see

W ∼ N (0, 1) reported.

How does this all relate to logistic regression?

So far, we’ve learned how to estimate p and to test p in the one-sample bernoulli case. How can we use this with logistic regression.

  • MLEs for βs
  • Testing hypotheses about the βs
  • Constructing confidence intervals for the βs

MLEs for coefficients in logistic regression

Remember: E[Yi] = πi

and logit(πi) = β 0 + β 1 xi 1 + · · · + βpxip = x′ iβ,

where xi = (1, xi 1 ,... xip)′^ and β = (β 0 ,... , βp)′. Therefore

E[Yi] =

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

The p + 1 score functions of β for the logistic regression model cannot be solved analytically. It is common to use a numerical algorithm, such as the Newton-Raphson algorithm, to obtain the MLEs.

The information in this case will be a (p + 1) × (p + 1) matrix of the partial second derivatives of l with respect to the parameters, β. The inverted information matrix is the covariance matrix for βˆ.

Testing a single logistic regression coefficient in

R

To test a single logistic regression coefficient, we will use the Wald test, βˆj − βj 0 se ˆ( βˆ)

∼ N (0, 1),

where seˆ ( βˆ) is calculated by taking the inverse of the estimated information matrix. This value is given to you in the R output for βj 0 = 0. As in linear regression, this test is conditional on all other coefficients being in the model.

Confidence intervals for the coefficients and

In the model the odds ratios

logit(πi) = β 0 + β 1 xi 1 + · · · + βpxip,

a (1 − α/2) × 100% confidence interval for βj, j = 1,... , p, can easily be calculated as

β^ ˆj ± Z 1 −α/ 2 seˆ( βˆj).

The (1 − α/2) × 100% confidence interval for the odds ratio over a one unit change in xj is [ exp( βˆj − Z 1 −α/ 2 seˆ( βˆj)), exp( βˆj + Z 1 −α/ 2 seˆ ( βˆj))

]

What about for a 10 unit change in xj?

Example

logit(πi) = β 0 + β 1 cad.duri + β 2 genderi. Estimate Std. Error z value Pr(>|z|) (Intercept) −0.3203 0.0579 −5.53 0. cad.dur 0.0074 0.0008 9.30 0. sex −0.3913 0.1078 −3.63 0.

95% CI for a one-unit change in cad.dur:

[exp(. 0074 − 1. 96 × 0 .0008), exp(.0074 + 1. 96 × 0 .0008)]

[

e^0.^0058 , e^0.^0090

]

= [1. 006 , 1 .009]

How can we construct a similar confidence interval for males vs. females?