R语言regmedint包中介分析

最近在用R语言做中介分析,用的是regmedint包,操作代码如下,

regmedint_obj1 <- regmedint(data = be,
                            ## Variables
                            yvar = "sleeptime.group7",
                            avar = "AZI",
                            mvar = "log5HT",
                            cvar = c("SEX","age.1","exer3"),
                            ## Values at which effects are evaluated
                            a0 = 0,
                            a1 = 1,
                            m_cde = 1,
                            c_cond = 1,
                            ## Model types
                            mreg = "linear",
                            yreg = "logistic",
                            ## Additional specification
                            interaction = FALSE,
                            casecontrol = FALSE)
运行后出现报错,Error: length(c_cond) not equal to length(cvar)
不知道是cvar还是c_cond 出了问题,一直不明白c_cond应该怎么设置,R包给的说明是c_cond:A numeric vector of the same length as cvar. Covariate levels at which natural direct and indirect effects are evaluated at.



错误信息提示的直接意思是c_cond和cvar的长度应该一样长,但是你的代码运行结果中,这两个东西的长度不一样的所以报错了。c_cond和cvar应该是长度相等的两个数值化向量。你现在cvar设置了三个值,那么c_cond也设置3个值就可以。望采纳