psim_real {stppSim} | R Documentation |
Stpp from real (sample) origins
Description
Generates spatiotemporal point pattern from origins sampled based on real sample dataset.
Usage
psim_real(n_events, ppt, start_date = NULL, poly = NULL,
netw = NULL, s_threshold = NULL, step_length = 20, n_origin=50,
restriction_feat=NULL, field=NA,
p_ratio=20, interactive = FALSE, s_range = 150,
s_interaction = "medium", tolerance = 0.07,
crsys = NULL)
Arguments
n_events |
number of points
(events) to simulate. Default: |
ppt |
A 3-column matrix or list containing
|
start_date |
the start date of the temporal pattern.
The date should be in the format |
poly |
(An sf or S4 object) a polygon shapefile defining the extent of the landscape |
netw |
(An sf or S4 object)
The network path of the landscape
(e.g. road and/or street). Default: |
s_threshold |
defines the spatial
perception range of a walker at a given
location. Default: |
step_length |
the maximum step taken by a walker from one point to the next. |
n_origin |
number of locations to serve as
origins for walkers. Default: |
restriction_feat |
(An S4 object) optional
shapefile containing features
in which walkers cannot walk through.
Default: |
field |
a number in the range of |
p_ratio |
the smaller of the
two terms of proportional ratios.
For example, a value of |
interactive |
Whether to run the process in
interactive mode. Default is |
s_range |
A value (in metres), not less than 150,
specifying the maximum range of spatial
interaction across the space. For example, for 150m,
the intervals of spatial interactions are created as
|
s_interaction |
(string) indicating the
type of spatial interaction to detect.
Default: |
tolerance |
Pvalue to use for the extraction of
space-time interaction in the sample data. Default
value: |
crsys |
(string) the EPSG code of the projection
system of the |
Details
The spatial and temporal patterns and interactions detected in sample datasets are extrapolated to synthetise larger data size. Details of the spatiotemporal interactions detected in the sample dataset are provided. If the street network of the area is provided, each point is snapped to its nearest street segment.
Value
A list of artificial spatiotemporal point patterns and interaction generated based on a sample (real) data.
References
Davies, T.M. and Hazelton, M.L. (2010), Adaptive kernel estimation of spatial relative risk, Statistics in Medicine, 29(23) 2423-2437. Terrell, G.R. (1990), The maximal smoothing principle in density estimation, Journal of the American Statistical Association, 85, 470-477.
Examples
## Not run:
data(camden_crimes)
#subset 'theft' crime
theft <- camden_crimes[which(camden_crimes$type == "Theft"),]
#specify the proportion of full data to use
sample_size <- 0.3
set.seed(1000)
dat_sample <- theft[sample(1:nrow(theft),
round((sample_size * nrow(theft)), digits=0),
replace=FALSE),1:3]
#plot(dat_sample$x, dat_sample$y) #preview
#load boundary and land use of Camden
#load(file = system.file("extdata", "camden.rda",
#package="stppSim"))
#landuse = camden$landuse # get landuse
landuse <- stppSim:::landuse
#simulate data
simulated_stpp <- psim_real(n_events=2000, ppt=dat_sample,
start_date = NULL, poly = NULL, netw = NULL, s_threshold = NULL,
step_length = 20, n_origin=20,
restriction_feat = NULL, field=NULL,
p_ratio=20, interactive = FALSE, s_range = 150,
s_interaction = "medium", tolerance = 0.07,
crsys = "EPSG:27700")
#If `n_events` is a vector of values,
#retrieve the simulated data for the
#corresponding vector element by using
#`simulated_stpp[[enter-element-index-here]]`, e.g.,
#to retrieve the first dataframe, use
#simulated_stpp[[1]].
#The above example simulates point patterns on
#an unrestricted landscape. If \code{restriction_feat = landuse} and \code{field = "restrVal"},
then the simulation
#is run with the landuse features as restrictions
#on the landscape.
## End(Not run)