首页 文章

Cholesky改变了lmer中的残留物

提问于
浏览
0

我目前正在使用线性混合模型(LMM),并希望执行一些残差分析 . 由于线性混合模型的残差“是相关的并且不一定具有恒定的方差”,因此它们不足以检查模型所依据的假设(Fitzmaurice等,2011,第266页) . 因此有人建议(Waternaux等人1989)使用Cholesky变换残差代替调查模型假设,参见Houseman等人 . (2004年)和Santos Nobre&da Motta Singer(2007年) .

也就是说,假设我们有一个形式为Yi =XiβZibiƐi的LMM,其中β是固定效应参数的向量,bi是正态分布随机效应的向量,其中Xi和Zi是设计矩阵 .

然后,残差ei = Yi-Xiβ是相关的,使用估计的β系数而不是未知的真实值,它们的观察对应物是相关的 . 我们将这些残差表示为ri . 通过找到ri的协方差矩阵的Cholesky分解来对残差进行去相关 . 也就是说,让Cov(ei)=Σi,让Lii'成为基于ri的Σi估计的Cholesky分解 . 然后将Cholesky变换的残差定义为r * i = Li-1ri . 这些是我试图从lme4(Bates et al.2015)包中得到的残差,但到目前为止还没有成功 .

但是,使用Fitzmaurice等人主页的数据 . (2011),我已经设法使用nlme包(而不是lme4包)从书中的案例研究中重新创建残差 . 代码如下 .

require(foreign) # To read dta-files
require(nlme) # The nlme package used to estimate the LMM.
require(mgcv) # Needed for the extract.lme.cov function

fat <- read.dta("https://content.sph.harvard.edu/fitzmaur/ala2e/fat.dta") # We read the data

# Add spline function for time, with a knot at age of menarch, denoted time = 0 in the data.
fat$timeknot <- fat$time * (fat$time > 0)

# Estimate the LMM with nlme
nlme.model <- lme(pbf ~ time + timeknot, data=fat, random = ~ 1 + time + timeknot | id)

# Calculate the residuals
raw.residuals <- residuals(nlme.model, level=0)

# Cholesky residuals
est.cov <- extract.lme.cov(nlme.model, fat) # We extract the blocked covariance function of the residuals
Li <- t(chol(est.cov)) # We find the Cholesky transformation of the residuals. (The transform is to get the lower trangular matrix.)
cholesky.residuals <- solve(Li) %*% raw.residuals # We then calculate the transformed residuals.

hist(cholesky.residuals) # We plot the residuals

因此,我的问题是,是否有一种简单的方法可以使用lme4包提取残差的估计协方差矩阵?或者直接获得Cholesky变换残差?

感谢任何帮助或指示 . 带着敬意,

/菲尔

References:

Bates,D.,Mächler,M.,Bolker,B . ,&Walker,S . (2015) . 使用lme4拟合线性混合效应模型 . 统计软件杂志,67(1),1-48 .

Fitzmaurice,G.M.,Laird,N.M . ,&Ware,J.H . (2011) . 应用纵向分析,第二版 . John Wiley&Sons .

Houseman,E.A.,Ryan,L.M . ,&Coull,B.A . (2004) . Cholesky残差用于评估具有相关结果的线性模型中的正常误差 . Journal of the American Statistical Association,99(466),383-394 .

Santos Nobre,J . ,&da Motta Singer,J . (2007) . 线性混合模型的残差分析 . Biometrical Journal:Journal of Mathematical Methods in Biosciences,49(6),863-875 .

Waternaux,C.,Laird,N.M . ,&Ware,J.H . (1989) . 纵向数据分析方法:血铅浓度和认知发展 . Journal of the American Statistical Association,84(405),33-41 .

1 回答

  • 0

    经过大量挖掘后,我发现这个问题的答案已经发布在本网站的其他地方,并且在发布我自己之前我没有找到该帖子 . (虽然我搜索了!)

    解决方案可以在这里找到:Get Residual Variance-Covariance Matrix in lme4

相关问题