What is the equation to calculate the log likelihood of a null model in logistic regression? I would like to calculate the log likelihood of the null model for a logistic regression manually. Ultimately, this is to calculate McFadden's pseudo-R2, and, yes, I could have software generate the log likelihood of the null model (that is my current workaround) but am looking to expand my understanding through manual calculation. I have looked online, but I am not confident that I have found the proper equation to do so.
What is the proper equation for this?
I tried the following equation from this lecture: $$ \ln L(\hat p) = n\bar y\ln(\hat p) + (n-n\bar y)\ln(1 - \hat p) $$
Where $ \hat p  = \bar y = \frac{\sum y_i}{n}$
However, this gives me huge log likelihood values. For example, with a sample size of 4000 and 50% of the labels in each category ($ p = 0.50 $), this gives a log likelihood of -5545.18. When using this to calculate McFadden's pseudo-R2 with a model log-likelihood, it's resulting in clearly erroneous R2 values > 0.99. When I run a model with only the intercept (array of 1s) to calculate the null model log likelihood in python's sklearn, I find pseudo-R2 values in the range of 0.01 - 0.09 (so no, it's not as simple as missing a $ 1 - ... $ for the R2 calculation, which was my initial guess). Could someone clarify what is wrong with this equation above or the proper way to calculate log likelihood for the null intercept model by hand?

$$L(y,\hat p)\\=\dfrac{1}{n}
\sum_{i=1}^n
\bigg[
y_i\log(\hat p_i)+
(1-y_i)\log(1-\hat p_i)
\bigg]
$$
In your case, the (null) model predicts $\bar y$ every time, so $\hat p_i=\bar y$ for every $i$.
To calculate your McFadden $R^2$, take that result as the denominator, and then the numerator is that equation with the $\hat p_i$ predicted by the model of interest.
$$
R^2_{McFadden} = 1 - \dfrac{
\dfrac{1}{n}
\sum_{i=1}^n
\bigg[
y_i\log(\hat p_i)+
(1-y_i)\log(1-\hat p_i)
\bigg]
}{
\dfrac{1}{n}
\sum_{i=1}^n
\bigg[
y_i\log(\bar y)+
(1-y_i)\log(1-\bar y)
\bigg]\\
= 1 - \dfrac{
\sum_{i=1}^n
\bigg[
y_i\log(\hat p_i)+
(1-y_i)\log(1-\hat p_i)
\bigg]
}{
\sum_{i=1}^n
\bigg[
y_i\log(\bar y)+
(1-y_i)\log(1-\bar y)
\bigg]
}
}
$$
