混合效应对数线性模型

机器算法验证 分类数据 混合模式 对数线性
2022-04-08 05:16:13

在某些情况下,我想拟合违反观察之间的独立性假设的对数线性模型。通常情况下,我对每个主题都有多个观察结果。对数线性模型是否有混合效应扩展,例如线性和广义线性模型?

我对原则上这种东西的存在感兴趣,但也对它在 R 库中的具体存在感兴趣。

1个回答

对数线性或泊松模型是广义线性模型的一部分。查看允许混合效果建模的lme4包,带有family=poisson().

这是一个使用示例:

> data(homerun, package="Zelig")
> with(homerun, table(homeruns, month))
        month
homeruns April August July June March May September
       0    36     36   40   26     1  33        30
       1    13     17   11   21     1  14        14
       2     0      3    3    3     0   3         6
       3     1      0    0    1     0   1         0
> library(lme4)
> mod <- glmer(homeruns ~ player + (player - 1 | month), data=homerun, family=poisson())
> summary(mod)
Generalized linear mixed model fit by the Laplace approximation 
Formula: homeruns ~ player + (player - 1 | month) 
   Data: homerun 
   AIC   BIC logLik deviance
 305.8 324.6 -147.9    295.8
Random effects:
 Groups Name          Variance   Std.Dev.   Corr  
 month  playerMcGwire 7.9688e-10 2.8229e-05       
        playerSosa    6.6633e-02 2.5813e-01 0.000 
Number of obs: 314, groups: month, 7

Fixed effects:
            Estimate Std. Error z value Pr(>|z|)    
(Intercept)  -0.7949     0.1195  -6.651 2.91e-11 ***
playerSosa   -0.1252     0.2020  -0.620    0.535    
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 

Correlation of Fixed Effects:
           (Intr)
playerSosa -0.592

规模参数(用于检查可能的过度分散)可通过以下插槽获得:

summary(mod)@sigma

(通常 GLM 的等价物是summary(glm(...))$dispersion)。

lme4如@fabians 所建议的,可以在 R-forge、混合效果模型项目GLMM 常见问题解答中找到有关在 中实现的混合效果建模的更多信息

gamm4包也可能有趣,因为它允许拟合广义的加法混合模型。