Skip to contents

CRTsp coerces data frames containing co-ordinates and location attributes into objects of class "CRTsp" or creates a new "CRTsp" object by simulating a set of Cartesian co-ordinates for use as the locations in a simulated trial site

Usage

CRTsp(
  x = NULL,
  design = NULL,
  geoscale = NULL,
  locations = NULL,
  kappa = NULL,
  mu = NULL,
  geometry = "point"
)

Arguments

x

an object of class "CRTsp" or a data frame containing locations in (x,y) coordinates, cluster assignments (factor cluster), and arm assignments (factor arm). Optionally specification of a buffer zone (logical buffer); any other variables required for subsequent analysis.

design

list: an optional list containing the requirements for the power of the trial

geoscale

numeric: standard deviation of random displacement from each settlement cluster center (for new objects)

locations

integer: number of locations in population (for new objects)

kappa

numeric: intensity of Poisson process of settlement cluster centers (for new objects)

mu

numeric: mean number of points per settlement cluster (for new objects)

geometry

with valid values 'point' (the default, corresponding to point locations), 'triangle', 'square' and 'hexagon' corresponding to grids constructed from pixels of regular polygons.

Value

A list of class "CRTsp" containing the following components:

designlist:parameters required for power calculations
geom_fulllist:summary statistics describing the site
geom_corelist:summary statistics describing the core area (when a buffer is specified)
trialdata frame:rows correspond to geolocated points, as follows:
xnumeric vector: x-coordinates of locations
ynumeric vector: y-coordinates of locations
clusterfactor: assignments to cluster of each location
armfactor: assignments to "control" or "intervention" for each location
nearestDiscordnumeric vector: Euclidean distance to nearest discordant location (km)
bufferlogical: indicator of whether the point is within the buffer
...other objects included in the input "CRTsp" object or data frame

Details

If a data frame or "CRTsp" object is input then the output "CRTsp" object is validated, a description of the geography is computed and power calculations are carried out.

If geoscale, locations, kappa and mu are specified then a new trial dataframe is constructed corresponding to a novel simulated human settlement pattern. This is generated using the Thomas algorithm (rThomas) in spatstat.random allowing the user to defined the density of locations and degree of spatial clustering. The resulting trial data frame comprises a set of Cartesian coordinates centred at the origin.

Examples

{# Generate a simulated area with 10,000 locations
example_area = CRTsp(geoscale = 1, locations=10000, kappa=3, mu=40)
summary(example_area)
}
#> Error in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]): namespace 'spatstat.utils' 3.0-4 is already loaded, but >= 3.0.5 is required