specify_clusters {CRTspat}R Documentation

Algorithmically assign locations to clusters in a CRT

Description

specify_clusters algorithmically assigns locations to clusters by grouping them geographically

Usage

specify_clusters(
  trial = trial,
  c = NULL,
  h = NULL,
  algorithm = "NN",
  reuseTSP = FALSE
)

Arguments

trial

A CRT object or data frame containing (x,y) coordinates of households

c

integer: number of clusters in each arm

h

integer: number of locations per cluster

algorithm

algorithm for cluster boundaries, with options:

NN Nearest neighbour: assigns equal numbers of locations to each cluster
kmeans kmeans clustering: aims to partition locations so that each belongs to the cluster with the nearest centroid.
TSP travelling salesman problem heuristic: Assigns locations sequentially along a travelling salesman path.
reuseTSP

logical: indicator of whether a pre-existing path should be used by the TSP algorithm

Details

The reuseTSP parameter is used to allow the path to be reused for creating alternative allocations with different cluster sizes.

Either c or h must be specified. If both are specified the input value of c is ignored.

Value

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

geom_full list: summary statistics describing the site, and cluster assignments.
trial data frame: rows correspond to geolocated points, as follows:
x numeric vector: x-coordinates of locations
y numeric vector: y-coordinates of locations
cluster factor: assignments to cluster of each location
... other objects included in the input "CRTsp" object or data frame

Examples

#Assign clusters of average size h = 40 to a test set of co-ordinates, using the kmeans algorithm
exampletrial <- specify_clusters(trial = readdata('exampleCRT.txt'),
                            h = 40, algorithm = 'kmeans', reuseTSP = FALSE)

[Package CRTspat version 1.2.0 Index]