统计测试,基于ggpredict / ggeffect的输出比较第一/第二差

问题描述

我想在R中进行一个简单的两个样本t检验,以比较ggpredict(或ggeffect)产生的边际效应。

ggpredict和ggeffect都提供了不错的输出:(1)表(pred prob / std error / CIs)和(2)图。但是,它没有提供p值来评估边际效应的统计显着性(即,两个预测概率之差是否为零?)。此外,由于我正在使用“交互效应”,因此我也对两个差异(两个边际效应之间)和第二差异的两个t样本样本感兴趣。

是否有一种简单的方法可以通过ggpredict / ggeffect输出运行相关的t检验?还有其他选择吗?

附加: 。用虚拟数据表示代码 。具体来说:我要测试以下“第一个区别”:

-> .67-.33 = .34(与零相差吗?)

-> .5-.5 = 0(与零相差吗?)

...以及以下第二个区别:

-> 0.0-.34 = .34(与零相差吗?)

另请参阅Mize 2019中的图12 /表3(非线性模型中的交互作用)

感谢斯科特


  library(mlogit)
#> Loading required package: dfidx
#> 
#> Attaching package: 'dfidx'
#> The following object is masked from 'package:stats':
#> 
#>     filter
  library(sjPlot)
  library(ggeffects)
  
  # create ex. data set.  1 row per respondent (dataset shows 2 resp). Each resp answers 3 choice sets,w/ 2 alternatives in each set. 
  cedata.1 <- data.frame( id    =  c(1,1,2,2),# respondent ID. 
                          QES    = c(1,3,3),# Choice set (with 2 alternatives)    
                          Alt    = c(1,# Alt 1 or Alt 2 in  choice set 
                          LOC    = c(0,1),# attribute describing alternative. binary categorical variable
                          SIZE   = c(1,# attribute describing alternative. binary categorical variable
                          Choice = c(0,# if alternative is Chosen (1) or not (0)
                          gender = c(1,0)   # male or female (repeats for each indivdual) 
  )
  
  # convert dep var Choice to factor as required by sjPlot
  cedata.1$Choice <- as.factor(cedata.1$Choice)
  cedata.1$LOC <- as.factor(cedata.1$LOC)
  cedata.1$SIZE <- as.factor(cedata.1$SIZE)
  
  # estimate model. 
glm.model <- glm(Choice ~  LOC*SIZE,data=cedata.1,family = binomial(link = "logit"))

  # estimate MEs for use in IE assessment
LOC.SIZE <- ggpredict(glm.model,terms = c("LOC","SIZE")) 
LOC.SIZE
#> 
#> # Predicted probabilities of Choice
#> # x = LOC
#> 
#> # SIZE = 0
#> 
#> x | Predicted |   SE |       95% CI
#> -----------------------------------
#> 0 |      0.33 | 1.22 | [0.04,0.85]
#> 1 |      0.50 | 1.41 | [0.06,0.94]
#> 
#> # SIZE = 1
#> 
#> x | Predicted |   SE |       95% CI
#> -----------------------------------
#> 0 |      0.67 | 1.22 | [0.15,0.96]
#> 1 |      0.50 | 1.00 | [0.12,0.88]
#> Standard errors are on the link-scale (untransformed).

  # plot 
  # plot(LOC.SIZE,connect.lines = TRUE)

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...