# Poisson regression log likelihood function given sample data

If $$Y_i$$ has a $$\textrm{Poisson}(\lambda_i)$$ distribution then it has density function, $$p(Y_i|\lambda_i) = \frac{\lambda_i^{Y_i}}{Y_i!}e^{−\lambda_i}$$ Suppose we think the variables $$Y_1, \dots , Y_n$$ follow a Poisson distribution. For each variable, we have an predictor $$X_i$$ and would like to model $$Y$$ as a function of X. So we get the poisson regression model with: $$λ_i = e^{\beta_0+\beta_1X_i}$$ write the log likelihood function in terms of $$x,y,\beta_1$$ and $$\beta_0$$.

I am a little stuck with this and think that the likelihood function here would be equal to $$-\sum e^{\beta_0+\beta_1 x_i}-\sum \log(y_i!)+\sum y_i (\beta_0+\beta_1 x_i)$$ Is this correct and if not how would I go about finding this log likelihood function?

The likelihood function is $$L(\beta_0,\beta_1\mid(Y_i)_{i=1}^n)=\prod_{i=1}^n p(Y_i\mid e^{\beta_0+\beta_1 X_i})=\prod_{i=1}^n\frac{(-e^{\beta_0+\beta_1 X_i})^{Y_i}}{Y_i!}\exp(-e^{\beta_0+\beta_1 X_i})$$ and so the log-likelihood is \begin{align*} l(\beta_0,\beta_1\mid(Y_i)_{i=1}^n)&=\log L(\beta_0,\beta_1\mid(Y_i)_{i=1}^n)\\ &=\sum_{i=1}^n\log\left[\frac{(e^{\beta_0+\beta_1 X_i})^{Y_i}}{Y_i!}\exp(-e^{\beta_0+\beta_1 X_i})\right]\\ &=\sum_{i=1}^n\log(e^{\beta_0+\beta_1 X_i})^{Y_i}-\sum_{i=1}^n\log(Y_i!)-\sum_{i=1}^ne^{\beta_0+\beta_1 X_i}\\ &=\sum_{i=1}^n(\beta_0+\beta_1 X_i)Y_i-\sum_{i=1}^n\log(Y_i!)-\sum_{i=1}^ne^{\beta_0+\beta_1 X_i}. \end{align*}