Determine a samples size for simple random sampling using relative standard error

## Usage

calculate_sampsize(
mraster,
rse = NULL,
start = 0.01,
end = 0.05,
increment = 0.001,
plot = FALSE
)

## Arguments

mraster

spatRaster. Metrics raster. All values must be numeric.

rse

Numeric. Desired relative standard error (coefficient of variation of the mean) threshold to determine sample size.

start

Numeric. First rse value to begin rse sequence. default = 0.01.

end

Numeric. Final rse value to end rse sequence. default = 0.05.

increment

Numeric. Value to increment between start & end. default = 0.001.

plot

Logical. if TRUE output graphical representation of estimated sample size vs. rse.

## Value

A data.frame of sample size and rse by raster variable.

## Note

$$rse = (100 * SE) / mean)$$

Where:

• SE - Standard error of the mean

• s - Standard deviation of the observations

• n - Number of observations

## References

Benedetti, R., Piersimoni, F., & Postiglione, P. (2015). Sampling spatial units for agricultural surveys. pp 202-203. Berlin: Springer.

Other calculate functions: calculate_allocation_existing(), calculate_allocation(), calculate_coobs(), calculate_distance(), calculate_pcomp(), calculate_pop(), calculate_representation()

## Author

Tristan R.H. Goodbody

## Examples


r <- system.file("extdata", "mraster.tif", package = "sgsR")
mr <- terra::rast(r)

calculate_sampsize(
mraster = mr,
rse = 0.01
)
#>   nSamp  rse      var
#> 1  1394 0.01     zq90
#> 2  1341 0.01 pzabove2
#> 3  1859 0.01      zsd

calculate_sampsize(
mraster = mr
)
#>     nSamp   rse      var
#> 1    1394 0.010     zq90
#> 2    1155 0.011     zq90
#> 3     973 0.012     zq90
#> 4     830 0.013     zq90
#> 5     717 0.014     zq90
#> 6     625 0.015     zq90
#> 7     550 0.016     zq90
#> 8     488 0.017     zq90
#> 9     435 0.018     zq90
#> 10    391 0.019     zq90
#> 11    353 0.020     zq90
#> 12    320 0.021     zq90
#> 13    292 0.022     zq90
#> 14    267 0.023     zq90
#> 15    246 0.024     zq90
#> 16    226 0.025     zq90
#> 17    209 0.026     zq90
#> 18    194 0.027     zq90
#> 19    181 0.028     zq90
#> 20    168 0.029     zq90
#> 21    157 0.030     zq90
#> 22    148 0.031     zq90
#> 23    138 0.032     zq90
#> 24    130 0.033     zq90
#> 25    123 0.034     zq90
#> 26    116 0.035     zq90
#> 27    110 0.036     zq90
#> 28    104 0.037     zq90
#> 29     98 0.038     zq90
#> 30     93 0.039     zq90
#> 31     89 0.040     zq90
#> 32     85 0.041     zq90
#> 33     81 0.042     zq90
#> 34     77 0.043     zq90
#> 35     74 0.044     zq90
#> 36     70 0.045     zq90
#> 37     67 0.046     zq90
#> 38     65 0.047     zq90
#> 39     62 0.048     zq90
#> 40     59 0.049     zq90
#> 41     57 0.050     zq90
#> 42   1341 0.010 pzabove2
#> 43   1111 0.011 pzabove2
#> 44    935 0.012 pzabove2
#> 45    798 0.013 pzabove2
#> 46    689 0.014 pzabove2
#> 47    601 0.015 pzabove2
#> 48    529 0.016 pzabove2
#> 49    469 0.017 pzabove2
#> 50    418 0.018 pzabove2
#> 51    376 0.019 pzabove2
#> 52    339 0.020 pzabove2
#> 53    308 0.021 pzabove2
#> 54    281 0.022 pzabove2
#> 55    257 0.023 pzabove2
#> 56    236 0.024 pzabove2
#> 57    218 0.025 pzabove2
#> 58    201 0.026 pzabove2
#> 59    187 0.027 pzabove2
#> 60    174 0.028 pzabove2
#> 61    162 0.029 pzabove2
#> 62    151 0.030 pzabove2
#> 63    142 0.031 pzabove2
#> 64    133 0.032 pzabove2
#> 65    125 0.033 pzabove2
#> 66    118 0.034 pzabove2
#> 67    111 0.035 pzabove2
#> 68    105 0.036 pzabove2
#> 69    100 0.037 pzabove2
#> 70     95 0.038 pzabove2
#> 71     90 0.039 pzabove2
#> 72     85 0.040 pzabove2
#> 73     81 0.041 pzabove2
#> 74     78 0.042 pzabove2
#> 75     74 0.043 pzabove2
#> 76     71 0.044 pzabove2
#> 77     68 0.045 pzabove2
#> 78     65 0.046 pzabove2
#> 79     62 0.047 pzabove2
#> 80     59 0.048 pzabove2
#> 81     57 0.049 pzabove2
#> 82     55 0.050 pzabove2
#> 83   1859 0.010      zsd
#> 84   1542 0.011      zsd
#> 85   1299 0.012      zsd
#> 86   1109 0.013      zsd
#> 87    958 0.014      zsd
#> 88    836 0.015      zsd
#> 89    735 0.016      zsd
#> 90    652 0.017      zsd
#> 91    582 0.018      zsd
#> 92    523 0.019      zsd
#> 93    472 0.020      zsd
#> 94    429 0.021      zsd
#> 95    391 0.022      zsd
#> 96    358 0.023      zsd
#> 97    329 0.024      zsd
#> 98    303 0.025      zsd
#> 99    280 0.026      zsd
#> 100   260 0.027      zsd
#> 101   242 0.028      zsd
#> 102   225 0.029      zsd
#> 103   211 0.030      zsd
#> 104   197 0.031      zsd
#> 105   185 0.032      zsd
#> 106   174 0.033      zsd
#> 107   164 0.034      zsd
#> 108   155 0.035      zsd
#> 109   147 0.036      zsd
#> 110   139 0.037      zsd
#> 111   132 0.038      zsd
#> 112   125 0.039      zsd
#> 113   119 0.040      zsd
#> 114   113 0.041      zsd
#> 115   108 0.042      zsd
#> 116   103 0.043      zsd
#> 117    98 0.044      zsd
#> 118    94 0.045      zsd
#> 119    90 0.046      zsd
#> 120    86 0.047      zsd
#> 121    83 0.048      zsd
#> 122    79 0.049      zsd
#> 123    76 0.050      zsd

calculate_sampsize(
mraster = mr,
rse = 0.025,
start = 0.01,
end = 0.08,
increment = 0.01
)
#> 'rse' not perfectly divisible by 'increment'. Selecting closest sample size (rse = 0.03) based on values.
#> # A tibble: 3 × 3
#> # Groups:   var [3]
#>   nSamp   rse var
#>   <dbl> <dbl> <chr>
#> 1   157  0.03 zq90
#> 2   151  0.03 pzabove2
#> 3   211  0.03 zsd

#--- higher variance leads to need for more samples ---#