Calculates the two log-likelihood of \(X\) following a normal distribution.
norm2ll(mu, sigma, x, neg = TRUE)
mu | Numeric. Location parameter mean \(\mu\). |
---|---|
sigma | Numeric. Positive number. Scale parameter standard deviation \(\sigma = \sqrt{\sigma^2}\). |
x | Numeric vector. Values of the random variable \(X\). |
neg | Logical.
If |
The two log-likelihood for the normal (or Gaussian or Gauss or Laplace–Gauss) distribution is given by $$ 2 \mathcal{l} \left( \mu, \sigma^2 \mid x \right) = 2 \left[ - \frac{n}{2} \ln 2 \pi \sigma^2 - \frac{1}{2 \sigma^2} \sum_{i = 1}^{n} \left( x_i - \mu \right)^2 \right] \\ = - n \ln 2 \pi \sigma^2 - \frac{1}{\sigma^2} \sum_{i = 1}^{n} \left( x_i - \mu \right)^2 %(\#eq:dist-norm2ll) $$ with independent and identically distributed sample data \(x \in \mathbf{R}\), \(\mu\) is the location parameter mean being estimated (\(\mu \in \mathbf{R}\)), and \(\sigma^2\) is the scale parameter variance being estimated (\(\sigma^2 > 0\)).
The negative two log-likelihood is given by $$ - 2 \mathcal{l} \left( \mu, \sigma^2 \mid x \right) = - 2 \left[ - \frac{n}{2} \ln 2 \pi \sigma^2 - \frac{1}{2 \sigma^2} \sum_{i = 1}^{n} \left( x_i - \mu \right)^2 \right] \\ = n \ln 2 \pi \sigma^2 + \frac{1}{\sigma^2} \sum_{i = 1}^{n} \left( x_i - \mu \right)^2 . %(\#eq:dist-normneg2ll) $$
Wikipedia: Normal Distribution
Wikipedia: Likelihood Function