You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -276,7 +276,7 @@ <h2 class="anchored" data-anchor-id="loading-the-data-into-r">Loading the data i
276
276
<p>Note that later in the script, we will make use of the <code>effectfun()</code> that requires that the raster layer be stored as a double data type. You can tell if your raster is stored as a double by typing <code>typeof(inc.km[])</code>, for example. If it’s not stored as a double, you can force it to a double using the <code>as.double()</code> function (e.g. <code>inc[] <- as.double(inc[])</code>).</p>
277
277
<p>Let’s plot each raster with the Walmart point overlay. We’ll use <code>R</code>’s base plotting environment.</p>
Values of the covariate 'pop.km' were NA or undefined at 3.4% (17 out of 504)
330
333
of the quadrature points</code></pre>
331
334
</div>
332
335
</div>
333
-
<p>The values of interest are the <strong>intercept</strong> (whose value is around <code>-10.1</code>) and the <strong>coefficient</strong><code>pop.km</code> (whose value is around <code>0.63</code>). Using these values, we can construct the mathematical relationship (noting that we are using the logged population raster and not the original population raster values):</p>
336
+
<p>The values of interest are the <strong>intercept</strong> (whose value is around <code>-10.1</code>) and the <strong>coefficient</strong><code>pop.km</code> (whose value is around <code>0.63</code>). Using these values, we can construct the mathematical relationship (noting that we are using the population raster and not the original population raster values):</p>
\]</span> The above equation can be interpreted as follows: if the population density is <code>0</code>, then the Walmart intensity is <spanclass="math inline">\(e^{−10.1}\)</span> which is very close to <code>0</code>. So for every unit increase of the <em>logged</em>population density (i.e. log of one person per square mile), there is an increase in Walmart intensity by a factor of <spanclass="math inline">\(e^{0.63}\)</span>.</p>
\]</span> The above equation can be interpreted as follows: if the population density is <code>0</code>, then the Walmart intensity is <spanclass="math inline">\(e^{−6.3}\)</span> which is very close to <code>0</code>. So for every unit increase of the population density (i.e. one person per square mile), there is an increase in Walmart intensity by a factor of <spanclass="math inline">\(e^{-6.3}\)</span> stores per square kilometer.</p>
337
340
<p>Likewise, we can extract the parameters from the <code>Minc</code> model and construct its equation.</p>
338
341
<divclass="cell">
339
342
<divclass="sourceCode cell-code" id="cb10"><preclass="sourceCode r code-with-copy"><codeclass="sourceCode r"><spanid="cb10-1"><ahref="#cb10-1" aria-hidden="true" tabindex="-1"></a>Minc</span></code><buttontitle="Copy to Clipboard" class="code-copy-button"><iclass="bi"></i></button></pre></div>
@@ -398,13 +401,13 @@ <h2 class="anchored" data-anchor-id="plotting-the-competing-models">Plotting the
398
401
</div>
399
402
</div>
400
403
</div>
401
-
<p>Note the difference in relationships between the two models. In the first plot, we note an increasing relationship between Walmart intensity and population density; this is to be expected since you would not expect to see Walmart stores in underpopulated areas. In the second plot, we note an inverse relationship between Walmart intensity and income—i.e. as an area’s income increases, the Walmart intensity decreases.</p>
404
+
<p>Note the difference in relationships between the two models. In the first plot, we note a slightly increasing relationship between Walmart intensity and population density; this is to be expected since you would not expect to see Walmart stores in underpopulated areas. In the second plot, we note an inverse relationship between Walmart intensity and income—i.e. as an area’s income increases, the Walmart intensity decreases.</p>
402
405
<p>The grey envelopes encompass the 95% confidence interval; i.e. the true estimate (black line) can fall anywhere within this envelope. Note how the envelope broadens near the upper end of the population density values–this suggests wide uncertainty in the estimated model.</p>
403
406
<p>To assess how well the above models explain the relationship between covariate and Walmart intensity, we will turn to hypothesis testing.</p>
<h2class="anchored" data-anchor-id="testing-for-covariate-effect">Testing for covariate effect</h2>
407
-
<p>Now, let’s compare the non-homogeneous covariates to the null model using a technique called the <em>likelihood ratio</em> test. Remember that the null model assumes that the intensity is homogeneous across the entire study area; what we want to know is <em>“does the model with the covariate do a significantly better job in predicting Walmart densities than the null model?”</em></p>
410
+
<p>To formally assess whether the covariate-based model provides a significantly better fit than the null model, we use a <strong>likelihood ratio test statistic (LRT)</strong> which quantifies how much better the alternative model (<code>Mpop</code> or <code>Minc</code>) is at describing the observed pattern than the null model (<code>Mo</code>).</p>
408
411
<divclass="cell">
409
412
<divclass="sourceCode cell-code" id="cb15"><preclass="sourceCode r code-with-copy"><codeclass="sourceCode r"><spanid="cb15-1"><ahref="#cb15-1" aria-hidden="true" tabindex="-1"></a><spanclass="fu">anova</span>(Mo, Mpop, <spanclass="at">test =</span><spanclass="st">"LRT"</span>) <spanclass="co"># Compare null to population model</span></span></code><buttontitle="Copy to Clipboard" class="code-copy-button"><iclass="bi"></i></button></pre></div>
410
413
<divclass="cell-output cell-output-stderr">
@@ -421,9 +424,9 @@ <h2 class="anchored" data-anchor-id="testing-for-covariate-effect">Testing for c
@@ -449,9 +452,10 @@ <h2 class="anchored" data-anchor-id="testing-for-covariate-effect">Testing for c
449
452
2 18 1 1.3388 0.2473</code></pre>
450
453
</div>
451
454
</div>
452
-
<p>What we are seeking is a small p-value (parameter <code>Pr(>Chi)</code> in the output). The smaller the value, the more confident we are in stating that the covariate does a better job in predicting Walmart intensity than the null model. For example, the p-value for the <code>Mpop</code> model (<code>Pr(>Chi) = 1.776e-08</code>) suggests that population density does a better job in predicting Walmart density than the null model <code>Mo</code>.</p>
453
-
<p>The p-value for <code>Minc</code>, on the other hand, is higher with a value of <code>Pr = 0.247</code> indicating that there is a 24.7% chance that we would be wrong in stating that income does a better job in predicting Walmart densities. To many, that probability is too high to reject the null.</p>
454
-
<p>So to summaries: of the two models we tested, it seems that population density does a better job at explaining the distribution of Walmarts (though not perfect) than the null model. Income distribution, on the other hand, does not improve on the null model.</p>
455
+
<p>The p-value is the <strong>probability of observing the magnitude of fit improvement (as quantified by the LRT statistic) if that improvement were due entirely to random chance (as defined by CSR)</strong>.</p>
456
+
<p>A resulting p-value of 0.039 (<code>Pr(>Chi) = 0.039</code>) indicates that if the null model were true (i.e., if Walmart locations were randomly distributed with constant intensity, unrelated to population density), there is only a 3.9% chance of observing an LRT statistic computed using <code>Mpop</code>. This suggests that the population density covariate does a better job in predicting Walmart distributions than CSR.</p>
457
+
<p>The p-value for <code>Minc</code>, on the other hand, is higher with a value of <code>Pr = 0.247</code> indicating that there is a 24.7% chance of observing a pattern that fits the covariate-based model this well. To many, that probability is too high to reject the null.</p>
458
+
<p>So, to summarize, of the two models we tested, it seems that population density does a better job at explaining the distribution of Walmarts (though not perfect) than the null model. Income distribution, on the other hand, does not improve on the null model.</p>
0 commit comments