Package interspread. September 7, Index 11. InterSpread Plus: summary information

Similar documents
Package leiv. R topics documented: February 20, Version Type Package

Package bivariate. December 10, 2018

Package depth.plot. December 20, 2015

Online Appendix to Mixed Modeling for Irregularly Sampled and Correlated Functional Data: Speech Science Spplications

Package gma. September 19, 2017

Package clustergeneration

Package rnmf. February 20, 2015

Package mpmcorrelogram

Package pearson7. June 22, 2016

Canadian climate: function-on-function regression

The evdbayes Package

Package CorrMixed. R topics documented: August 4, Type Package

Package CEC. R topics documented: August 29, Title Cross-Entropy Clustering Version Date

Package bpp. December 13, 2016

Metric Predicted Variable on Two Groups

Matematisk statistik allmän kurs, MASA01:A, HT-15 Laborationer

Metric Predicted Variable on One Group

Package gumbel. February 15, 2013

Package jmcm. November 25, 2017

Package ForwardSearch

Package diffeq. February 19, 2015

Package PolynomF. May 17, 2018

Package SK. May 16, 2018

Package msir. R topics documented: April 7, Type Package Version Date Title Model-Based Sliced Inverse Regression

Package SpatPCA. R topics documented: February 20, Type Package

Package idmtpreg. February 27, 2018

The Bernstein Mechansim

Package clogitboost. R topics documented: December 21, 2015

Lecture 5 : The Poisson Distribution

Package face. January 19, 2018

Package sklarsomega. May 24, 2018

Watersheds : Spatial watershed aggregation and spatial drainage network analysis

Package DiscreteLaplace

Problems from Chapter 3 of Shumway and Stoffer s Book

Package msbp. December 13, 2018

Measurement, Scaling, and Dimensional Analysis Summer 2017 METRIC MDS IN R

The sbgcop Package. March 9, 2007

k-means clustering mark = which(md == min(md)) nearest[i] = ifelse(mark <= 5, "blue", "orange")}

ensemblebma: An R Package for Probabilistic Forecasting using Ensembles and Bayesian Model Averaging

SUPPLEMENTARY MATERIAL TECHNICAL APPENDIX Article: Comparison of control charts for monitoring clinical performance using binary data

Package MTA. R topics documented: May 14, Title Multiscalar Territorial Analysis Version 0.1.2

Package ZIM. R topics documented: August 29, Type Package. Title Statistical Models for Count Time Series with Excess Zeros. Version 1.

Package hierdiversity

ensemblebma: An R Package for Probabilistic Forecasting using Ensembles and Bayesian Model Averaging

First steps of multivariate data analysis

The crossdes Package

Metric Predicted Variable With One Nominal Predictor Variable

Modern Regression HW #6 Solutions

Package hds. December 31, 2016

Package ensemblepp. R topics documented: September 20, Title Ensemble Postprocessing Data Sets. Version

Package Watersheds. R topics documented: February 9, Type Package

Package RootsExtremaInflections

Gov 2000: 7. What is Regression?

Package EDR. September 14, 2016

Package gwqs. R topics documented: May 7, Type Package. Title Generalized Weighted Quantile Sum Regression. Version 1.1.0

Package FDRSeg. September 20, 2017

Package sbgcop. May 29, 2018

Introduction to the North Carolina SIDS data set

Package cartogram. June 21, 2018

Package NonpModelCheck

The reldist Package. April 5, 2006

Package Select. May 11, 2018

Package r2glmm. August 5, 2017

A Handbook of Statistical Analyses Using R 3rd Edition. Torsten Hothorn and Brian S. Everitt

Package plw. R topics documented: May 7, Type Package

Using Relative Distribution Software

Package locfdr. July 15, Index 5

Explore the data. Anja Bråthen Kristoffersen Biomedical Research Group

Package alphaoutlier

(Re)introduction to Statistics Dan Lizotte

Package ProbForecastGOP

Introduction to Statistics and R

Package ExtremeBounds

Package Rarity. December 23, 2016

Package unbalhaar. February 20, 2015

Package STMedianPolish

Package misctools. November 25, 2016

Prediction problems 3: Validation and Model Checking

Algebra vocabulary CARD SETS Frame Clip Art by Pixels & Ice Cream

Package SightabilityModel

Quartiles, Deciles, and Percentiles

