<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=utf-8"><meta name=Generator content="Microsoft Word 15 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:"Lucida Console";
        panose-1:2 11 6 9 4 5 4 2 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
code
        {mso-style-priority:99;
        font-family:"Courier New";}
pre
        {mso-style-priority:99;
        mso-style-link:"HTML Preformatted Char";
        margin:0in;
        margin-bottom:.0001pt;
        font-size:10.0pt;
        font-family:"Courier New";}
span.HTMLPreformattedChar
        {mso-style-name:"HTML Preformatted Char";
        mso-style-priority:99;
        mso-style-link:"HTML Preformatted";
        font-family:"Courier New";}
span.gd15mcfcktb
        {mso-style-name:gd15mcfcktb;}
span.gd15mcfcotb
        {mso-style-name:gd15mcfcotb;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style></head><body lang=EN-US><div class=WordSection1><p class=MsoNormal>Hello,</p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>I have a dataset of effect sizes taken at different places in the northern hemisphere, sometimes in close proximity, and sometimes in distant locations.</p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>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). </p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>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:</p><p class=MsoNormal><o:p> </o:p></p><pre style='background:white;word-break:break-all'><span class=gd15mcfcktb><span style='font-family:"Lucida Console";color:blue'>rma.mv(yi=yi, V=vi, mods=~moderator1, random = ~ Longitude+ Latitude| moderator1,data=datub,method="REML", dist="gcd", struct="SPEXP")</span></span><span style='font-family:"Lucida Console";color:black'><o:p></o:p></span></pre><div><pre style='background:white;word-break:break-all'><span class=gd15mcfcktb><span style='color:blue'><o:p> </o:p></span></span></pre></div><p class=MsoNormal>when there is a moderator like habitat type in my analysis. And:</p><p class=MsoNormal><o:p> </o:p></p><pre style='background:white;word-break:break-all'><span class=gd15mcfcktb><span style='font-family:"Lucida Console";color:blue'>rma.mv(yi=yi, V=vi, random = ~ Longitude+Latitude|StudyID, data=datasub,method="REML", dist="gcd", struct="SPEXP")</span></span><span style='font-family:"Lucida Console";color:black'><o:p></o:p></span></pre><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>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.</p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>The help text says “<span style='font-size:10.0pt;font-family:"Arial",sans-serif;color:black;background:white'>Let <i>d</i> denote the distance between two points that share the same level of the </span><code><span style='font-size:10.0pt;color:black;background:white'>outer</span></code><span style='font-size:10.0pt;font-family:"Arial",sans-serif;color:black;background:white'> variable (if all true effects are allowed to be spatially correlated, simply set </span><code><span style='font-size:10.0pt;color:black;background:white'>outer</span></code><span style='font-size:10.0pt;font-family:"Arial",sans-serif;color:black;background:white'> to a constant)</span>”, so intuitively I wanted to write the model as </p><p class=MsoNormal><o:p> </o:p></p><pre style='background:white;word-break:break-all'><span class=gd15mcfcktb><span style='font-family:"Lucida Console";color:blue'>rma.mv(yi=yi, V=vi, random = ~ Longitude+Latitude|1, data=datasub,method="REML", dist="gcd", struct="SPEXP")</span></span><span style='font-family:"Lucida Console";color:black'><o:p></o:p></span></pre><p class=MsoNormal><o:p> </o:p></p><div><pre style='background:white;word-break:break-all'><span style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:black'>(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 “</span><span class=gd15mcfcotb><span style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#C5060B'>Error in eval(predvars, data, env) : object 'Latitude' not found” </span></span><span class=gd15mcfcotb><span style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:black'>error unless I include one of the named variables.</span></span><span style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:black'><o:p></o:p></span></pre></div><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>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?<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>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?<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Thank you so much for your time and input,</p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Grace Pold</p><p class=MsoNormal>Postdoctoral researcher</p><p class=MsoNormal>Cal Poly NRES</p></div></body></html>