全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 R语言论坛
1850 2
2021-11-30
求助各位!
R语言新手,想线性混合模型分析,数据:center和disease是分类变量,FP和Q5是连续变量。模型:Q5是应变量,disease、FP和两者的交互效应设为固定效应,center设为随机效应,包括截距和与FP的交互效应。
代码如下:
> library(readxl)
> Q5 <- read_excel("LNR5.xlsx", col_types = c("text",
+     "text", "numeric", "numeric"))
> View(Q5)
> which(is.na(Q5)==T)
integer(0)
> library(Matrix)
> library(lme4)
> Q5.model = lmer(Q5 ~ disease + FP + FP|disease + (1 + FP|center),data=Q5)

结果提示如下错误,请问有人知道这是什么意思和如何解决么?
Error: Invalid grouping factor specification, disease + (1 + FP | center)
In addition: Warning messages:
1: In Ops.factor(1, FP) : ‘+’ not meaningful for factors
2: In Ops.factor(1 + FP, center) : ‘|’ not meaningful for factors
3: In Ops.factor(disease, (1 + FP | center)) :
  ‘+’ not meaningful for factors


捕获1.PNG
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

全部回复
2021-12-14 07:33:56
导入数据时,col_types = c("text", "text", "numeric", "numeric")这里吧前两个变量的类型改为numeric再试试
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2022-12-15 16:05:03
col_types = c("text", "text", "numeric", "numeric"
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群