In the first model, I believe you estimate two parameters: the mean and
the variance:
> fm <- lm(y ~ 1)
> 2*2 - 2 * logLik(fm)
'log Lik.' 40.49275 (df=2)
>
AIC(fm)
[1] 40.49275
A zero mean model:
fm0 <- lm(y ~ -1)
> 2*1 - 2 * logLik(fm0)
'log Lik.' 39.00611 (df=1)
> AIC(fm0)
[1] 39.00611
Regard
On 2021/5/12 19:49, Jinsong Zhao wrote:
Hi there,
I learned that AIC = 2 * npar - 2 * log(logLik(model)), where k is the
number of estimated parameters in the model.
k should be npar in the above sentence. Sorry for the mistake.
For examle:
> set.seed(123)
> y <- rnorm(15)
> fm <- lm(y
Hi there,
I learned that AIC = 2 * npar - 2 * log(logLik(model)), where k is the
number of estimated parameters in the model.
For examle:
> set.seed(123)
> y <- rnorm(15)
> fm <- lm(y ~ 1)
In this example, npar should be 1, so, AIC is:
> 2*1 - 2 * logLik(fm)
'log Lik.' 38.49275 (df=2)
However
3 matches
Mail list logo