Title: | Metrics of Difference for Comparing Pairs of Maps or Pairs of Variables |
---|---|
Description: | Metrics of difference for comparing pairs of variables or pairs of maps representing real or categorical variables at original and multiple resolutions. |
Authors: | Robert Gilmore Pontius Jr. <[email protected]>, Ali Santacruz <[email protected]> |
Maintainer: | Ali Santacruz <[email protected]> |
License: | GPL (>= 2) |
Version: | 0.0-8 |
Built: | 2025-02-02 03:40:32 UTC |
Source: | https://github.com/amsantac/differ |
Metrics of difference for comparing pairs of variables or pairs of maps representing real or categorical variables at original and multiple resolutions.
Package: | diffeR |
Type: | Package |
Version: | 0.0-8 |
Date: | 2023-08-21 |
License: | GPL (>= 2) |
LazyLoad: | yes |
BugReports: | https://github.com/amsantac/diffeR/issues |
Robert Gilmore Pontius Jr. <[email protected]>, Ali Santacruz <[email protected]>
Maintainer: Ali Santacruz <[email protected]>
If comparison and reference (raster) maps are provided, this function creates the Category Components plot from the comparison between the comparison map (or map at time t) and the reference map (or map at time t+1). If a square contingency table (matrix) is provided instead of raster maps, then this function creates the Category Components plot from the comparison between the comparison variable (or variable at time t) and the reference variable (or variable at time t+1).
categoryComponentsPlot(comp = NULL, ref = NULL, ctmatrix = NULL, units = NULL, population = NULL, fontSize = NULL, breaks = waiver(), labels = waiver(), limits = NULL)
categoryComponentsPlot(comp = NULL, ref = NULL, ctmatrix = NULL, units = NULL, population = NULL, fontSize = NULL, breaks = waiver(), labels = waiver(), limits = NULL)
comp |
object of class SpatRaster corresponding to a comparison map (or map at time t). See Details below |
ref |
object of class SpatRaster corresponding to a reference map (or map at time t+1). See Details below |
ctmatrix |
matrix representing a square contingency table between a comparison variable or variable at time t (rows) and a reference variable or variable at time t+1 (columns). See Details below |
units |
optional; character string indicating units of |
population |
optional; an n x 2 matrix provided to correct the sample count to population count in the square contingency table. See Details below |
fontSize |
text size (in pts) |
breaks |
One of:
|
labels |
One of:
|
limits |
A numeric vector of length two providing limits of the scale.
Use |
Users may enter as input either a square contingency table (ctmatrix
) or a comparison and a reference raster maps (comp
and ref
, respectively).
The first column of population
must contain integer identifiers of each category, corresponding to the categories in the comparison and reference variables. The second column corresponds to the population totals for each category.
a stacked barplot showing for each category the quantity, exchange and shift components of difference between the comparison map/variable (or map/variable at time t) and the reference map/variable (or map/variable at time t+1)
Pontius Jr., R.G., Millones, M. 2011. Death to Kappa: birth of quantity disagreement and allocation disagreement for accuracy assessment. International Journal of Remote Sensing 32 (15), 4407-4429.
comp <- rast(system.file("external/comparison.rst", package = "diffeR")) ref <- rast(system.file("external/reference.rst", package = "diffeR")) categoryComponentsPlot(comp, ref) ctmat <- crosstabm(comp, ref) categoryComponentsPlot(ctmatrix = ctmat, units = "pixels")
comp <- rast(system.file("external/comparison.rst", package = "diffeR")) ref <- rast(system.file("external/reference.rst", package = "diffeR")) categoryComponentsPlot(comp, ref) ctmat <- crosstabm(comp, ref) categoryComponentsPlot(ctmatrix = ctmat, units = "pixels")
If comparison and reference (raster) maps are provided, this function creates the Category Sources plot from the comparison between the comparison map (or map at time t) and the reference map (or map at time t+1). If a square contingency table (matrix) is provided instead of raster maps, then this function creates the Category Sources plot from the comparison between the comparison variable (or variable at time t) and the reference variable (or variable at time t+1).
categorySourcesPlot(comp = NULL, ref = NULL, ctmatrix = NULL, analysis = "error", units = NULL, population = NULL, fontSize = NULL, breaks = waiver(), labels = waiver(), limits = NULL)
categorySourcesPlot(comp = NULL, ref = NULL, ctmatrix = NULL, analysis = "error", units = NULL, population = NULL, fontSize = NULL, breaks = waiver(), labels = waiver(), limits = NULL)
comp |
object of class SpatRaster corresponding to a comparison map (or map at time t). See Details below |
ref |
object of class SpatRaster corresponding to a reference map (or map at time t+1). See Details below |
ctmatrix |
matrix representing a square contingency table between a comparison variable or variable at time t (rows) and a reference variable or variable at time t+1 (columns). See Details below |
analysis |
character string indicating type of analysis, either "error" (default) or "change" |
units |
optional; character string indicating units of |
population |
optional; an n x 2 matrix provided to correct the sample count to population count in the square contingency table. See Details below |
fontSize |
text size (in pts) |
breaks |
One of:
|
labels |
One of:
|
limits |
A numeric vector of length two providing limits of the scale.
Use |
Users may enter as input either a square contingency table (ctmatrix
) or a comparison and a reference raster maps (comp
and ref
, respectively).
The first column of population
must contain integer identifiers of each category, corresponding to the categories in the comparison and reference variables. The second column corresponds to the population totals for each category.
a stacked barplot showing for each category the agreement and the omission and comission components of difference between the comparison map/variable (or map/variable at time t) and the reference map/variable (or map/variable at time t+1)
Pontius Jr., R.G., Millones, M. 2011. Death to Kappa: birth of quantity disagreement and allocation disagreement for accuracy assessment. International Journal of Remote Sensing 32 (15), 4407-4429.
comp <- rast(system.file("external/comparison.rst", package = "diffeR")) ref <- rast(system.file("external/reference.rst", package = "diffeR")) categorySourcesPlot(comp, ref) ctmat <- crosstabm(comp, ref) categorySourcesPlot(ctmatrix = ctmat, units = "Pixels")
comp <- rast(system.file("external/comparison.rst", package = "diffeR")) ref <- rast(system.file("external/reference.rst", package = "diffeR")) categorySourcesPlot(comp, ref) ctmat <- crosstabm(comp, ref) categorySourcesPlot(ctmatrix = ctmat, units = "Pixels")
provide a method to create a composite matrix from the crosstabulation of a comparison map (or map at time t) and a reference map (or map at time t+1), both aggregated at a given factor
composite(comp, ref, factor)
composite(comp, ref, factor)
comp |
object of class SpatRaster corresponding to a comparison map (or map at time t) |
ref |
object of class SpatRaster corresponding to a reference map (or map at time t+1) |
factor |
integer. Aggregation factor expressed as number of cells in each direction (horizontally and vertically). Or two integers (horizontal and vertical aggregation factor). See |
the pixel definition in a composite matrix interpretes class membership as the proportion of a pixel that belongs to a class. The pixel contains information about only the quantity of each category (Kuzera and Pontius 2008).
a matrix showing the contingency table derived from the crosstabulation of a comparison map (or map at time t) and a reference map (or map at time t+1), both aggregated at a given factor. Output values are given as proportion (0 to 1)
Kuzera, K., Pontius Jr., R.G. 2008. Importance of matrix construction for multiple-resolution categorical map comparison. GIScience & Remote Sensing 45 (3), 249-274.
comp <- rast(system.file("external/comparison.rst", package = "diffeR")) ref <- rast(system.file("external/reference.rst", package = "diffeR")) composite(comp, ref, factor = 2)
comp <- rast(system.file("external/comparison.rst", package = "diffeR")) ref <- rast(system.file("external/reference.rst", package = "diffeR")) composite(comp, ref, factor = 2)
create a contingency table, also called cross-tabulated matrix, between a comparison raster map (rows), or map at time t, and a reference raster map (columns), or map at time t+1
crosstabm(comp, ref, percent = FALSE, population = NULL)
crosstabm(comp, ref, percent = FALSE, population = NULL)
comp |
object of class SpatRaster corresponding to the comparison map, or map at time t |
ref |
object of class SpatRaster corresponding to the reference map, or map at time t+1 |
percent |
logical. If TRUE, output values are given as percentage. If FALSE, output values are given in pixel counts |
population |
an n x 2 matrix provided to correct the sample count to population count in the square contingency table. See Details below |
For correcting the sample count to population count in the square contingency table, assuming a stratified random sampling, an n (number of categories) by 2 matrix can be provided in the population
argument. The first column of population
must contains integer identifiers of each category, corresponding to the categories in the comparison map (or map at time t) and reference map (or map at time t+1). The second column corresponds to the population totals for each map category
a matrix showing the cross-tabulation between the comparison map (or map at time t) and the reference map (or map at time t+1)
comp <- rast(system.file("external/comparison.rst", package = "diffeR")) ref <- rast(system.file("external/reference.rst", package = "diffeR")) crosstabm(comp, ref) # Population-adjusted square contingency table (population <- matrix(c(1, 2, 3, 2000, 4000, 6000), ncol = 2)) crosstabm(comp, ref, population = population) # Population-adjusted square contingency table, output as percentage crosstabm(comp, ref, percent = TRUE, population = population)
comp <- rast(system.file("external/comparison.rst", package = "diffeR")) ref <- rast(system.file("external/reference.rst", package = "diffeR")) crosstabm(comp, ref) # Population-adjusted square contingency table (population <- matrix(c(1, 2, 3, 2000, 4000, 6000), ncol = 2)) crosstabm(comp, ref, population = population) # Population-adjusted square contingency table, output as percentage crosstabm(comp, ref, percent = TRUE, population = population)
calculates quantity, exchange and shift components of difference, as well as the overall difference, between a comparison raster map (or map at time t), and a reference raster map (or map at time t+1), both consecutively aggregated at multiple resolutions.
Quantity difference is defined as the amount of difference between the reference map and a comparison map that is due to the less than maximum match in the proportions of the categories. Exchange consists of a transition from category i to category j in some pixels and a transition from category j to category i in an identical number of other pixels. Shift refers to the difference remaining after subtracting quantity difference and exchange from the overall difference.
differenceMR(comp, ref, eval = "multiple", percent = TRUE, fact = 2, population = NULL)
differenceMR(comp, ref, eval = "multiple", percent = TRUE, fact = 2, population = NULL)
comp |
object of class SpatRaster corresponding to the comparison map, or map at time t |
ref |
object of class SpatRaster corresponding to the reference map, or map at time t+1 |
eval |
default "original", return difference metrics between the input raster maps at the original resolution; if "multiple", return difference metrics at multiple resolutions aggregated according to a geometric sequence |
percent |
logical. If TRUE, output value is given as percentage. If FALSE, output value is given as proportion (0 to 1) |
fact |
positive integer. Aggregation factor expressed as number of cells in each direction (horizontally and vertically). Or two integers (horizontal and vertical aggregation factor). See |
population |
an n x 2 matrix provided to correct the sample count to population count in the square contingency table. See Details below |
For correcting the sample count to population count in the square contingency table, assuming a stratified random sampling, an n (number of categories) by 2 matrix can be provided in the population
argument. The first column of population
must contains integer identifiers of each category, corresponding to the categories in the comparison map (or map at time t) and reference map (or map at time t+1). The second column corresponds to the population totals for each map category
data.frame containing quantity, exchange and shift components of difference, as well as the overall difference, between the comparison map and the reference map at multiple resolutions
Pontius Jr., R.G., Millones, M. 2011. Death to Kappa: birth of quantity disagreement and allocation disagreement for accuracy assessment. International Journal of Remote Sensing 32 (15), 4407-4429.
Pontius Jr., R.G., Santacruz, A. 2014. Quantity, exchange and shift components of difference in a square contingency table. International Journal of Remote Sensing 35 (21), 7543-7554.
## Not run: comp <- rast(system.file("external/comparison.rst", package = "diffeR")) ref <- rast(system.file("external/reference.rst", package = "diffeR")) differenceMR(comp, ref, eval = "original") differenceMR(comp, ref, eval = "multiple", fact = 2) ## End(Not run)
## Not run: comp <- rast(system.file("external/comparison.rst", package = "diffeR")) ref <- rast(system.file("external/reference.rst", package = "diffeR")) differenceMR(comp, ref, eval = "original") differenceMR(comp, ref, eval = "multiple", fact = 2) ## End(Not run)
calculates quantity, exchange and shift components of difference, as well as the overall difference, at the category level from a contingency table derived from the crosstabulation between a comparison variable (or variable at time t), and a reference variable (or variable at time t+1).
Quantity difference is defined as the amount of difference between the reference variable and a comparison variable that is due to the less than maximum match in the proportions of the categories. Exchange consists of a transition from category i to category j in some observations and a transition from category j to category i in an identical number of other observations. Shift refers to the difference remaining after subtracting quantity difference and exchange from the overall difference.
diffTablej(ctmatrix, digits = 0, analysis = "error")
diffTablej(ctmatrix, digits = 0, analysis = "error")
ctmatrix |
matrix representing a square contingency table between a comparison variable (rows) and a reference variable (columns) |
digits |
integer indicating the number of decimal places to be used |
analysis |
character string either "error" (default) or "change". The output table shows category-level omission error, agreement and comission error in the "error" analysis, and category-level gain, persistence and loss in the "change" analysis |
data.frame containing difference metrics at the category level between a comparison variable (rows) and a reference variable (columns). Output values are given in the same units as ctmatrix
Pontius Jr., R.G., Millones, M. 2011. Death to Kappa: birth of quantity disagreement and allocation disagreement for accuracy assessment. International Journal of Remote Sensing 32 (15), 4407-4429.
Pontius Jr., R.G., Santacruz, A. 2014. Quantity, exchange and shift components of difference in a square contingency table. International Journal of Remote Sensing 35 (21), 7543-7554.
comp <- rast(system.file("external/comparison.rst", package = "diffeR")) ref <- rast(system.file("external/reference.rst", package = "diffeR")) ctmatCompRef <- crosstabm(comp, ref) diffTablej(ctmatCompRef) # Adjustment to population assuming a stratified random sampling (population <- matrix(c(1, 2, 3, 2000, 4000, 6000), ncol = 2)) ctmatCompRef <- crosstabm(comp, ref, percent = TRUE, population = population) diffTablej(ctmatCompRef)
comp <- rast(system.file("external/comparison.rst", package = "diffeR")) ref <- rast(system.file("external/reference.rst", package = "diffeR")) ctmatCompRef <- crosstabm(comp, ref) diffTablej(ctmatCompRef) # Adjustment to population assuming a stratified random sampling (population <- matrix(c(1, 2, 3, 2000, 4000, 6000), ncol = 2)) ctmatCompRef <- crosstabm(comp, ref, percent = TRUE, population = population) diffTablej(ctmatCompRef)
Provides a method to compare the quantity difference and allocation difference between two images of the same real variable at the original resolution or at multiple resolutions.
The output provides a stacked graph and an accompanying numerical table for the Mean Absolute Deviation (MAD) for the difference due to quantity, the difference due to stratum-level allocation, and difference due to pixel-level allocation. The output also indicates which image has a smaller average. A scatterplot indicating the distribution of values in relation to the 1:1 line can be produced with MADscatterplot
MAD(grid1, grid2, strata = NULL, eval = "original")
MAD(grid1, grid2, strata = NULL, eval = "original")
grid1 |
object of class SpatRaster corresponding to the first image |
grid2 |
object of class SpatRaster corresponding to the second image |
strata |
object of class SpatRaster corresponding to the mask or strata image. Zero values are taken as no data (i.e., NA) |
eval |
default "original", return the MAD value for the original resolution; if "multiple", return the MAD values for multiple resolutions following a geometric sequence |
a dataframe containing the multiples of the original resolution, the corresponding aggregated resolution, the difference due to quantity, the difference due to stratum-level allocation, and the difference due to pixel-level allocation.
Pontius Jr., R.G., Thontteh, O., Chen, H. 2008. Components of information for multiple resolution comparison between maps that share a real variable. Environmental and Ecological Statistics 15 (2), 111-142.
old.par <- par(no.readonly = TRUE) grid1 <- rast(system.file("external/GRID1_INT.rst", package = "diffeR")) grid2 <- rast(system.file("external/GRID2_INT.rst", package = "diffeR")) strata <- rast(system.file("external/strata_int.rst", package = "diffeR")) MAD(grid1, grid2, strata, eval = "original") MAD(grid1, grid2, strata, eval = "multiple") ## Not run: veg_obs1 <- rast(system.file("external/veg_obs1.rst", package = "diffeR")) veg_pre1 <- rast(system.file("external/veg_pre1.rst", package = "diffeR")) veg_mask1 <- rast(system.file("external/veg_mask1.rst", package = "diffeR")) MADscatterplot(veg_obs1, veg_pre1, veg_mask1) MAD(veg_obs1, veg_pre1, veg_mask1, eval = "multiple") ## End(Not run) par(old.par)
old.par <- par(no.readonly = TRUE) grid1 <- rast(system.file("external/GRID1_INT.rst", package = "diffeR")) grid2 <- rast(system.file("external/GRID2_INT.rst", package = "diffeR")) strata <- rast(system.file("external/strata_int.rst", package = "diffeR")) MAD(grid1, grid2, strata, eval = "original") MAD(grid1, grid2, strata, eval = "multiple") ## Not run: veg_obs1 <- rast(system.file("external/veg_obs1.rst", package = "diffeR")) veg_pre1 <- rast(system.file("external/veg_pre1.rst", package = "diffeR")) veg_mask1 <- rast(system.file("external/veg_mask1.rst", package = "diffeR")) MADscatterplot(veg_obs1, veg_pre1, veg_mask1) MAD(veg_obs1, veg_pre1, veg_mask1, eval = "multiple") ## End(Not run) par(old.par)
Generates a scatterplot indicating the distribution of values from two images in relation to the 1:1 line
MADscatterplot(grid1, grid2, strata = NULL)
MADscatterplot(grid1, grid2, strata = NULL)
grid1 |
object of class SpatRaster corresponding to the first image |
grid2 |
object of class SpatRaster corresponding to the second image |
strata |
object of class SpatRaster corresponding to the mask or strata image. Zero values are taken as no data (i.e., NA) |
a ggplot object corresponding to the scatterplot
old.par <- par(no.readonly = TRUE) grid1 <- rast(system.file("external/GRID1_INT.rst", package = "diffeR")) grid2 <- rast(system.file("external/GRID2_INT.rst", package = "diffeR")) strata <- rast(system.file("external/strata_int.rst", package = "diffeR")) MADscatterplot(grid1, grid2, strata) veg_obs1 <- rast(system.file("external/veg_obs1.rst", package = "diffeR")) veg_pre1 <- rast(system.file("external/veg_pre1.rst", package = "diffeR")) veg_mask1 <- rast(system.file("external/veg_mask1.rst", package = "diffeR")) MADscatterplot(veg_obs1, veg_pre1, veg_mask1) par(old.par)
old.par <- par(no.readonly = TRUE) grid1 <- rast(system.file("external/GRID1_INT.rst", package = "diffeR")) grid2 <- rast(system.file("external/GRID2_INT.rst", package = "diffeR")) strata <- rast(system.file("external/strata_int.rst", package = "diffeR")) MADscatterplot(grid1, grid2, strata) veg_obs1 <- rast(system.file("external/veg_obs1.rst", package = "diffeR")) veg_pre1 <- rast(system.file("external/veg_pre1.rst", package = "diffeR")) veg_mask1 <- rast(system.file("external/veg_mask1.rst", package = "diffeR")) MADscatterplot(veg_obs1, veg_pre1, veg_mask1) par(old.par)
Calculates membership values for each category in the input raster at a specified aggregated resolution
memberships(grid, fact = 2)
memberships(grid, fact = 2)
grid |
object of class SpatRaster |
fact |
positive integer. Aggregation factor expressed as number of cells in each direction (horizontally and vertically). Or two integers (horizontal and vertical aggregation factor). See |
a RasterBrick object containing membership values for each category in the input raster at a specified aggregated resolution
ref <- rast(system.file("external/reference.rst", package = "diffeR")) plot(ref) memb.ref <- memberships(ref, fact = 2) names(memb.ref) <- c("ref.1", "ref.2", "ref.3") plot(memb.ref)
ref <- rast(system.file("external/reference.rst", package = "diffeR")) plot(ref) memb.ref <- memberships(ref, fact = 2) names(memb.ref) <- c("ref.1", "ref.2", "ref.3") plot(memb.ref)
If comparison and reference (raster) maps are provided, this function creates the Overall Components plot from the comparison between the comparison map (or map at time t) and the reference map (or map at time t+1). If a square contingency table (matrix) is provided instead of raster maps, then this function creates the Overall Components plot from the comparison between the comparison variable (or variable at time t) and the reference variable (or variable at time t+1).
overallComponentsPlot(comp = NULL, ref = NULL, ctmatrix = NULL, units = NULL, population = NULL, graphics_system = 'ggplot2')
overallComponentsPlot(comp = NULL, ref = NULL, ctmatrix = NULL, units = NULL, population = NULL, graphics_system = 'ggplot2')
comp |
object of class SpatRaster corresponding to a comparison map (or map at time t). See Details below |
ref |
object of class SpatRaster corresponding to a reference map (or map at time t+1). See Details below |
ctmatrix |
matrix representing a square contingency table between a comparison variable (rows) and a reference variable (columns).. See Details below |
units |
character string indicating units of |
population |
an n x 2 matrix provided to correct the sample count to population count in the square contingency table. See Details below |
graphics_system |
character string indicating the graphics system for creating the plot, either "ggplot2" (default) or "graphics" (for base R graphics system) |
Users may enter as input either a square contingency table (ctmatrix
) or a comparison and a reference raster maps (comp
and ref
, respectively).
The first column of population
must contain integer identifiers of each category, corresponding to the categories in the comparison and reference variables. The second column corresponds to the population totals for each category.
a stacked barplot showing the quantity, exchange and shift components of difference between the comparison map/variable (or map/variable at time t) and the reference map/variable (or map/variable at time t+1)
Pontius Jr., R.G., Millones, M. 2011. Death to Kappa: birth of quantity disagreement and allocation disagreement for accuracy assessment. International Journal of Remote Sensing 32 (15), 4407-4429.
comp <- rast(system.file("external/comparison.rst", package = "diffeR")) ref <- rast(system.file("external/reference.rst", package = "diffeR")) overallComponentsPlot(comp, ref) ctmat <- crosstabm(comp, ref) overallComponentsPlot(ctmatrix = ctmat, units = "pixels")
comp <- rast(system.file("external/comparison.rst", package = "diffeR")) ref <- rast(system.file("external/reference.rst", package = "diffeR")) overallComponentsPlot(comp, ref) ctmat <- crosstabm(comp, ref) overallComponentsPlot(ctmatrix = ctmat, units = "pixels")
If comparison and reference (raster) maps are provided, this function creates the Overall Sources plot from the comparison between the comparison map (or map at time t) and the reference map (or map at time t+1). If a square contingency table (matrix) is provided instead of raster maps, then this function creates the Overall Sources plot from the comparison between the comparison variable (or variable at time t) and the reference variable (or variable at time t+1).
overallSourcesPlot(comp = NULL, ref = NULL, ctmatrix = NULL, analysis = "error", units = NULL, population = NULL, fontSize = NULL, colorValues = NULL, breaks = waiver(), labels = waiver(), limits = NULL)
overallSourcesPlot(comp = NULL, ref = NULL, ctmatrix = NULL, analysis = "error", units = NULL, population = NULL, fontSize = NULL, colorValues = NULL, breaks = waiver(), labels = waiver(), limits = NULL)
comp |
object of class SpatRaster corresponding to a comparison map (or map at time t). See Details below |
ref |
object of class SpatRaster corresponding to a reference map (or map at time t+1). See Details below |
ctmatrix |
matrix representing a square contingency table between a comparison variable (rows) and a reference variable (columns). See Details below |
analysis |
character string indicating type of analysis, either "error" (default) or "change" |
units |
character string indicating units of |
population |
an n x 2 matrix provided to correct the sample count to population count in the square contingency table. See Details below |
fontSize |
text size (in pts) |
colorValues |
a set of aesthetic values to map data values to. If this is a named vector, then the values will be matched based on the names. If unnamed, values will be matched in order (usually alphabetical) with the limits of the scale. Any data values that don't match will be given |
breaks |
One of:
|
labels |
One of:
|
limits |
A numeric vector of length two providing limits of the scale.
Use |
Users may enter as input either a square contingency table (ctmatrix
) or a comparison and a reference raster maps (comp
and ref
, respectively).
The first column of population
must contain integer identifiers of each category, corresponding to the categories in the comparison and reference variables. The second column corresponds to the population totals for each category.
a stacked barplot showing the omission and comission components of difference between the comparison map/variable (or map/variable at time t) and the reference map/variable (or map/variable at time t+1)
Pontius Jr., R.G., Millones, M. 2011. Death to Kappa: birth of quantity disagreement and allocation disagreement for accuracy assessment. International Journal of Remote Sensing 32 (15), 4407-4429.
comp <- rast(system.file("external/comparison.rst", package = "diffeR")) ref <- rast(system.file("external/reference.rst", package = "diffeR")) overallSourcesPlot(comp, ref) ctmat <- crosstabm(comp, ref) overallSourcesPlot(ctmatrix = ctmat, units = "pixels")
comp <- rast(system.file("external/comparison.rst", package = "diffeR")) ref <- rast(system.file("external/reference.rst", package = "diffeR")) overallSourcesPlot(comp, ref) ctmat <- crosstabm(comp, ref) overallSourcesPlot(ctmatrix = ctmat, units = "pixels")
Converts sample count to population count in the square contingency table, assuming a stratified random sampling
sample2pop(ctmatrix, population)
sample2pop(ctmatrix, population)
ctmatrix |
matrix representing a sampling-derived square contingency table between a comparison variable (rows) and a reference variable (columns) |
population |
an n x 2 matrix provided to correct the sample count to population count in the square contingency table. See Details below |
The first column of population
must contain integer identifiers of each category, corresponding to the categories in the comparison and reference variables. The second column corresponds to the population totals for each category.
matrix representing a population-adjusted square contingency table for the crosstabulation between a comparison variable (rows) and a reference variable (columns). Output values are given in the same units as ctmatrix
comp <- rast(system.file("external/comparison.rst", package = "diffeR")) ref <- rast(system.file("external/reference.rst", package = "diffeR")) # Sample square contingency table (ctmatCompRef <- crosstabm(comp, ref)) # Population-adjusted square contingency table (population <- matrix(c(1, 2, 3, 2000, 4000, 6000), ncol = 2)) sample2pop(ctmatCompRef, population = population) # The square contingency table can also be adjusted directly using the # crosstabm function crosstabm(comp, ref, population = population)
comp <- rast(system.file("external/comparison.rst", package = "diffeR")) ref <- rast(system.file("external/reference.rst", package = "diffeR")) # Sample square contingency table (ctmatCompRef <- crosstabm(comp, ref)) # Population-adjusted square contingency table (population <- matrix(c(1, 2, 3, 2000, 4000, 6000), ncol = 2)) sample2pop(ctmatCompRef, population = population) # The square contingency table can also be adjusted directly using the # crosstabm function crosstabm(comp, ref, population = population)