【问题标题】:Cholesky transformed residuals in lmerlmer中的Cholesky变换残差
【发布时间】:2018-09-10 12:37:04
【问题描述】:

我目前正在使用线性混合模型 (LMM) 并希望执行一些残差分析。由于线性混合模型的残差“相关且不一定具有恒定方差”,因此它们不足以检查模型背后的假设(Fitzmaurice et al. 2011, p. 266)。因此建议(Waternaux 等人,1989 年)使用 Cholesky 变换残差来研究模型假设,另见 Houseman 等人。 (2004) 和 Santos Nobre & da Motta Singer (2007)。

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

然后,残差 ei = Yi - Xiβ 是相关的,使用估计的 β 系数观察到的对应物也是相关的而不是未知的真实值。我们将这些残差表示为 ri。通过找到 ri 的协方差矩阵的 Cholesky 分解来对残差进行去相关。即令 Cov(ei) = Σi, 令 Lii' 为 Cholesky 分解基于 ri 的 Σi 估计值。然后将 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 变换的残差?

感谢任何帮助或指点。关于,

/菲尔

参考资料:

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)。 应用纵向分析,第二版。约翰威利父子公司。

Houseman, E. A.、Ryan, L. M. 和 Coull, B. A. (2004)。用于评估具有相关结果的线性模型中的正态误差的 Cholesky 残差。 美国统计协会杂志n, 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)。纵向数据分析方法:血铅浓度和认知发展。 美国统计协会杂志, 84(405), 33-41.

【问题讨论】:

    标签: r lme4 mixed-models nlme


    【解决方案1】:

    经过大量挖掘,我发现这个问题的答案已经发布在本网站的其他地方,而我在发布自己的帖子之前未能找到该帖子。 (虽然我确实搜索过!)

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

    【讨论】:

      猜你喜欢
      • 2012-09-27
      • 1970-01-01
      • 2020-10-22
      • 2020-11-25
      • 1970-01-01
      • 2020-03-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多