Package ChIPtest. July 20, 2016

Key for Unit I Exam: Out-of-Class Portion

A Handbook of Statistical Analyses Using R 2nd Edition. Brian S. Everitt and Torsten Hothorn

Package bayeslm. R topics documented: June 18, Type Package

Package Perc. R topics documented: December 5, Type Package

Package LPTime. March 3, 2015

Package generalhoslem

Package IDmining. October 25, 2017

Package timelines. August 29, 2016

STAT2201 Assignment 3 Semester 1, 2017 Due 13/4/2017

Galaxy Dataset Analysis

Topic 2 Part 1 [195 marks]

The locfdr Package. August 19, hivdata... 1 lfdrsim... 2 locfdr Index 5

Package mmm. R topics documented: February 20, Type Package

Spatial is special. The earth is not flat (coordinate reference systems) Size: lots and lots of it, multivariate, time series

Package TSPred. April 5, 2017

Package jmuoutlier. February 17, 2017

Package clr. December 3, 2018

Package dhsic. R topics documented: July 27, 2017

Transcription:

Package interspread September 7, 2012 Version 0.2-2 Date 2012-09-07 Title Functions for analysing InterSpread Plus simulation output Author Mark Stevenson <M.Stevenson@massey.ac.nz> A package for analysing InterSpread Plus simulation output. Maintainer Mark Stevenson <M.Stevenson@massey.ac.nz> Depends R (>= 2.7.0), sp, sm, spatstat, RColorBrewer, spatialkernel License GPL (>= 2) URL http://epicentre.massey.ac.nz R topics documented: is.about........................................... 1 is.act............................................. 2 is.boundary......................................... 2 is.describemovt....................................... 3 is.epicurve.......................................... 4 is.farms........................................... 5 is.move........................................... 7 is.sim............................................ 8 Index 11 is.about InterSpread Plus: summary information A collection of functions for analysing InterSpread Plus simulation output. is.about() 1

2 is.boundary Details The most recent version of the interspread package can be obtained from: http://epicentre. massey.ac.nz/ Author(s) Mark Stevenson, EpiCentre, IVABS, Massey University, Palmerston North New Zealand. is.act Details from an outbreak of foot-and-mouth disease This data set provides infection dates and location details of farms infected during an outbreak of foot-and-mouth disease. data(is.act) Format A data frame with the following variables: itno iteration number. time the estimated day of infection (relative to the date of infection of the index case). id farm identifier. type farm type. xcoord easting coordinate of the farm centroid. ycoord northing coordinate of the farm centroid. data(is.act) is.boundary Boundary of study area Polygon defining the boundary of a hypothetical study area. data(is.boundary)

is.describemovt 3 Format A two column data frame with the following variables: xcoord easting coordinates of the boundary vertices. ycoord northing coordinates of the boundary vertices. data(is.boundary) ## Not run: library(spatstat) ## Create an observation window. is.boundary is two column data frame with ## 173 rows. Reverse the row order and drop the last set of coordinates to ## coerce the data into a suitable format for spatstat: is.ow <- owin(poly = as.matrix(is.boundary[172:1,]), unitname = c("metre", "metres")) ## Method for SpatialPolygonsDataFrame object: ## is.ow <- as(as(is.boundary, "SpatialPolygonsDataFrame"), "owin") plot(is.ow, axes = TRUE) ## End(Not run) is.describemovt InterSpread Plus: describe parameterised movement patterns Returns descriptive statistics of the predicted number of events per iteration. is.describemovt(movements, ngrid = 100, min = 5, transform = 1000) Arguments movements ngrid min transform an eight column matrix listing the following data (in order): iteration number, time, outcome, easting of the location acting as the source of movement, northing of the location acting as the source of the movement, easting of the destination location, northing of the destination location, movement type. integer, specifying the number of grids to use for the smoothing function. integer, the minimum number of eligible distances required to compute a density estimate. scalar, distance values will be divided by this value (useful for converting metres into kilometres.)

