我有兴趣找出下面模型中哪种变量组合(binge
followup
sreport
age
)产生最小的I2
统计量顺序(最小到最大)。每个模型的I2
如下获得:
I2 <- function(x)as.double(x$mod_info$I.2)
。
有没有一种方法可以通过循环公式自动在R中实现这一目标?
示例::首先拟合effectsize ~ binge
,然后拟合effectsize ~ binge + followup
,然后...
注意: :假设我已存储了所有变量的名称,例如:var.names = c("binge","followup","sreport","age")
。
library(robumeta)
fit <- robu(effectsize ~ binge + followup + sreport + age,data = get(data(hierdat)),study = studyid,var = var)
# Get the `I2` for the above model:
I2(fit) # gives 63.993
# Note: I think `lapply(seq_along(var.names),function(i)combn(var.names,i))` can
# give us each combination that should be used in the formula.