# [R-meta] How to do a graph with all variables and interactions

Rafael Rios b|or@|@e|rm @end|ng |rom gm@||@com
Mon May 20 18:37:22 CEST 2019

```Dear Wolfgang,

Thanks for the answers. I want to plot the mean and confidence intervals of
all variables and their interactions in the same graph. In the example,
they are var1A, var1B, var2C, var2D, var1A:var2C, var1A:var2D, var1B:var2C,
and var1B:var2D. To obtain coefficients and confidence intervals, do I need
to run a model for each variable and to the interaction? Will the values be
different when compared with the full model? I tried to use different
combinations but the estimates changed depending on the model. The advices
on tests to investigate outleirs were very helpful! Thank you.

Best wishes,

Rafael.
__________________________________________________________

Dr. Rafael Rios Moura
*scientia amabilis*

Behavioral Ecologist, D.Sc.
Postdoctoral Researcher
Campinas, São Paulo, Brazil

ORCID: http://orcid.org/0000-0002-7911-4734
Currículo Lattes: http://lattes.cnpq.br/4264357546465157
Research Gate: https://www.researchgate.net/profile/Rafael_Rios_Moura2

<http://buscatextual.cnpq.br/buscatextual/visualizacv.do?id=K4244908A8>

Em seg, 20 de mai de 2019 às 12:49, Viechtbauer, Wolfgang (SP) <
wolfgang.viechtbauer using maastrichtuniversity.nl> escreveu:

> Dear Rafael,
>
> I am not sure what you are asking in the first part. As you have
> illustrated, one could plot predicted values (with corresponding CIs) in a
> forest plot, although the last predicted value is a bit strange. Maybe you
> meant (i.e., the combination of B and D):
>
> preds=predict(res,newmods=rbind(c(0,0,0),c(1,0,0),c(0,1,0),c(1,1,1)))
>
> You can also get the same with:
>
> res <- rma.mv(yi, vi, mods=~var1:var2-1, random=list(~1|school,~1|year),
> data=dat)
> forest(coef(res), diag(vcov(res)), slab=names(coef(res)))
>
> So, in what sense is this not satisfactory for your actual purposes?
>
> As for the second question:
>
> You could examine the data for potential outliers / influential cases with
> rstudent() and cooks.distance() at various levels (i.e., using the
> 'cluster' argument). So:
>
> rstudent(res)
> rstudent(res, cluster=dat\$study)
> rstudent(res, cluster=dat\$animal)
> ...
>
> and the same with cooks.distance().
>
> There isn't a strict cutoff for the Cook's distances. I would just plot
> them and see if there are 'spikes'. So, using the earlier example:
>
> sav <- cooks.distance(res)
> plot(sav, type="o")
>
> # shows some spikes; probably multiple estimates from the same district
> that are influential:
>
> sav <- cooks.distance(res, cluster=dat\$district)
> plot(sav, type="o")
>
> Best,
> Wolfgang
>
> -----Original Message-----
> From: Rafael Rios [mailto:biorafaelrm using gmail.com]
> Sent: Monday, 20 May, 2019 7:48
> To: Viechtbauer, Wolfgang (SP); r-sig-meta-analysis using r-project.org
> Subject: How to do a graph with all variables and interactions
>
> Dear Wolfgang and All,
>
> How can I graph all variables and interactions for a mixed-effects
> meta-analysis? I am providing an example bellow in wich part of the
> variables and an interaction can be vizualised in the forest plot. In
> addition, what are the most approppriate analyzes to investigate potential
> effects of outliers in more complex models, such as a multilevel
> meta-analysis controlling for phylogenetic non-independence? In case of
> using Cook's distance, what should be the value of cut-off value?
>
> library(metafor)
> dat <- dat.konstantopoulos2011
> dat\$var1=c("A","B")
> dat\$var2=c("C","C","D", "D")
> res <- rma.mv(yi, vi, mods=~var1*var2, random=list(~1|school,~1|year),
> data=dat)
> summary(res)
>
> preds=predict(res,newmods=rbind(c(0,0,0),c(1,0,0),c(0,1,0),c(0,0,1)))
> forest(preds\$pred, sei=preds\$se, slab=c("intercept", "var1B", "var2D",
> "var1B:var2D"))
>
> Best wishes,
>
> Rafael.
> __________________________________________________________
>
> Dr. Rafael Rios Moura
> scientia amabilis
>
> Behavioral Ecologist, D.Sc.
> Postdoctoral Researcher