4 is.epicurve ## Load data: data(is.move) move <- is.move$ex1 ## Select movements where type equals "MovementType10": id <- move[,8] == "MovementType10" move <- move[id, 1:8] rval <- is.describemovt(move, ngrid = 100, min = 5, transform = 1000) dim <- dim(rval$estimate) plot(rval$eval.points[,1], rval$estimate[,1], type = "l", xlim = c(0, 100), ylim = c(0, 0.1), xlab = "Distance (km)", ylab = "Density", col = "gray") for(i in 2:dim[2]){ lines(rval$eval.points[,i], rval$estimate[,i], col = "gray") } is.epicurve InterSpread Plus: epidemic curve Computes the cumulative number of locations predicted to experience an event as a function of time, suitable for plotting as an epidemic curve. is.epicurve(dat, daylim, xlim, ylim, n.iterations = 5, stats = FALSE, type = "cumulative", quant = c(0.25, 0.75)) Arguments dat daylim xlim ylim n.iterations stats a four column matrix listing the following data (in order): iteration number, time, easting of the location experiencing the event, northing of the location experiencing the event. vector of length two, defining the start and the end of the simulation period. vector of length two, defining map limits in the easting direction. vector of length two, defining map limits in the northing direction. integer defining the number of Interspread Plus iterations to be included. logical, if TRUE descriptive statistics of the cumulative number of infected premises at each epidemic time period are calculated. If FALSE the cumulative number of infected premises is reported for each iteration. type string indicating the type of analysis to performed. cumulative returns the cumulative number of events, frequency returns the count of events for each time period. quant vector of length two, defines the quantiles to be computed. Only used if stats = TRUE

is.farms 5 ## Load data: data(is.act) data(is.sim) ## Details of observed epidemic: act <- is.act[, c(1,2,5,6)] act[,3:4] <- act[,3:4]/1000 tmp <- as.data.frame(table(act$time)) tmp[,1] <- as.numeric(as.character(tmp[,1])) names(tmp) <- c("day", "n") ## Set boundaries of study area: xlim <- c(173,273) ylim <- c(340,440) ## Details of premises predicted to become infected by InterSpread Plus: inf <- is.sim$inf[, c(1,2,5,6)] inf[,3:4] <- inf[,3:4]/1000 ## Compare actual epidemic curve with that predicted by InterSpread Plus: fmd.pred <- is.epicurve(inf, daylim = c(0,60), xlim = xlim, ylim = ylim, n.iterations = 9, stats = FALSE, type = "cumulative", quant = c(0.25,0.75)) ## Plot results: plot(c(0,60), c(0,60), type = "n", xlab = "Simulation day", ylab = "Cumulative number of infected premises") for(i in 1:9){ lines(fmd.pred[,1], fmd.pred[,1+i], type = "s", lwd = 1) } lines(tmp$day, cumsum(tmp$n), type = "s", lwd = 2, col = "red") ## Compare actual epidemic curve with median, 25th percentile and 75th ## percentile, predicted by InterSpread Plus: fmd.pred <- is.epicurve(inf, daylim = c(0,60), xlim = xlim, ylim = ylim, n.iterations = 9, stats = TRUE, type = "cumulative") ## Plot results: plot(c(0, 60), c(0, 60), type = "n", xlab = "Simulation day", ylab = "Cumulative number of infected premises") lines(fmd.pred[,1], fmd.pred[,4], type = "s", lwd = 2) lines(fmd.pred[,1], fmd.pred[,5], type = "s", lwd = 1) lines(fmd.pred[,1], fmd.pred[,6], type = "s", lwd = 1) lines(tmp$day, cumsum(tmp$n), type = "s", lwd = 2, col = "red") legend(0, 50, legend = c("actual cumulative number IPs", "Predicted cumulative IPs (median of 9 iterations)", "25th and 75th prediction quartiles"), col = c("red", "black", "black"), lwd = c(3, 3, 1), bty = "n") is.farms Farm details

