nlme包为我提供了一种使用resid(fitted对象,type=“规范化”)对归一化残差进行合成的方法,但是lme4没有选择这样做。如果没有lme4中的这个特性,我就无法诊断自相关。
我不认为R stats包resid(lme4object,type="normalized")工作,lme4-object$residuals是不正确的语法。
lmer/glmer是merMod对象。
拟合混合效应模型描述的
类"merMod“--混合效应模型表示为继承自类lmResp的类的merPredD对象和响应模块。具有lmerResp响应的模型有类lmerMod;glmResp响应有类glmerMod;nlsResp响应有nlmerMod类。
定义“规范化”
采用归一化残差(标准化残差预乘以估计误差相关矩阵的平方根逆因子)。
另外,什么是“误差相关矩阵”?你是说费舍尔-信息/方差-协方差还是尤勒-沃克?
如何用lme4或手工计算归一化模型残差?
lme4只给出了“剩余标准差”、“皮尔逊”和“偏差残差”,以及列出的残差。文件开始:
Description
residuals of merMod objects
Usage
## S3 method for class 'merMod'
residuals(object,
type = if (isGLMM(object)) "deviance" else "response",
scaled = FALSE, ...)
## S3 method for class 'lmResp'
residuals(object,
type = c("working", "response", "deviance", "pearson", "partial"),
...)
## S3 method for class 'glmResp'
residuals(object,
type = c("deviance", "pearson", "working", "response", "partial"),
...)
Arguments
object a fitted [g]lmer (merMod) object
type type of residuals
scaled scale residuals by residual standard deviation (=scale parameter)?
... additional arguments (ignored: for method compatibility)
Details
• The default residual type varies between lmerMod and glmerMod objects: they try to mimic
residuals.lm and residuals.glm respectively. In particular, the default type is "response",
i.e. (observed-fitted) for lmerMod objects vs. "deviance" for glmerMod objects. type="partial"
is not yet implemented for either type.
• Note that the meaning of "pearson" residuals differs between residuals.lm and residuals.lme.
The former returns values scaled by the square root of user-specified weights (if any), but
not by the residual standard deviation, while the latter returns values scaled by the estimated
standard deviation (which will include the effects of any variance structure specified in the
weights argument). To replicate lme behaviour, use type="pearson", scaled=TRUE.https://cran.r-project.org/web/packages/lme4/lme4.pdf
https://cran.r-project.org/web/packages/nlme/nlme.pdf
https://search.r-project.org/CRAN/refmans/lme4/html/merMod-class.html
发布于 2022-08-23 14:20:08
nlme::lme允许在残差项中建模相关性和异方差,而lme4::lmer则不允许(在SAS术语中这些结构称为“R-端”结构)。指定type = "normalized"提供了能够解释/纠正残差中任何建模结构的残差;由于lme4::lmer没有这些结构,因此对残差进行规范化不会有任何作用。
如果线性混合模型(带有R-侧结构)表示为
y ~ MVN(mu, Sigma_r(phi))
mu = X beta + Z b
b ~ MVN(0, Sigma_g(theta))其中X是固定效应模型矩阵,beta是有限元参数向量,Z是随机效应模型矩阵,b是BLUP/条件模式的向量,Sigma_r和Sigma_g是残差和随机效应的协方差矩阵,phi和theta是定义这些矩阵的参数向量。
..。Sigma_r是误差相关(协方差)矩阵。在lmer中,Sigma_r总是齐次对角矩阵(phi^2*I)。
https://stackoverflow.com/questions/73459709
复制相似问题