[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|
Thu Aug 20 13:28:25 CEST 2020
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).
Best,
Wolfgang
>-----Original Message-----
>From: R-sig-meta-analysis [mailto:r-sig-meta-analysis-bounces using r-project.org]
>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
>
>Hello,
>
>I have a dataset of effect sizes taken at different places in the northern
>hemisphere, sometimes in close proximity, and sometimes in distant
>locations.
>
>I have two questions. The first is specifically related to metafor and model
>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 similarity
>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