6 is.farms Format This data set provides, for a set of farms within a defined study area, details of location and the number of animals present. data(is.farms) A data frame with the following variables: id the primary farm identifier. farmid the secondary farm identifier. type farm type. cattle the number of cattle present. other the number of other (foot-and-mouth disease susceptible) species present. pigs the number of pigs present. xcoord easting coordinate of the farm centroid. ycoord northing coordinate of the farm centroid. data(is.farms) ## Not run: library(spatstat); library(rcolorbrewer); library(spatialkernel) data(is.boundary) data(is.farms) ## Create an observation window: is.ow <- owin(poly = as.matrix(is.boundary[172:1,]), unitname = c("metre", "metres")) ## Method for SpatialPolygonsDataFrame object: ## is.ow <- as(as(is.boundary, "SpatialPolygonsDataFrame"), "owin") # Create ppp object: farms.ppp <- ppp(x = is.farms$xcoord, y = is.farms$ycoord, window = is.ow) xylims <- rbind(range(is.farms$xcoord), range(is.farms$ycoord)) ## Method for SpatialPolygonsDataFrame object: ## xylims <- attr(is.boundary, "bbox") ratio <- (xylims[2,2] - xylims[2,1]) / (xylims[1,2] - xylims[1,1]) x.points <- seq(from = 180000, to = 250000, by = 10000); x.lab <- x.points/1000 y.points <- seq(from = 360000, to = 420000, by = 10000); y.lab <- y.points/1000 ## Plot farm locations: par(pin = c(1 * 5, ratio * 5), omi = c(0.5,0,0,0)) plot(x = xylims[1,], y = xylims[2,], xaxt = "n", yaxt = "n", type = "n", xlab = "", ylab = "", axes = TRUE)

is.move 7 points(x = is.farms$xcoord, y = is.farms$ycoord, col = "gray") plot(is.ow, add = TRUE) axis(side = 1, at = x.points, labels = x.lab, tick = TRUE, cex.axis = 0.80) axis(side = 2, at = y.points, labels = y.lab, tick = TRUE, cex.axis = 0.80) mtext("easting (km)", side = 1, line = 3, cex = 1.0) mtext("northing (km)", side = 2, line = 3, cex = 1.0) legend(x = "topleft", legend = "Farm locations", pch = 1, col = "gray", bty = "n") ## Set the bandwidth and grid dimensions: sigma <- 1200; dimyx = c(200, 200) ## Kernel smooth: farms.den <- density(farms.ppp, sigma = sigma, dimyx = dimyx) ## The density.ppp function returns an estimate of the intensity of the ## underlying point process, that is the expected number of points per unit ## area (in this case, the number of points per metre). Express results as ## the number of points per square kilometre (1 square metre = 0.000001 ## square kilometres): farms.den$v <- farms.den$v / 0.000001 summary(as.vector(farms.den$v)) ## Maximum farm density is 7 per farms per square kilometre. ## Image plot of farm density: breaks <- seq(from = 0, to = 7, length = 5) col <- brewer.pal(n = 4, name = "Blues") par(pin = c(1 * 5, ratio * 5), omi = c(0.5,0,0,0)) plot(x = xylims[1,], y = xylims[2,], type = "n", xlab = "Easting (m)", ylab = "Northing (m)", xaxt = "n", yaxt = "n") image(x = farms.den$xcol, y = farms.den$yrow, z = t(farms.den$v), zlim = c(0, 7), col = col, breaks = breaks, add = TRUE) plot(is.ow, add = TRUE) axis(side = 1, at = x.points, labels = x.lab, tick = TRUE, cex.axis = 0.80) axis(side = 2, at = y.points, labels = y.lab, tick = TRUE, cex.axis = 0.80) metre(xl = xylims[1,1], yb = xylims[2,1], xr = xylims[1,1] + 2000, yt = xylims[2,1] + 15000, lab = breaks, cols = col, shift = 0, cex = 0.75) ## End(Not run) is.move Movement details from an InterSpread Plus simulation This data set provides details of movement events generated during a typical InterSpread Plus simulation. data(is.move)

8 is.sim Format A list containing the following data frames: ex1 an eight column data frame listing the following (in order): itno iteration number, time time, outcome infection outcome (infected or not infected), src.xcoord easting of the location acting as the source of movement, src.ycoord northing of the location acting as the source of the movement, des.xcoord easting of the destination location, src.ycoord northing of the destination location, type movement type. ex2 an eight column data frame listing the following (in order): itno iteration number, time time, outcome infection outcome (infected or not infected), src.xcoord easting of the location acting as the source of movement, src.ycoord northing of the location acting as the source of the movement, des.xcoord easting of the destination location, src.ycoord northing of the destination location, type movement type. data(is.move) is.sim Details from an InterSpread Plus simulation This data set provides details from a typical InterSpread Plus simulation. data(is.sim) Format A list containing the following data frames: dep a nine column data frame listing the following (in order): itno iteration number, time time, id farm identifier, type depopulation resource, xcoord easting coordinate, xcoord northing coordinate, cattle cattle numbers, other other stock numbers, pigs pig numbers. det a six column data frame listing the following (in order): itno iteration number, time time, id farm identifier, type detection resource, xcoord easting coordinate, ycoord northing coordinate. inf a six column data frame listing the following (in order): itno iteration number, time time, id farm identifier, type infection mechanism, xcoordeasting coordinate, ycoord northing coordinate. vac a nine column data frame listing the following (in order): itno iteration number, time time, id farm identifier, type vaccination resource, xcoord easting coordinate, ycoord northing coordinate, cattle cattle numbers, other other stock numbers, pigs pig numbers.

