Lecture 4

Oct 5th, 2026




HW4: (Due on Oct 7th)

1. In the plasma dataset, test if fibrinogen predicts the ESR<20 or not. 
2. In the ER visit dataset, test if ER visits differ between two sites after taking the medication. 
3. In the RNA seq data, pick a gene that is NOT CADM1, and test if its expression is associated with smoking status.  

Maximum Likelihood Estimate


To fit a logistic regression to data, the estimation of $\beta_0$ and $\beta_1$ has to follow some principles. In linear regression, we tried to find a straight line that minimized the sum of residual squares, and the estimate is called least square estimate. For generalized linear models, a different but more general principle is used. The two numbers are obtained as they maximize a so-called likelihood function. Essentially, if the assumptions of our model is true (logistic link function and binomial distribution), under these two numbers, the probability of observing our data is the greatest. We call them maximum likelihood estimate (MLE). MLE is a general concept that can be applied to almost all (parametric) models, and there are general procedures through numerical iteration to find them under most of the situations.

Let me try to explain it with a much simpler example. Say we draw 4 balls from a basket of blue and red balls (with replacement), and got 2 red and 2 blue. Denote the proportion of the red balls in the basket as p, the probability of getting 2 red balls and 2 blue balls is ${4 \choose 2}p^2(1-p)^2$. To estimate the proportion of red balls, we want to find a $\hat{p}$ that gives me the greatest probability of getting two red and two blue balls. You can verify that this is achieved when $\hat{p}=0.5$. If you have taken calculus and still remember how to apply derivatives to find the maximum of a function, you can show that in general, if we get $m$ red balls out of $n$ draws, the maximum likelihood estimate of $p$ is $m/n$.

In general, the total likelihood of observed data can be written as a function of parameters $\theta$, where $\theta$ is a vector of all parameters,
$$ L(\theta) = \prod_i^n P(\bf{y}_i|\theta),$$
where $P(\bf{y}_i|\theta)$ is the probability of observing data point $\bf{y}_i$ given $\theta$.

In the logistic regression model, $P(y_i|x_i,\theta)$ follows a Binomial distribution $B(1,p_i)$, where $log(\frac{p_i}{1-p_i})=\beta_0+\beta_1x_i$;
In the Poisson regression model, $P(y_i|x_i,\theta)$ follows a Poisson distribution $Pois(\lambda_i t_i)$; where $log(\lambda_i) = \beta_0+\beta_1x_i$;
In the negative binomial regression, $P(y_i|x_i,\theta)$ follows Negative Binomial Distribution. 
 
For mathematical convenience, we usually find $\hat\theta$ by maximizing log-likelihood
$$ll(\theta) = log(L(\theta)) = \sum_i^n log(P(y_i|\theta)).$$

Related to MLE (maximum likelihood estimate) is a general hypothesis test statistic called likelihood ratio tests. A likelihood ratio test (LRT) using the difference in deviance compares two nested statistical models by subtracting the residual deviance of the complex model from the deviance of the simpler model.  In the study on the age of menarche, we compare two models, the simpler model is the null model and the complex model is the one with age as the predictor.  The statistical significance of the model complicated model is obtained by compare the difference in the deviance ($D_1-D_2$) with the difference of the degree freedoms ($df_1-df_2$). If the null model is true, the difference in deviance $D_1-D_2$ should follow a chi-square distribution with degree of freedom $df_1-df_2$. Note that deviance is $-2\times ll(\theta)$. 






Comments

Popular posts from this blog

Final Exam

Syllabus

Lecture 2