How does lmer (from the R package lme4) compute log likelihood?

依然范特西╮ 提交于 2019-12-02 21:05:11
stewbasic

The links in the comments contained the answer. Below I've put what the formulae simplify to in this simple example, since the results are somewhat intuitive.

lmer fits a model of the form

, where

and

are independent normals with variances

and

respectively. The joint probability distribution of

and

is therefore

where

.

The likelihood is obtained by integrating this with respect to

(which isn't observed) to give

where

is the number of observations from group

, and

is the mean of observations from group

. This is somewhat intuitive since the first term captures spread within each group, which should have variance

, and the second captures the spread between groups. Note that

is the variance of

.

However, by default (REML=T) lmer maximises not the likelihood but the "REML criterion", obtained by additionally integrating this with respect to

to give

where

is given below.

Maximising likelihood (REML=F)

If

is fixed, we can explicitly find the

and

which maximise likelihood. They turn out to be

Note

has two terms for variation within and between groups, and

is somewhere between the mean of

and the mean of

depending on the value of

.

Substituting these into likelihood, we can express the log likelihood

in terms of

only:

lmer iterates to find the value of

which minimises this. In the output,

and

are shown in the fields "deviance" and "logLik" (if REML=F) respectively.

Maximising restricted likelihood (REML=T)

Since the REML criterion doesn't depend on

, we use the same estimate for

as above. We estimate

to maximise the REML criterion:

The restricted log likelihood

is given by

In the output of lmer,

and

are shown in the fields "REMLdev" and "logLik" (if REML=T) respectively.
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!