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
)

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

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

locations

number of locations in population (for new objects)

kappa

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

mu

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

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)
}
#> ===============================CLUSTER RANDOMISED TRIAL ===========================
#> 
#> Summary of coordinates
#> ----------------------
#>         Min.   : 1st Qu.: Median : Mean   : 3rd Qu.: Max.   :
#>       x -4.85    -2.62    -0.02     0.00     2.52     5.15   
#>       y -4.88    -2.44    -0.02     0.00     2.37     5.12   
#> 
#> Total area (within  0.2 km of a location) :  106 sq.km
#> Total area (convex hull) :  99.7 sq.km
#> 
#> Locations and Clusters
#> ----------------------                                          -                        
#> Coordinate system                      (x, y)                        
#> row 3                                    
#> Locations:                                                      10000                        
#> Available clusters (across both arms)                           Not assigned                        
#> row 6                                    
#> row 7                                    
#> row 8                                    
#> No randomization          -                        
#> row 10                                    
#> row 11                                    
#> row 12                                    
#> row 13                                    
#> row 14                                    
#> row 15                                    
#> row 16                                    
#> No power calculations to report          -                        
#> row 18                                    
#> row 19                                    
#> row 20                                    
#> row 21                                    
#> row 22