-
Notifications
You must be signed in to change notification settings - Fork 0
/
geog364_lab_5_project.html
681 lines (585 loc) · 22.8 KB
/
geog364_lab_5_project.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="generator" content="pandoc" />
<meta http-equiv="X-UA-Compatible" content="IE=EDGE" />
<meta name="author" content="cap6019" />
<meta name="date" content="2021-10-12" />
<title>Lab5</title>
<script src="site_libs/header-attrs-2.11/header-attrs.js"></script>
<script src="site_libs/jquery-3.6.0/jquery-3.6.0.min.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link href="site_libs/bootstrap-3.3.5/css/flatly.min.css" rel="stylesheet" />
<script src="site_libs/bootstrap-3.3.5/js/bootstrap.min.js"></script>
<script src="site_libs/bootstrap-3.3.5/shim/html5shiv.min.js"></script>
<script src="site_libs/bootstrap-3.3.5/shim/respond.min.js"></script>
<style>h1 {font-size: 34px;}
h1.title {font-size: 38px;}
h2 {font-size: 30px;}
h3 {font-size: 24px;}
h4 {font-size: 18px;}
h5 {font-size: 16px;}
h6 {font-size: 12px;}
code {color: inherit; background-color: rgba(0, 0, 0, 0.04);}
pre:not([class]) { background-color: white }</style>
<script src="site_libs/navigation-1.1/tabsets.js"></script>
<link href="site_libs/highlightjs-9.12.0/textmate.css" rel="stylesheet" />
<script src="site_libs/highlightjs-9.12.0/highlight.js"></script>
<style type="text/css">
code{white-space: pre-wrap;}
span.smallcaps{font-variant: small-caps;}
span.underline{text-decoration: underline;}
div.column{display: inline-block; vertical-align: top; width: 50%;}
div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}
ul.task-list{list-style: none;}
.display.math{display: block; text-align: center; margin: 0.5rem auto;}
</style>
<style type="text/css">code{white-space: pre;}</style>
<script type="text/javascript">
if (window.hljs) {
hljs.configure({languages: []});
hljs.initHighlightingOnLoad();
if (document.readyState && document.readyState === "complete") {
window.setTimeout(function() { hljs.initHighlighting(); }, 0);
}
}
</script>
<link rel="stylesheet" href="styles.css" type="text/css" />
<style type = "text/css">
.main-container {
max-width: 940px;
margin-left: auto;
margin-right: auto;
}
img {
max-width:100%;
}
.tabbed-pane {
padding-top: 12px;
}
.html-widget {
margin-bottom: 20px;
}
button.code-folding-btn:focus {
outline: none;
}
summary {
display: list-item;
}
pre code {
padding: 0;
}
</style>
<style type="text/css">
.dropdown-submenu {
position: relative;
}
.dropdown-submenu>.dropdown-menu {
top: 0;
left: 100%;
margin-top: -6px;
margin-left: -1px;
border-radius: 0 6px 6px 6px;
}
.dropdown-submenu:hover>.dropdown-menu {
display: block;
}
.dropdown-submenu>a:after {
display: block;
content: " ";
float: right;
width: 0;
height: 0;
border-color: transparent;
border-style: solid;
border-width: 5px 0 5px 5px;
border-left-color: #cccccc;
margin-top: 5px;
margin-right: -10px;
}
.dropdown-submenu:hover>a:after {
border-left-color: #adb5bd;
}
.dropdown-submenu.pull-left {
float: none;
}
.dropdown-submenu.pull-left>.dropdown-menu {
left: -100%;
margin-left: 10px;
border-radius: 6px 0 6px 6px;
}
</style>
<script type="text/javascript">
// manage active state of menu based on current page
$(document).ready(function () {
// active menu anchor
href = window.location.pathname
href = href.substr(href.lastIndexOf('/') + 1)
if (href === "")
href = "index.html";
var menuAnchor = $('a[href="' + href + '"]');
// mark it active
menuAnchor.tab('show');
// if it's got a parent navbar menu mark it active as well
menuAnchor.closest('li.dropdown').addClass('active');
// Navbar adjustments
var navHeight = $(".navbar").first().height() + 15;
var style = document.createElement('style');
var pt = "padding-top: " + navHeight + "px; ";
var mt = "margin-top: -" + navHeight + "px; ";
var css = "";
// offset scroll position for anchor links (for fixed navbar)
for (var i = 1; i <= 6; i++) {
css += ".section h" + i + "{ " + pt + mt + "}\n";
}
style.innerHTML = "body {" + pt + "padding-bottom: 40px; }\n" + css;
document.head.appendChild(style);
});
</script>
<!-- tabsets -->
<style type="text/css">
.tabset-dropdown > .nav-tabs {
display: inline-table;
max-height: 500px;
min-height: 44px;
overflow-y: auto;
border: 1px solid #ddd;
border-radius: 4px;
}
.tabset-dropdown > .nav-tabs > li.active:before {
content: "";
font-family: 'Glyphicons Halflings';
display: inline-block;
padding: 10px;
border-right: 1px solid #ddd;
}
.tabset-dropdown > .nav-tabs.nav-tabs-open > li.active:before {
content: "";
border: none;
}
.tabset-dropdown > .nav-tabs.nav-tabs-open:before {
content: "";
font-family: 'Glyphicons Halflings';
display: inline-block;
padding: 10px;
border-right: 1px solid #ddd;
}
.tabset-dropdown > .nav-tabs > li.active {
display: block;
}
.tabset-dropdown > .nav-tabs > li > a,
.tabset-dropdown > .nav-tabs > li > a:focus,
.tabset-dropdown > .nav-tabs > li > a:hover {
border: none;
display: inline-block;
border-radius: 4px;
background-color: transparent;
}
.tabset-dropdown > .nav-tabs.nav-tabs-open > li {
display: block;
float: none;
}
.tabset-dropdown > .nav-tabs > li {
display: none;
}
</style>
<!-- code folding -->
</head>
<body>
<div class="container-fluid main-container">
<div class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="index.html">GEOG-364</a>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li>
<a href="index.html">Home</a>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
Tutorials
<span class="caret"></span>
</a>
<ul class="dropdown-menu" role="menu">
<li>
<a href="pg_Tut1_about.html">1. About R, R-Studio & R-Studio Cloud</a>
</li>
<li>
<a href="pg_Tut2_startup.html">2. Getting started</a>
</li>
<li>
<a href="pg_Tut3_basics.html">3. Console Basics</a>
</li>
<li>
<a href="pg_Tut4_markdown.html">4. Markdown</a>
</li>
<li>
<a href="pg_Tut5_checklist.html">5. Lab Template</a>
</li>
<li>
<a href="pg_Tut6_input_output.html">6. Reading in/saving data</a>
</li>
<li>
<a href="pg_Tut7_wrangle.html">7. Data wrangling</a>
</li>
<li>
<a href="pg_Tut8_summarystat.html">8. Exploratory Data Analysis</a>
</li>
<li>
<a href="pg_Tut9_dist_stats.html">9. Distributions & Inferential Stats</a>
</li>
<li>
<a href="pg_Tut10_plot.html">10. Plotting non-spatial data</a>
</li>
<li>
<a href="pg_Tut11_spatial101.html">11. Spatial data analysis</a>
</li>
<li>
<a href="pg_Tut12_pointpattern.html">12. Point Pattern analysis</a>
</li>
<li>
<a href="pg_Tut13_coding.html">13. Coding</a>
</li>
</ul>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
Labs
<span class="caret"></span>
</a>
<ul class="dropdown-menu" role="menu">
<li>
<a href="pg_364Lab1_Basics_2021.html">Lab 1: R-Basics</a>
</li>
<li>
<a href="pg_364Lab2_Summary_2021.html">Lab 2: Playing with data</a>
</li>
<li>
<a href="pg_364Lab3_Spatial_2021.html">Lab 3: Spatial</a>
</li>
<li>
<a href="pg_364Lab4_Manip_2021.html">Lab 4: Spatial Intermediate</a>
</li>
<li>
<a href="pg_364Lab5_tobler_2021.html">Lab 5: Join Counts</a>
</li>
<li>
<a href="pg_364Lab6_moran_2021.html">Lab 6: Census Moran</a>
</li>
<li>
<a href="pg_364Lab7_Regression_2021.html">Lab 7: LISA and Regression</a>
</li>
<li>
<a href="pg_364Lab8_PointPattern_2021.html">Lab 8: Point Pattern</a>
</li>
</ul>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
PROJECT
<span class="caret"></span>
</a>
<ul class="dropdown-menu" role="menu">
<li>
<a href="364Data_TutorialDownload.html">Downloading Secondary datasets</a>
</li>
<li>
<a href="364Data_TutorialWranglePoint.html">Dealing with Point Data</a>
</li>
<li>
<a href="364Data_TutorialWranglePolygon.html">Dealing with Polygon Data</a>
</li>
</ul>
</li>
</ul>
<ul class="nav navbar-nav navbar-right">
</ul>
</div><!--/.nav-collapse -->
</div><!--/.container -->
</div><!--/.navbar -->
<div id="header">
<h1 class="title toc-ignore">Lab5</h1>
<h4 class="author">cap6019</h4>
<h4 class="date">10/12/2021</h4>
</div>
<p>#Something New - Creating our own function</p>
<pre class="r"><code>fahrenheit_to_celsius <- function(temp_F) {
temp_C <- (temp_F - 32) * 5 / 9
return(temp_C)
}</code></pre>
<pre class="r"><code>celsius_to_kelvin <- function(temp_C) {
temp_K <- temp_C + 273.15
return(temp_K)
}
# freezing point of water in Kelvin
celsius_to_kelvin(0)</code></pre>
<pre><code>## [1] 273.15</code></pre>
<pre class="r"><code>fahrenheit_to_kelvin <- function(temp_F) {
temp_C <- fahrenheit_to_celsius(temp_F)
temp_K <- celsius_to_kelvin(temp_C)
return(temp_K)
}
# freezing point of water in Kelvin
fahrenheit_to_kelvin(32.0)</code></pre>
<pre><code>## [1] 273.15</code></pre>
<pre class="r"><code># we don't use min or max as they are standard R fucntion names
selectAny <- function(size, mini, maxi) {
f <- c() # create an empty vector
for(i in 1:size) { # repeat size times
f <- rbind(v, sample(mini:maxi, size = 1)) # add a random value to the vector
} # end loop
f # output the vector
} </code></pre>
<pre class="r"><code>standard.error <- function(x) {
v <- var(x)
n <- length(x)
sqrt(v/n)
}</code></pre>
<ul>
<li>An if statement</li>
</ul>
<pre class="r"><code>x <- -20
if(x > 0){
print("Non-negative number")
} else {
print("Negative number")
}</code></pre>
<pre><code>## [1] "Negative number"</code></pre>
<pre class="r"><code>x <- 10000
if (x < 0) {
print("Negative number")
} else if (x > 0) {
print("Positive number")
} else
print("Zero")</code></pre>
<pre><code>## [1] "Positive number"</code></pre>
<div id="join-counts" class="section level1">
<h1>Join Counts</h1>
<p>LLENA ESTO Y PONLO BONITO SE ESPECIFICA</p>
<p>Briefly explain what join counts are and why it is only appropriate to use use them for categorical or binary data (yes/no ; TRUE/FALSE). Feel free to use pictures/examples etc to help you explain it.</p>
</div>
<div id="join-counts-coding" class="section level1">
<h1>Join Counts coding</h1>
<pre class="r"><code>row.1 <- rep(1,6)
row.2 <- c(0,1,1,1,1,1)
row.3 <- c(rep(0,5),1)
row.4 <- rep(0,6)
row.5 <- c(0,0,0,1,0,0)
row.6 <- rep(0,6)
ToyA_matrix <- matrix(c(row.1, row.2, row.3, row.4, row.5, row.6),
nrow=6,ncol=6, byrow=TRUE)
ToyA_matrix</code></pre>
<pre><code>## [,1] [,2] [,3] [,4] [,5] [,6]
## [1,] 1 1 1 1 1 1
## [2,] 0 1 1 1 1 1
## [3,] 0 0 0 0 0 1
## [4,] 0 0 0 0 0 0
## [5,] 0 0 0 1 0 0
## [6,] 0 0 0 0 0 0</code></pre>
<pre class="r"><code>ToyA_raster <- raster(ToyA_matrix)
plot(ToyA_raster)
text(coordinates(ToyA_raster), labels=ToyA_raster[], cex=1.5)</code></pre>
<p><img src="geog364_lab_5_project_files/figure-html/unnamed-chunk-9-1.png" /><!-- --></p>
<ul>
<li>rep() and c() commands do Explain in your lab answers what the rep() and c() commands do. Feel free to use code examples!</li>
</ul>
<pre class="r"><code>row.1 <- rep(1,6)
row.2 <- c(1,0,1,0,1,0)
row.3 <- c(rep(0,5),1)
row.4 <- rep(0,6)
row.5 <- c(0,1,0,1,1,1)
row.6 <- rep(0,6)
ToyB_matrix <- matrix(c(row.1, row.2, row.3, row.4, row.5, row.6),
nrow=6,ncol=6, byrow=TRUE)
ToyB_matrix</code></pre>
<pre><code>## [,1] [,2] [,3] [,4] [,5] [,6]
## [1,] 1 1 1 1 1 1
## [2,] 1 0 1 0 1 0
## [3,] 0 0 0 0 0 1
## [4,] 0 0 0 0 0 0
## [5,] 0 1 0 1 1 1
## [6,] 0 0 0 0 0 0</code></pre>
<pre class="r"><code>ToyB_raster <- raster(ToyB_matrix)
plot(ToyB_raster)
text(coordinates(ToyB_raster), labels=ToyB_raster[], cex=1.5)</code></pre>
<p><img src="geog364_lab_5_project_files/figure-html/unnamed-chunk-11-1.png" /><!-- --></p>
<pre class="r"><code># Step 1 - turn to polygon
ToyA_polygon <- rasterToPolygons(ToyA_raster, dissolve=FALSE)
ToyA_spdep <- SpatialPolygons(ToyA_polygon@polygons)
# Step 2 - Make list of neighbors
ToyA_nb.rook <- poly2nb(ToyA_spdep, queen = FALSE)
# Step 3 - Create weights matrix
ToyA_weights.rook <- nb2listw(ToyA_nb.rook, style='B')
# Step 4 - plot the neighbors
plot(ToyA_spdep, border='blue')
plot(ToyA_nb.rook, coordinates(ToyA_spdep), col='red', lwd=2, add=TRUE)</code></pre>
<p><img src="geog364_lab_5_project_files/figure-html/unnamed-chunk-12-1.png" /><!-- --></p>
<div id="spatial-weights-matrix" class="section level2">
<h2>Spatial weights matrix</h2>
<p>Explain what a spatial-weights-matrix is, how adjacency can been used to create one (e.g. what are queens/rooks) or how distance might be used to create one (lecture 8A, Lecture 7B). **</p>
<p>LLENA</p>
<pre class="r"><code># Step 1 - turn to polygon
ToyB_polygon <- rasterToPolygons(ToyB_raster, dissolve=FALSE)
ToyB_spdep <- SpatialPolygons(ToyB_polygon@polygons)
# Step 2 - Make list of neighbors
ToyB_nb.queen <- poly2nb(ToyB_spdep, queen = TRUE)
# Step 3 - Create weights matrix
ToyB_weights.queen <- nb2listw(ToyB_nb.queen, style='B')
# Step 4 - plot the neighbors
plot(ToyB_spdep, border='blue')
plot(ToyB_nb.queen, coordinates(ToyB_spdep), col='red', lwd=2, add=TRUE)</code></pre>
<p><img src="geog364_lab_5_project_files/figure-html/unnamed-chunk-13-1.png" /><!-- --></p>
<p>Explain why your Queens adjacecy plot for the Toy_B data looks different to my Rooks adjacecy plot for the Toy_A data.</p>
<p>llena</p>
<p>HLG - THIS WAS THE OLD FUNCTION, THIS IS THE ONE I WAS TALKING ABOUT IN MY CANVAS MESSAGE. I COPY/PASTED THIS FROM THE NEW VERSION OF MY INSTRUCTIONS</p>
<pre class="r"><code>toyIRP <- function(matrix_input, silent=FALSE){
# find how big out input matrix is
nrows <- nrow(matrix_input)
ncols <- nrow(matrix_input)
numberones <- 13
# make a list of all the ones and zeros
alltheones <- rep(1,numberones)
allthezeros <- rep(0, ((nrows*ncols) - numberones))
# randomise
randombinary <- sample(c(alltheones,allthezeros),size=(nrows*ncols),replace=FALSE)
#---------------------------------------------------------------------------
# Turn into a matrix and create the weights etc.
#---------------------------------------------------------------------------
IRP_matrix <- matrix(randombinary, nrow=nrows,ncol=ncols, byrow=TRUE)
IRP_raster <- raster(IRP_matrix)
IRP_polygon <- rasterToPolygons(IRP_raster, dissolve=FALSE)
IRP_spdep <- SpatialPolygons(IRP_polygon@polygons)
IRP_nb.rook <- poly2nb(IRP_spdep, queen = FALSE)
IRP_weights.rook <- nb2listw(IRP_nb.rook, style='B')
IRB_jointest <- joincount.test(fx = as.factor(IRP_polygon$layer), listw = IRP_weights.rook)
ww_gg_joincount <- IRB_jointest[[1]]$estimate[1]+ IRB_jointest[[2]]$estimate[1]
# If you want to see the output (e.g. silent=FALSE) then plot
if(silent == FALSE){
plot(IRP_raster,
main = list(paste("CSR:Number of same color (WW or GG) boundaries = ",ww_gg_joincount),cex=.9))
text(coordinates(IRP_raster), labels=IRP_raster[], cex=1.5)
}
return(ww_gg_joincount)
}</code></pre>
<p>THIS WAS OUT OF DATE AND NEEDED TO BE UPDATED FROM THE NEW VERSION OF THE INSTRUCTIONS</p>
<pre class="r"><code>output <- toyIRP(ToyA_matrix, silent=FALSE)</code></pre>
<p><img src="geog364_lab_5_project_files/figure-html/unnamed-chunk-15-1.png" /><!-- --></p>
<p>On average, if an IRP really did cause the pattern in the matrix, how many white-white joins would you expect to see? Why does the number change each time you run it?</p>
<p>LLENA</p>
<pre class="r"><code># Run once
alloutput <- toyIRP(ToyA_matrix, silent=TRUE)
# Repeat 200 times and add in the answer
for(n in 1:1000){
newIRP <- toyIRP(ToyA_matrix, silent=TRUE)
alloutput <- c(alloutput, newIRP)
}
#make a histogram of all the white-white joins
hist(alloutput, br=20, main="The number of same color joins for 1001 variations of an IRP")</code></pre>
<p><img src="geog364_lab_5_project_files/figure-html/unnamed-chunk-16-1.png" /><!-- --></p>
<p>Given this output, what is your new expectation of the number of white-white joins if an IRP caused the process?</p>
<p>llena</p>
<p>Using this equation, if you have a 6x6 grid, how many same colour joins would you theoretically expect (hint, it would be the total number of joins minus E_BW)</p>
<p>llena</p>
<pre class="r"><code># run the command
ToyA_jointest <- joincount.test(fx = as.factor(ToyA_polygon$layer),
listw = ToyA_weights.rook,
alternative = "greater")
numberboundaries <- ToyA_jointest[[1]]$estimate[1]+ ToyA_jointest[[2]]$estimate[1]
# and plot
plot(ToyA_raster, main = paste("TOYA: Number of same color boundaries =",numberboundaries))
text(coordinates(ToyA_raster), labels=ToyA_raster[], cex=1.5)</code></pre>
<p><img src="geog364_lab_5_project_files/figure-html/unnamed-chunk-17-1.png" /><!-- --></p>
<pre class="r"><code># run the command
# run the command
ToyB_jointest <- joincount.test(fx = as.factor(ToyB_polygon$layer),
listw = ToyB_weights.queen,
alternative = "greater")
numberboundaries <- ToyB_jointest[[1]]$estimate[1]+ ToyB_jointest[[2]]$estimate[1]
# and plot
plot(ToyB_raster, main = paste("TOYB: Number of same color boundaries =",numberboundaries))
text(coordinates(ToyB_raster), labels=ToyB_raster[], cex=1.5)</code></pre>
<p><img src="geog364_lab_5_project_files/figure-html/unnamed-chunk-18-1.png" /><!-- --></p>
<p>Comparing against the histogram, is the number of white-white boundaries unusually high/low?? Does this suggest your data is unusually clustered/uniform compared to one created by an IRP?</p>
<p>LLENAAA</p>
<pre class="r"><code>ToyA_jointest <- joincount.test(fx = as.factor(ToyA_polygon$layer),
listw = ToyA_weights.rook,
sampling = "nonfree",
alternative = "two.sided") </code></pre>
<p>In the joincount.test command, there is an argument, sampling = “nonfree”. Using the textbook pdf to help, explain the difference between free and non-free sampling when making our IRP pattern. LLENA</p>
<pre class="r"><code># White-to-white Join counts
ToyA_jointest[[1]]</code></pre>
<pre><code>##
## Join count test under nonfree sampling
##
## data: as.factor(ToyA_polygon$layer)
## weights: ToyA_weights.rook
##
## Std. deviate for 0 = 4.1544, p-value = 3.262e-05
## alternative hypothesis: two.sided
## sample estimates:
## Same colour statistic Expectation Variance
## 33.000000 24.095238 4.594478</code></pre>
<p>info to look attt In the output, the test said the p-value was 3.262e-05 e.g. 0.00003262. This means that we would expect only ~0.003% of cases from an IRP-generated pattern to have 33 or more white-white joins (1 in 3000). It’s incredibly unusual to see this is the IRP was true.</p>
<p>In the joincount.test command, there is an argument, sampling = “nonfree”. Using the textbook pdf to help, explain the difference between free and non-free sampling when making our IRP pattern.</p>
<p>LLENA ESTOOOOOO</p>
<p>Interpretation</p>
<p>We can see that there are many more white-white joins joins than you might expect. In fact, looking at the low p-value, we can see that it is very unusual to see so many same-color joins (), so in this case, most people can can safely reject the null hypothesis.</p>
<p>So finally we can formally conclude:</p>
<p>The p-value for our test of white-white joins was 3.262e-05, so only 0.003262% of cases caused by an IRP-generated pattern (non-free sampling) would have seen 33 or more white-white joins.</p>
<p>I am willing to accept this level of uncertainty in the result. I have enough evidence to reject the null hypothesis and suggest that Toy_A is not caused by an IRP.</p>
<p>Use the steps above to run a joincount test for your Toy B hypothesis test (e.g. you are testing if it is unusually clustered) and interpret the output.</p>
<p>LLENA</p>
<pre class="r"><code>ToyB_jointest <- joincount.test(fx = as.factor(ToyB_polygon$layer),
listw = ToyB_weights.queen,
sampling = "nonfree",
alternative = "two.sided") </code></pre>
<pre class="r"><code>ToyB_jointest[[1]]</code></pre>
<pre><code>##
## Join count test under nonfree sampling
##
## data: as.factor(ToyB_polygon$layer)
## weights: ToyB_weights.queen
##
## Std. deviate for 0 = 1.1676, p-value = 0.243
## alternative hypothesis: two.sided
## sample estimates:
## Same colour statistic Expectation Variance
## 45.00000 40.33333 15.97386</code></pre>
<p>REAL LIFE EXAMPLE Step 17: The paper did not provide a map of how the territories looked - if you had to choose one of the maps below, which is most likely? Why?</p>
<p>llenaa</p>
<p>Step 18: At a significance value of 0.01, do these results indicate that the frogs preferred hunting prey in specific patches of their core areas? Or is there no evidence to reject the notion that they randomly hunted wherever they hopped?</p>
<p>llenaa</p>
</div>
</div>
</div>
<script>
// add bootstrap table styles to pandoc tables
function bootstrapStylePandocTables() {
$('tr.odd').parent('tbody').parent('table').addClass('table table-condensed');
}
$(document).ready(function () {
bootstrapStylePandocTables();
});
</script>
<!-- tabsets -->
<script>
$(document).ready(function () {
window.buildTabsets("TOC");
});
$(document).ready(function () {
$('.tabset-dropdown > .nav-tabs > li').click(function () {
$(this).parent().toggleClass('nav-tabs-open');
});
});
</script>
<!-- code folding -->
</body>
</html>