多项逻辑回归中的交互项

时间:2019-10-05 13:29:28

标签: r mlogit

我正在尝试预测响应类型的可能性(4个级别:正确,不正确,过早,遗漏)。我有4个预测变量:试验(连续变量,因主题而异,但约为1:80),组(分类变量,3个级别:“ HI”,“ MID”,“ LI”)和ITI(分类变量) ,分为4个级别:“ 3000”,“ 5000”,“ 7000”,“ 9000”)。

我想我了解如何看待主要效果和相互作用,但是我在相互作用项中得到了一些奇怪的系数,这些系数并不能真正反映数据,所以我想知道自己是否做错了事。

我的数据

mydat1$rat_ID<- as.factor(mydat1$rat_ID)

mydat1$response_type <- factor(mydat1$response_type, levels = c("correct", "incorrect", "premature", "omission"))
mydat1$response_type2 <- relevel(mydat1$response_type, ref = "incorrect")

mydat1$ITI <- factor(mydat1$ITI, levels = c("3000", "5000", "7000", "9000"))

mydat1$impulsivity <- factor(mydat1$impulsivity, levels = c("HI", "MID", "LI"))

#this is what my data looks like 
head(mydat1)
  Corr Prem Omiss Incorr  ITI rat_ID Trials response_type impulsivity response_type2
1    1    0     0      0 3000      1      1       correct         MID        correct
2    0    0     0      1 3000      1      2     incorrect         MID      incorrect
3    0    0     1      0 3000      1      3      omission         MID       omission
4    1    0     0      0 3000      1      4       correct         MID        correct
5    0    0     1      0 3000      1      5      omission         MID       omission
6    0    0     0      1 3000      1      6     incorrect         MID      incorrect


str(mydat1)
'data.frame':   6414 obs. of  10 variables:
 $ Corr          : num  1 0 0 1 0 0 0 0 0 0 ...
 $ Prem          : num  0 0 0 0 0 0 0 0 0 0 ...
 $ Omiss         : num  0 0 1 0 1 0 0 1 1 1 ...
 $ Incorr        : num  0 1 0 0 0 1 1 0 0 0 ...
 $ ITI           : Factor w/ 4 levels "3000","5000",..: 1 1 1 1 1 1 1 1 1 1 ...
 $ rat_ID        : Factor w/ 24 levels "1","2","3","4",..: 1 1 1 1 1 1 1 1 1 1 ...
 $ Trials        : int  1 2 3 4 5 6 7 8 9 10 ...
 $ response_type : Factor w/ 4 levels "correct","incorrect",..: 1 2 4 1 4 2 2 4 4 4 ...
 $ impulsivity   : Factor w/ 3 levels "HI","MID","LI": 2 2 2 2 2 2 2 2 2 2 ...
 $ response_type2: Factor w/ 4 levels "incorrect","correct",..: 2 1 4 2 4 1 1 4 4 4 ...

然后我运行多项式逻辑回归

test <- multinom(response_type2 ~ Trials*ITI*impulsivity, data = mydat1)

#coefficients of the logistic regression
summary(test)

z <- summary(test)$coefficients/summary(test)$standard.errors

##p values of the coefficients
p <- (1 - pnorm(abs(z), 0, 1)) * 2
p

例如LI的输出与HI进行比较,ITI9000与ITI3000进行比较

Coefficients:

          Trials:ITI9000:impulsivityLI
correct                    0.016879271
premature                  0.046295381
omission                   0.003091414

我的问题是互动的系数无法反映数据,例如事实并非如此,与不正确的响应相比,ITI9000vsITI3000中的LIvsHI试用增加了。

有人可以告诉我是否应该在此模型中添加一些内容吗?

0 个答案:

没有答案