sppt_boot: Performs a Spatial Point Pattern Test with resampling of both...

Description Usage Arguments Details Value Examples

View source: R/sppt_boot.R

Description

This function is different from the original sppt() in that it does a (bootstrapped) resampling procedure on both Base and Test data, instead of just on the Test data.

Usage

1
2
3
4
5
6
7
8
9
sppt_boot(
  base_points.sp,
  test_points.sp,
  uoa.sp,
  nsamples = 200,
  percpoints = 85,
  conf_level = 95,
  bootstrap = TRUE
)

Arguments

base_points.sp

the Base data of type SpatialPoints*

test_points.sp

the Test data of type SpatialPoints*

uoa.sp

the units of analysis of type SpatialPolygons*

nsamples

number of samples in simulations, default = 200

percpoints

percentage of points used in simulations if bootstrap = FALSE, default = 85

conf_level

confidence interval, default = 95

bootstrap

logical. should bootstrap sampling be done (i.e. with replacement?) default = TRUE

Details

After a (bootstrapped) resample, for each areal unit the difference between the two percentages is calculated immediately (and this is done nsamples times). If the 95 and Test percentages excludes 0, they are deemed statistically different.

With the default settings of bootstrap = TRUE, it's a real bootstrap procedure: (a) for each sampling loop (nsamples of times) as many points are sampled as present in the data (so argument 'percpoints' is ignored, or more precisely, set to 100 sampled WITH replacement.

If one wants to mimic the behavior of standard sppt() but with the added improvement that the choice of Base and Test data does not affect results, set percpoints to 85 and bootstrap = FALSE.

Value

Returns the uoa.sp spatialobject including sppt outcomes.

Examples

 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
# Plot areas, base points data, and test points data
plot(areas.sp)
text(coordinates(areas.sp), label = areas.sp$ID)
text(coordinates(points1.sp), label = points1.sp$ID, col="blue")
text(coordinates(points2.sp), label = points2.sp$ID, col="red")

set.seed(76772)
myoutput <- sppt_boot(base_points.sp = points1.sp, test_points.sp = points2.sp, uoa.sp = areas.sp)
summary_sppt(myoutput)
myoutput@data

# Vancouver data
set.seed(9866)
myoutput <- sppt_boot(vancouver_points1.sp, vancouver_points2.sp, vancouver_areas.sp)
summary_sppt(myoutput)

# Global-S may not be exactly the same when switching Base for Test
# due to random sampling procedure. Compare by doing the sppt_boot() 20 times:
# some global-s values should be the same
set.seed(85335)
reps.output <- replicate(20, mean(sppt_boot(vancouver_points1.sp,
       vancouver_points2.sp, vancouver_areas.sp)$globalS.robust, na.rm=TRUE))
set.seed(85335)
reps.output2 <- replicate(20, mean(sppt_boot(vancouver_points2.sp,
       vancouver_points1.sp, vancouver_areas.sp)$globalS.robust, na.rm=TRUE))
reps.output
reps.output2
reps.output %in% reps.output2

# Mimic the original sppt procedure but with resampling of both Base and Test
set.seed(9866)
myoutput <- sppt_boot(points1.sp, points2.sp, areas.sp, bootstrap=FALSE)
summary_sppt(myoutput)
myoutput@data

wsteenbeek/sppt documentation built on Oct. 16, 2020, 6:11 p.m.