Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 201839

Combinations of variables that produce the smallest quantities in an R function

$
0
0

I'm interested in finding out which combination of variables (bingefollowupsreportage) in my model below produce smallest I2 statistic in rank order (smallest to largest). The I2 from each model is obtained like so:

I2 <- function(x)as.double(x$mod_info$I.2).

Is there a way to automate this in R by looping over formulas?

Ex: First fitting effectsize ~ binge, then effectsize ~ binge + followup then ...

Note: suppose I have the names of all variables stored like so: 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.

Viewing all articles
Browse latest Browse all 201839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>