# load data
data(nydf)
data(nyw)
# create relevant data
coords <- nydf[, c("longitude", "latitude")]
cases <- floor(nydf$cases)
pop <- nydf$population
w <- nyw
ex <- sum(cases) / sum(pop) * pop
ubpop <- 0.5
ubd <- 0.5
ty <- sum(cases) # total number of cases
# intercentroid distances
d <- gedist(as.matrix(coords), longlat = TRUE)
# upperbound for population in zone
max_pop <- ubpop * sum(pop)
# upperbound for distance between centroids in zone
max_dist <- ubd * max(d)
# create list of neighbors for each region
# (inclusive of region itself)
all_neighbors <- nndist(d, ubd)
# find the dmst max zone
if (FALSE) {
out <- mst.all(all_neighbors, cases, pop, w, ex, ty, max_pop,
type = "maxonly"
)
head(out)
out <- mst.all(all_neighbors, cases, pop, w, ex, ty, max_pop,
type = "pruned"
)
head(out)
}
Run the code above in your browser using DataLab