[R-meta] How to do a graph with all variables and interactions
Viechtbauer, Wolfgang (SP)
wo||g@ng@v|echtb@uer @end|ng |rom m@@@tr|chtun|ver@|ty@n|
Thu Jul 18 13:16:44 CEST 2019
I am catching up on some old posts here. Not sure if this is still relevant.
Hi Rafael,
Still not sure what you are trying to do here. There are only 4 possible combinations of the two factors here, so I don't understand what you mean when you say that you want to plot all variables and their interactions. Certainly, you cannot fit a model that includes all of these main effects and interactions, since that would be completely overparameterized. You could fit various models where you change the reference levels, but then you are providing redundant information. Again, there are only 4 parameters in this model to obtain a fully saturated fixed effects structure.
Best,
Wolfgang
-----Original Message-----
From: Rafael Rios [mailto:biorafaelrm using gmail.com]
Sent: Monday, 20 May, 2019 18:37
To: Viechtbauer, Wolfgang (SP)
Cc: r-sig-meta-analysis using r-project.org
Subject: Re: How to do a graph with all variables and interactions
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
Universidade Estadual de Campinas (UNICAMP)
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
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")
head(dat)
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
Universidade Estadual de Campinas (UNICAMP)
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
More information about the R-sig-meta-analysis
mailing list