【问题标题】:Effects package: Error using GLM binomial model效果包:使用 GLM 二项式模型时出错
【发布时间】:2013-11-19 11:21:30
【问题描述】:

过去我在 lme4 中使用 Effects 包非常成功,但现在我遇到了一个使用 glm 的非常简单的示例。当拟合二项式 glm 然后使用 Effect 绘制交互时,我收到一条错误消息"Error in Analyze.model(focal.predictors, mod, xlevels, default.levels,:the following predictor is not in the model: Freq*Gp"。下面是一个简单的例子来说明我的问题。

感谢您的帮助。

Gp<-c(rep("A",20),rep("B",20))
Freq<-c(rep(1,10),rep(2,10),rep(1,10),rep(2,10))
Resp<-sample(c(0,1),40, replace=T)
data<-data.frame(Gp)
data$Freq<-Freq
data$Resp<-Resp

m2<-glm(Resp~Freq*Gp, data,family=binomial)
eff<-Effect("Freq*Gp",m2)

【问题讨论】:

    标签: r glm


    【解决方案1】:

    来自帮助部分:Focus.predictors for Effect 要求预测变量的特征向量。对于交互,只需提供两个主要效果的向量即可。

    eff <- Effect(c('Freq', 'Gp'), m2)
    

    给予

    Freq*Gp effect
    
                  Gp
    Freq          A   B
      1   0.4000000 0.3
      1.2 0.4196106 0.3
      1.4 0.4394784 0.3
      1.6 0.4595421 0.3
      1.8 0.4797378 0.3
      2   0.5000000 0.3
    

    【讨论】:

    • 谢谢,引用的交互术语到现在为止都很好用,但这肯定是一种更好的方法。
    猜你喜欢
    • 1970-01-01
    • 2018-03-09
    • 2016-09-07
    • 2020-02-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-09-24
    • 1970-01-01
    相关资源
    最近更新 更多