泥泥蕉4482
Should there have been indications of any non-linear relationship, restricted cubic spline function of these continuous variables would potentially have been considered for entry into the linear mixed model.
这句话描述的统计方法该如何实现呢?如何把一个混杂因素的RCS函数纳入到混合模型中呢?请大佬指教!
土井挞克树
把函数看作一个独立变量转化带入模型就可以
loveliufudan
这句话描述的统计方法是将非线性关系的预处理变量通过RCS(restricted cubic spline)函数转换成多个类别变量,然后将这些转换后的类别变量作为自变量纳入到线性混合模型中。下面是R语言的代码实现:
library(splines)
计算出等间隔RCS转换后的类别变量
x_rcs <- ns(x, df = 5)
用类别变量建立混合模型
model <- lmer(y ~ x_rcs + (1 | random_var))
相关产品推荐
相关问答