[R-meta] metafor - specifying spatial random effects

Viechtbauer, Wolfgang (SP) wo||g@ng@v|echtb@uer @end|ng |rom m@@@tr|chtun|ver@|ty@n|
Fri Aug 21 11:00:53 CEST 2020

Dear Grace,

Can you post the output of both models?


>-----Original Message-----
>From: Grace Pold [mailto:apold using umass.edu]
>Sent: Friday, 21 August, 2020 5:21
>To: Viechtbauer, Wolfgang (SP); r-sig-meta-analysis using r-project.org <r-sig-
>meta-analysis using r-project.org>
>Subject: RE: metafor - specifying spatial random effects
>Dear Wolfgang,
>I have a follow-up question.
>When comparing the spatial and the non-spatial models, I have different
>parameter estimates as expected. However, the residuals are identical for
>the two models. Is it expected that there would be the same residuals for
>the spatial and non-spatial models?
>Thank you for your assistance,
>From: Viechtbauer, Wolfgang (SP)
>Sent: Thursday, August 20, 2020 4:28 AM
>To: Grace Pold; r-sig-meta-analysis using r-project.org <r-sig-meta-analysis using r-
>Subject: RE: metafor - specifying spatial random effects
>Dear Grace,
>you need to create a variable that is a constant, so:
>datasub$const <- 1
>and then you can use:
>random = ~ Longitude + Latitude | const
>The post you are referring to is outdated. At that time, the rma.mv()
>function did not yet have spatial correlation structures. Now you can just
>use the 'struct' argument to specify the spatial correlation structure and
>the optimization is done for you.
>With respect to your second question: To me, the choice (whether to include
>location as a fixed or a random effect) comes down to whether I am actually
>interested in differences between the specific locations that make up the
>spatial configuration of your data points (in which case I would use a fixed
>effect) or I just want to account for possible dependency due to the spatial
>configuration (in which case I would use a random effect).
>>-----Original Message-----
>>From: R-sig-meta-analysis [mailto:r-sig-meta-analysis-bounces using r-
>>On Behalf Of Grace Pold
>>Sent: Thursday, 20 August, 2020 0:41
>>To: r-sig-meta-analysis using r-project.org <r-sig-meta-analysis using r-project.org>
>>Subject: [R-meta] metafor - specifying spatial random effects
>>I have a dataset of effect sizes taken at different places in the northern
>>hemisphere, sometimes in close proximity, and sometimes in distant
>>I have two questions. The first is specifically related to metafor and
>>specification, and the second is more generally related to spatial random
>>effects (which I don’t think I will get answered, but thought I would throw
>>it in anyway).
>>First, I couldn’t find any examples of how to specify the model to include
>>spatial random effects outside of the function help text. So I was hoping
>>someone could tell me if the following specification for a geographic
>>distance model is correct:
>>rma.mv(yi=yi, V=vi, mods=~moderator1, random = ~ Longitude+ Latitude|
>>moderator1,data=datub,method="REML", dist="gcd", struct="SPEXP")
>>when there is a moderator like habitat type in my analysis. And:
>>rma.mv(yi=yi, V=vi, random = ~ Longitude+Latitude|StudyID,
>>data=datasub,method="REML", dist="gcd", struct="SPEXP")
>>when I do not include moderators (StudyID is just the unique datapoint ID
>>and so each StudyID only has one effect size value associated with it). I
>>chose gcd as the distance because the curvature of the earth matters in my
>>data, and have no rationale for choosing SPEXP for structure.
>>The help text says “Let d denote the distance between two points that share
>>the same level of the outer variable (if all true effects are allowed to be
>>spatially correlated, simply set outer to a constant)”, so intuitively I
>>wanted to write the model as
>>rma.mv(yi=yi, V=vi, random = ~ Longitude+Latitude|1,
>>data=datasub,method="REML", dist="gcd", struct="SPEXP")
>>(ie with a “1” as the “outer” variable rather than a unique datapoint ID)
>>because there is no “distance between two points sharing the same level” of
>>StudyID because those are unique. However, it gives me a “Error in
>>eval(predvars, data, env) : object 'Latitude' not found” error unless I
>>include one of the named variables.
>>I also wanted to check that the “parameter optimization” mentioned in the
>>blog post here [https://stat.ethz.ch/pipermail/r-sig-meta-analysis/2017-
>>November/000371.html] on a previous approach to including spatial
>>matrices is accounted for in the most recent version of metafor. Or are
>>there additional steps I would need to complete?
>>Second, if you wanted to know whether to include geographic location as a
>>categorical (ex. New York vs. Beijing) versus geographic distance random
>>effect versus not at all, would you suggest extracting the residuals and
>>checking to see which model has done the best job of removing spatial
>>correlation, if any exists, using Moran’s I?
>>Thank you so much for your time and input,
>>Grace Pold
>>Postdoctoral researcher
>>Cal Poly NRES

More information about the R-sig-meta-analysis mailing list