mod_results | R Documentation |
Using a metafor model object of class rma
or rma.mv
, this function creates a table of model results containing the mean effect size estimates for all levels of a given categorical moderator, and their corresponding confidence and prediction intervals. The function is capable of calculating marginal means from meta-regression models, including those with multiple moderator variables of mixed types (i.e. continuous and categorical variables).
mod_results(
model,
mod = "1",
group,
N = NULL,
weights = "prop",
by = NULL,
at = NULL,
subset = FALSE,
upper = TRUE,
...
)
model |
|
mod |
Moderator variable of interest that one wants marginal means for. Defaults to the intercept, i.e. |
group |
The grouping variable that one wishes to plot beside total effect sizes, k. This could be study, species, or any grouping variable one wishes to present sample sizes for. |
N |
The name of the column in the data specifying the sample size so that each effect size estimate is scaled to the sample size, N. Defaults to |
weights |
How to marginalize categorical variables. The default is |
by |
Character vector indicating the name that predictions should be conditioned on for the levels of the moderator. |
at |
List of levels one wishes to predict at for the corresponding variables in |
subset |
Used when one wishes to only plot a subset of levels within the main moderator of interest defined by |
upper |
Logical, defaults to |
... |
Additional arguments passed to |
A data frame containing all the model results including mean effect size estimate, confidence and prediction intervals
Shinichi Nakagawa - s.nakagawa@unsw.edu.au
Daniel Noble - daniel.noble@anu.edu.au
## Not run:
# Simple eklof data
data(eklof)
eklof<-metafor::escalc(measure="ROM", n1i=N_control, sd1i=SD_control,
m1i=mean_control, n2i=N_treatment, sd2i=SD_treatment, m2i=mean_treatment, data = eklof)
# Add the unit level predictor
eklof$Datapoint<-as.factor(seq(1, dim(eklof)[1], 1))
# fit a MLMR - accouting for some non-independence
eklof_MR<-metafor::rma.mv(yi=yi, V=vi, mods=~ Grazer.type, random=list(~1|ExptID,
~1|Datapoint), data = eklof)
results <- mod_results(eklof_MR, mod = "Grazer.type", group = "ExptID")
# Fish example demonstrating marginalised means
data(fish)
warm_dat <- fish
model <- metafor::rma.mv(yi = lnrr, V = lnrr_vi,
random = list(~1 | group_ID, ~1 | es_ID),
mods = ~ experimental_design + trait.type + deg_dif + treat_end_days,
method = "REML", test = "t",
control=list(optimizer="optim", optmethod="Nelder-Mead"), data = warm_dat)
overall <- mod_results(model, group = "group_ID")
across_trait <- mod_results(model, group = "group_ID", mod = "trait.type")
across_trait_by_degree_diff <- mod_results(model, group = "group_ID",
mod = "trait.type", at = list(deg_dif = c(5, 10, 15)), by = "deg_dif")
across_trait_by_degree_diff_at_treat_end_days10 <- mod_results(model, group = "group_ID",
mod = "trait.type", at = list(deg_dif = c(5, 10, 15), treat_end_days = 10),
by = "deg_dif",data = warm_dat)
across_trait_by_degree_diff_at_treat_end_days10And50 <- mod_results(model, group = "group_ID",
mod = "trait.type", at = list(deg_dif = c(5, 10, 15),
treat_end_days = c(10, 50)), by = "deg_dif")
across_trait_by_treat_end_days10And50 <- mod_results(model, group = "group_ID",
mod = "trait.type", at = list(deg_dif = c(5, 10, 15), treat_end_days = c(10, 50)),
by = "treat_end_days")
across_trait_by_treat_end_days10And50_ordinaryMM <- mod_results(model, group = "group_ID",
mod = "trait.type", at = list(deg_dif = c(5, 10, 15), treat_end_days = c(10, 50)),
by = "treat_end_days", weights = "prop")
# Fish data example with a heteroscedastic error
model_het <- metafor::rma.mv(yi = lnrr, V = lnrr_vi, random = list(~1 | group_ID, ~1 + trait.type| es_ID), mods = ~ trait.type + deg_dif, method = "REML", test = "t", rho = 0, struc = "HCS", control=list(optimizer="optim", optmethod="Nelder-Mead"), data = warm_dat)
HetModel <- mod_results(model_het, group = "group_ID", mod = "trait.type", at = list(deg_dif = c(5, 10, 15)), by = "deg_dif", weights = "prop")
orchard_plot(HetModel, xlab = "lnRR")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.