is.sim 9 data(is.sim) ## Not run: library(spatstat); library(rcolorbrewer); library(spatialkernel) data(is.boundary) data(is.farms) ## Create an observation window: is.ow <- owin(poly = as.matrix(is.boundary[172:1,]), unitname = c("metre", "metres")) ## Method for SpatialPolygonsDataFrame object: ## is.ow <- as(as(is.boundary, "SpatialPolygonsDataFrame"), "owin") # Create ppp objects: farms.ppp <- ppp(x = is.farms$xcoord, y = is.farms$ycoord, window = is.ow) sim.ppp <- ppp(x = is.sim$inf$xcoord, y = is.sim$inf$ycoord, window = is.ow) xylims <- rbind(range(is.farms$xcoord), range(is.farms$ycoord)) ## Method for SpatialPolygonsDataFrame object: ## xylims <- attr(is.boundary, "bbox") ratio <- (xylims[2,2] - xylims[2,1]) / (xylims[1,2] - xylims[1,1]) x.points <- seq(from = 180000, to = 250000, by = 10000); x.lab <- x.points/1000 y.points <- seq(from = 360000, to = 420000, by = 10000); y.lab <- y.points/1000 ## Set the bandwidth and grid dimensions: sigma <- 1200; dimyx = c(200, 200) ## Kernel smooth: farms.den <- density(farms.ppp, sigma = sigma, dimyx = dimyx) sim.den <- density(sim.ppp, sigma = sigma, dimyx = dimyx) ## The density.ppp function returns an estimate of the intensity of the ## underlying point process, that is the expected number of points per unit ## area (in this case, the number of points per metre). Express results as ## the number of points per square kilometre (1 square metre = 0.000001 ## square kilometres): farms.den$v <- farms.den$v / 0.000001 summary(as.vector(farms.den$v)) ## Maximum farm density is 7 per farms per square kilometre. ## Do the same for the simulations. Note the division by 9, because simulation ## results are for 9 iterations: sim.den$v <- sim.den$v / 0.000001 summary(as.vector(sim.den$v) / 9) ## Image plot of farm density with superimposed contour plot to identify ## areas where the density of farms predicted to become infected was ## relatively high: breaks <- seq(from = 0, to = 7, length = 5) col <- brewer.pal(n = 4, name = "Blues")

10 is.sim par(pin = c(1 * 5, ratio * 5), omi = c(0.5,0,0,0)) plot(x = xylims[1,], y = xylims[2,], type = "n", xlab = "Easting (m)", ylab = "Northing (m)", xaxt = "n", yaxt = "n") image(x = farms.den$xcol, y = farms.den$yrow, z = t(farms.den$v), zlim = c(0, 7), col = col, breaks = breaks, add = TRUE) contour(x = sim.den$xcol, y = sim.den$yrow, z = t(sim.den$v / 9), levels = 0.02, col = "red", add = TRUE) plot(is.ow, add = TRUE) axis(side = 1, at = x.points, labels = x.lab, tick = TRUE, cex.axis = 0.80) axis(side = 2, at = y.points, labels = y.lab, tick = TRUE, cex.axis = 0.80) metre(xl = xylims[1,1], yb = xylims[2,1], xr = xylims[1,1] + 2000, yt = xylims[2,1] + 15000, lab = breaks, cols = col, shift = 0, cex = 0.75) ## End(Not run)

Index Topic datasets is.act, 2 is.boundary, 2 is.farms, 5 is.move, 7 is.sim, 8 Topic univar is.about, 1 is.describemovt, 3 is.epicurve, 4 is.about, 1 is.act, 2 is.boundary, 2 is.describemovt, 3 is.epicurve, 4 is.farms, 5 is.move, 7 is.sim, 8 11