Class used by the package prevR
Slots
clusters
data.frame
with observed data (one line per cluster). Columns names are:"id" cluster ID.
"x" longitude.
"y" latitude.
"n" number of valid observations per cluster.
"pos" number of positive cases per cluster.
"prev" observed prevalence (in %) in the cluster (pos/n).
"wn" (optional) sum of weights of observations per cluster.
"wpos" (optional) sum of weights of positive cases per cluster.
"wprev" (optional) weighted observed prevalence (in %) in the cluster (wpos/wn).
"c.type" (optional) cluster type.
boundary
object of class sf::sf, borders of the studied area.
proj
object of class sf::crs, map projection used.
rings
list of results returned by
rings()
. Each entry is composed of 3 elements:N
, minimum number of observations per ring;R
, maximum radius of rings andestimates
, a data frame with the following variables:"id" cluster ID.
"r.pos" number of positive cases inside the ring.
"r.n" number of valid observations inside the ring.
"r.prev" observed prevalence (in \
"r.radius" ring radius (in kilometers if coordinates in decimal degrees, in the unit of the projection otherwise).
"r.clusters" number of clusters located inside the ring.
"r.wpos" (optional) sum of weights of positive cases inside the ring.
"r.wn" (optional) sum of weights of valid observations inside the ring.
"r.wprev" (optional) weighted observed prevalence (in %) inside the ring (r.wpos/r.wn).
Note: the list
rings
is named, the name of each element is NN_value.RR_value, for example N300.RInf.
Objects from the Class
Objects of this class could be created by the function as.prevR()
.
Methods
- as.data.frame
signature(x = "prevR")
converts an object of class prevR into a data frame.- as.SpatialGrid
signature(object = "prevR")
generates a spatial grid.- export
signature(object = "prevR")
exports a prevR object as a shapefile, a dbase file or a text file.- idw
signature(formula = "ANY", locations = "prevR")
calculates a spatial interpolation using an inverse distance weighting.- kde
signature(object = "prevR")
estimates a prevalence surface using kernel density estimators.- krige
signature(formula = "ANY", locations = "prevR")
calculates a spatial interpolation by kriging.- plot
signature(x = "prevR", y = "ANY")
plots data of a prevR object.signature(x = "prevR")
shows a summary of a prevR object.- rings
signature(object = "prevR")
calculates rings of equal number of observations and/or equal radius.- show
signature(object = "prevR")
shows a summary of a prevR object.- summary
signature(object = "prevR")
shows a summary of the variables of a prevR object.- changeproj
signature(object = "prevR")
changes the map projection used.
Examples
showClass("prevR")
#> Class "prevR" [package "prevR"]
#>
#> Slots:
#>
#> Name: clusters boundary proj rings
#> Class: data.frame sf crs list
col <- c(
id = "cluster",
x = "x",
y = "y",
n = "n",
pos = "pos",
c.type = "residence",
wn = "weighted.n",
wpos = "weighted.pos"
)
dhs <- as.prevR(fdhs.clusters, col, fdhs.boundary)
str(dhs)
#> Formal class 'prevR' [package "prevR"] with 4 slots
#> ..@ clusters:'data.frame': 401 obs. of 10 variables:
#> .. ..$ id : int [1:401] 1 10 100 101 102 103 104 105 106 107 ...
#> .. ..$ x : num [1:401] -1.21 -1.79 -2.29 -2.71 -1.96 ...
#> .. ..$ y : num [1:401] 7.29 6.13 5.96 6.04 5.12 ...
#> .. ..$ n : num [1:401] 23 22 22 28 21 21 11 24 23 15 ...
#> .. ..$ pos : num [1:401] 0 0 0 0 3 4 0 1 0 0 ...
#> .. ..$ c.type: Factor w/ 2 levels "Rural","Urban": 1 1 1 1 1 1 1 1 1 1 ...
#> .. ..$ wn : num [1:401] 19.8 19.8 20.2 20.2 20.2 ...
#> .. ..$ wpos : num [1:401] 0 0 0 0 2.88 ...
#> .. ..$ prev : num [1:401] 0 0 0 0 14.3 ...
#> .. ..$ wprev : num [1:401] 0 0 0 0 14.3 ...
#> ..@ boundary:Classes ‘sf’ and 'data.frame': 1 obs. of 1 variable:
#> .. ..$ geometry:sfc_POLYGON of length 1; first list element: List of 1
#> .. .. ..$ : num [1:4056, 1:2] 1.28 1.25 1.23 1.22 1.22 ...
#> .. .. ..- attr(*, "class")= chr [1:3] "XY" "POLYGON" "sfg"
#> .. ..- attr(*, "sf_column")= chr "geometry"
#> .. ..- attr(*, "agr")= Factor w/ 3 levels "constant","aggregate",..:
#> .. .. ..- attr(*, "names")= chr(0)
#> .. ..- attr(*, "valid")= logi TRUE
#> ..@ proj :List of 2
#> .. ..$ input: chr "+proj=longlat +datum=WGS84"
#> .. ..$ wkt : chr "GEOGCRS[\"unknown\",\n DATUM[\"World Geodetic System 1984\",\n ELLIPSOID[\"WGS 84\",6378137,298.25722"| __truncated__
#> .. ..- attr(*, "class")= chr "crs"
#> ..@ rings : list()
print(dhs)
#> Object of class 'prevR'
#> Number of clusters: 401
#> Number of observations: 8000
#> Number of positive cases: 810
#> The dataset is weighted.
#>
#> National prevalence: 10.12%
#> National weighted prevalence: 10.16%
#>
#> Projection used: +proj=longlat +datum=WGS84
#>
#> Coordinate range
#> min max
#> x -5.37750 3.6850
#> y 4.80326 14.1225
#>
#> Boundary coordinate range
#> xmin ymin xmax ymax
#> -5.518916 4.736723 3.851701 15.082593
if (FALSE) { # \dontrun{
dhs <- rings(fdhs, N = c(100, 300, 500))
str(dhs)
print(dhs)
} # }