Skip to contents

Estimates map accuracy and area using stratified estimators for stratified random samples. Sampling strata may differ from the map classes. F1 is estimated directly from the weighted confusion matrix.

Usage

aa_stratified(stratum, reference, map, h = NULL, N_h = NULL, fpc = FALSE)

Arguments

stratum

vector of stratum identifiers

reference

vector of reference class labels

map

vector of map class labels

h

vector of unique stratum identifiers that correspond to N_h

N_h

population size or area for each stratum in h, in matching order. These values determine the stratum weights.

fpc

logical; apply the finite population correction within each stratum when TRUE.

Value

A list of map accuracy and area proportion estimates and associated standard errors:

  • cm: adjusted confusion matrix in counts

  • cmp: adjusted confusion matrix in area proportion (sums to 1)

  • stats: A data frame with one row per class and these columns:

    • class: class label.

    • ua, ua_se: User's accuracy and its stratified ratio standard error.

    • pa, pa_se: Producer's accuracy and its stratified ratio standard error.

    • f1: F1 score, estimated as the combined ratio 2 * TP / (map-class total + reference-class total).

    • f1_se: Selected F1 standard error. Uses f1_se_ratio when available; otherwise falls back to f1_se_propa.

    • f1_se_ratio: F1 standard error from the stratified ratio variance estimator, accounting for within-stratum covariance between numerator and denominator.

    • f1_se_propa: F1 standard error propagated from ua_se and pa_se using aa_f1(), which assumes UA and PA are independent.

    • f1_se_type: Flag declaring whether f1_se was constructed from f1_se_ratio (1), f1_se_propa (2), or is NA (0).

  • macroF1: A named numeric vector:

    • macroF1: Macro-F1 estimate.

    • macroF1_se_ratio: Stratified linearization standard error, including covariance between class-specific F1 estimates.

    • macroF1_se_approx: Approximate standard error that borrows variance from other strata when a stratum has one sample.

    • macroF1_se_propa: Propagated standard error that assumes class-specific F1 estimates are independent.

  • accuracy: Overall accuracy and its standard error

  • area: estimated area proportion and standard errors for each class

Details

Stratified estimation of map accuracy and area

Within each stratum, the sample is treated as a simple random sample. Supply h and N_h to use the known population sizes or areas for disproportionate allocation. If they are omitted, sample counts are used as stratum sizes, corresponding to proportional allocation. The F1 point estimate agrees with the harmonic mean of UA and PA up to numerical precision. f1_se_ratio is calculated directly from the F1 ratio and includes covariance between its numerator and denominator. f1_se_propa is calculated by propagating UA and PA standard errors under an independence assumption. f1_se uses the ratio-based SE when available and falls back to the propagated SE otherwise.

References

Stehman, S. V., 2014. Estimating area and map accuracy for stratified random sampling when the strata are different from the map classes. Int. J. Remote Sens. 35, 4923-4939. https://doi.org/10.1080/01431161.2014.930207

Author

Dirk Pflugmacher

Examples

r <- c("A","A","A","A","A","C","B","A","B","C","A","B","B","B","B","B",
       "A","A","B","B","C","C","C","C","C","D","D","B","B","A","D","D",
        "D","D","D","D","D","C","C","B")
m <- c("A","A","A","A","A","A","A","B","B","B","A","B","B","B","B","B",
       "B","B","B","B","B","B","C","C","C","C","C","C","B","B","D","D",
       "D","D","D","D","D","D","D","D")
s <- c("1","1","1","1","1","1","1","1","1","1","2","2","2","2","2","2",
       "2","2","2","2","3","3","3","3","3","3","3","3","3","3","4","4",
       "4","4","4","4","4","4","4","4")
h <- c("1", "2", "3", "4")
N_h <- c(40000, 30000, 20000, 10000)
aa_stratified(s, r, m, h=h, N_h=N_h)
#> $cm
#>     A    B   C   D
#> A 9.2  1.6 1.6 0.0
#> B 4.8 10.8 3.2 0.0
#> C 0.0  0.8 2.4 1.6
#> D 0.0  0.4 0.8 2.8
#> 
#> $cmp
#>      A    B    C    D
#> A 0.23 0.04 0.04 0.00
#> B 0.12 0.27 0.08 0.00
#> C 0.00 0.02 0.06 0.04
#> D 0.00 0.01 0.02 0.07
#> 
#> $stats
#>   class        ua     ua_se        pa     pa_se        f1     f1_se f1_se_ratio
#> 1     A 0.7419355 0.1645627 0.6571429 0.1477318 0.6969697 0.1282960   0.1282960
#> 2     B 0.5744681 0.1248023 0.7941176 0.1165671 0.6666667 0.1002029   0.1002029
#> 3     C 0.5000000 0.2151657 0.3000000 0.1504438 0.3750000 0.1613113   0.1613113
#> 4     D 0.7000000 0.1527525 0.6363636 0.1623242 0.6666667 0.1287357   0.1287357
#>   f1_se_propa f1_se_type
#> 1  0.11034620          1
#> 2  0.09354009          1
#> 3  0.13219833          1
#> 4  0.11284328          1
#> 
#> $macroF1
#>           macroF1  macroF1_se_ratio macroF1_se_approx  macroF1_se_propa 
#>        0.60132576        0.08069078        0.08069078        0.05653320 
#> 
#> $accuracy
#> [1] 0.63000000 0.08465617
#> 
#> $fpc
#> [1] 1 1 1 1
#> 
#> $area
#>   class proportion proportion_se
#> 1     A       0.35    0.08225975
#> 2     B       0.34    0.07586538
#> 3     C       0.20    0.06429101
#> 4     D       0.11    0.03073181
#> 
#> $adjusted
#> [1] TRUE
#>