Sampling

First we’ll load up the package and some data:

library(forestmangr)
data(exfm1)
data(exfm2)
data(exfm3)
data(exfm4)
data(exfm5)

data_acs_pilot <- as.data.frame(exfm3)
data_acs_def <- as.data.frame(exfm4)
data_ace_pilot <- as.data.frame(exfm1)
data_ace_def <- as.data.frame(exfm2)
data_as <- as.data.frame(exfm5)

Simple Random Sampling

The objective of this example is to survey an area of 46.8 ha using the simple random sampling method. The aimed error is 20%. 10 plots of 3000 m² each were measured for a pilot inventory. The data collected is shown below:

data_acs_pilot
#>    TOTAL_AREA PLOT_AREA VWB
#> 1        46.8      3000  41
#> 2        46.8      3000  33
#> 3        46.8      3000  24
#> 4        46.8      3000  31
#> 5        46.8      3000  10
#> 6        46.8      3000  32
#> 7        46.8      3000  62
#> 8        46.8      3000  16
#> 9        46.8      3000  66
#> 10       46.8      3000  25

Now we’ll calculate the inventory variables for a 20% error, considering a finite population with the sprs function. Area values must be inserted in square meters, and total area values must be in hectares:

sprs(data_acs_pilot, "VWB", 3000, 46.8,error = 20, pop = "fin")
#>                                        Variables    Values
#> 1              Total number of sampled plots (n)   10.0000
#> 2                    Number of maximum plots (N)  156.0000
#> 3                      Variance Quoeficient (VC)   53.2670
#> 4                                      t-student    2.2622
#> 5                         recalculated t-student    2.0452
#> 6  Number of samples regarding the admited error   25.0000
#> 7                                  Variance (S2)  328.0000
#> 8                         Standard deviation (s)   18.1108
#> 9                                       Mean (Y)   34.0000
#> 10               Standard error of the mean (Sy)    5.5405
#> 11                                Absolute Error   12.5335
#> 12                            Relative Error (%)   36.8634
#> 13                  Estimated Total Value (Yhat) 5304.0000
#> 14                                   Total Error 1955.2326
#> 15             Inferior Confidence Interval (m3)   21.4665
#> 16             Superior Confidence Interval (m3)   46.5335
#> 17          Inferior Confidence Interval (m3/ha)   71.5549
#> 18          Superior Confidence Interval (m3/ha)  155.1118
#> 19       inferior Total Confidence Interval (m3) 3348.7674
#> 20       Superior Total Confidence Interval (m3) 7259.2326

With these results, we can see that in order to meet the desired error, we’ll need 15 more samples. After a new survey was done, this are the new data:

data_acs_def
#>    TOTAL_AREA PLOT_AREA VWB
#> 1        46.8      3000  41
#> 2        46.8      3000  33
#> 3        46.8      3000  24
#> 4        46.8      3000  31
#> 5        46.8      3000  10
#> 6        46.8      3000  32
#> 7        46.8      3000  62
#> 8        46.8      3000  16
#> 9        46.8      3000  66
#> 10       46.8      3000  25
#> 11       46.8      3000  44
#> 12       46.8      3000   7
#> 13       46.8      3000  57
#> 14       46.8      3000  22
#> 15       46.8      3000  31
#> 16       46.8      3000  40
#> 17       46.8      3000  43
#> 18       46.8      3000  27
#> 19       46.8      3000  17
#> 20       46.8      3000  50
#> 21       46.8      3000  38
#> 22       46.8      3000  20
#> 23       46.8      3000  35
#> 24       46.8      3000  31
#> 25       46.8      3000  26

Now the definitive inventory can be done:

sprs(data_acs_def, "VWB", 3000, 46.8, error = 20, pop = "fin")
#>                                        Variables    Values
#> 1              Total number of sampled plots (n)   25.0000
#> 2                    Number of maximum plots (N)  156.0000
#> 3                      Variance Quoeficient (VC)   45.4600
#> 4                                      t-student    2.0639
#> 5                         recalculated t-student    2.0930
#> 6  Number of samples regarding the admited error   20.0000
#> 7                                  Variance (S2)  226.6933
#> 8                         Standard deviation (s)   15.0563
#> 9                                       Mean (Y)   33.1200
#> 10               Standard error of the mean (Sy)    2.7595
#> 11                                Absolute Error    5.6952
#> 12                            Relative Error (%)   17.1957
#> 13                  Estimated Total Value (Yhat) 5166.7200
#> 14                                   Total Error  888.4555
#> 15             Inferior Confidence Interval (m3)   27.4248
#> 16             Superior Confidence Interval (m3)   38.8152
#> 17          Inferior Confidence Interval (m3/ha)   91.4159
#> 18          Superior Confidence Interval (m3/ha)  129.3841
#> 19       inferior Total Confidence Interval (m3) 4278.2645
#> 20       Superior Total Confidence Interval (m3) 6055.1755

The desired error was met.

The area values can also be inserted as variables:

sprs(data_acs_def, "VWB", "PLOT_AREA", "TOTAL_AREA", 
     error = 20, pop = "fin")
#>                                        Variables    Values
#> 1              Total number of sampled plots (n)   25.0000
#> 2                    Number of maximum plots (N)  156.0000
#> 3                      Variance Quoeficient (VC)   45.4600
#> 4                                      t-student    2.0639
#> 5                         recalculated t-student    2.0930
#> 6  Number of samples regarding the admited error   20.0000
#> 7                                  Variance (S2)  226.6933
#> 8                         Standard deviation (s)   15.0563
#> 9                                       Mean (Y)   33.1200
#> 10               Standard error of the mean (Sy)    2.7595
#> 11                                Absolute Error    5.6952
#> 12                            Relative Error (%)   17.1957
#> 13                  Estimated Total Value (Yhat) 5166.7200
#> 14                                   Total Error  888.4555
#> 15             Inferior Confidence Interval (m3)   27.4248
#> 16             Superior Confidence Interval (m3)   38.8152
#> 17          Inferior Confidence Interval (m3/ha)   91.4159
#> 18          Superior Confidence Interval (m3/ha)  129.3841
#> 19       inferior Total Confidence Interval (m3) 4278.2645
#> 20       Superior Total Confidence Interval (m3) 6055.1755

It’s also possible to run multiple simple random sampling inventories. To demonstrate this, we’ll use the example dataset for stratified sampling, but running simple random statistics. We’ll still use the sprs function, but use the .groups argument to run a simple random sampling inventory for each stratum:

sprs(data_ace_def, "VWB", "PLOT_AREA", "STRATA_AREA",
     .groups = "STRATA" ,error = 20, pop = "fin")
#>                                        Variables  STRATA1   STRATA2   STRATA3
#> 1              Total number of sampled plots (n)  14.0000   20.0000   23.0000
#> 2                    Number of maximum plots (N) 144.0000  164.0000  142.0000
#> 3                      Variance Quoeficient (VC)  24.4785   15.8269   16.7813
#> 4                                      t-student   2.1604    2.0930    2.0739
#> 5                         recalculated t-student   2.4469    4.3027    4.3027
#> 6  Number of samples regarding the admited error   9.0000   11.0000   12.0000
#> 7                                  Variance (S2)   2.1829    3.6161    5.3192
#> 8                         Standard deviation (s)   1.4774    1.9016    2.3063
#> 9                                       Mean (Y)   6.0357   12.0150   13.7435
#> 10               Standard error of the mean (Sy)   0.3752    0.3984    0.4402
#> 11                                Absolute Error   0.8105    0.8339    0.9130
#> 12                            Relative Error (%)  13.4288    6.9409    6.6431
#> 13                  Estimated Total Value (Yhat) 869.1429 1970.4600 1951.5739
#> 14                                   Total Error 116.7157  136.7670  129.6455
#> 15             Inferior Confidence Interval (m3)   5.2252   11.1811   12.8305
#> 16             Superior Confidence Interval (m3)   6.8462   12.8489   14.6565
#> 17          Inferior Confidence Interval (m3/ha)  52.2519  111.8105  128.3048
#> 18          Superior Confidence Interval (m3/ha)  68.4624  128.4895  146.5647
#> 19       inferior Total Confidence Interval (m3) 752.4271 1833.6930 1821.9284
#> 20       Superior Total Confidence Interval (m3) 985.8586 2107.2270 2081.2194

Stratified Random Sampling

The objective of this example is to survey an area using the stratified random sampling method. The area was divided into 3 strata: one with 14.4 ha and 7 plots, another with 16.4 ha and 8 plots, and another with 14.2 ha and 7 plots. The plots have an area of 1000 square meters. In total, 22 plots were sampled for the pilot inventory. The data is shown below:

data_ace_pilot
#>    STRATA STRATA_AREA PLOT_AREA   VWB
#> 1       1        14.4      1000  7.90
#> 2       1        14.4      1000  3.80
#> 3       1        14.4      1000  4.40
#> 4       1        14.4      1000  6.25
#> 5       1        14.4      1000  5.55
#> 6       1        14.4      1000  8.10
#> 7       1        14.4      1000  6.10
#> 8       2        16.4      1000 10.20
#> 9       2        16.4      1000 15.25
#> 10      2        16.4      1000 13.40
#> 11      2        16.4      1000 13.60
#> 12      2        16.4      1000 14.20
#> 13      2        16.4      1000  9.85
#> 14      2        16.4      1000 10.20
#> 15      2        16.4      1000 11.55
#> 16      3        14.2      1000 10.65
#> 17      3        14.2      1000 12.15
#> 18      3        14.2      1000 14.60
#> 19      3        14.2      1000 10.90
#> 20      3        14.2      1000 16.55
#> 21      3        14.2      1000 17.90
#> 22      3        14.2      1000 13.35

We’ll calculate the statistics with an aimed error of 5%, considering a finite population using the strs function. Area values can be inserted as a numeric vector, or as a variable. The plot area must be inserted in square meters, and strata area must be in hectares:

strs(data_ace_pilot, "VWB", 3000, c(14.4, 16.4, 14.2), 
     strata = "STRATA", error = 5, pop = "fin")
#> $Table1
#>                                             Variables  STRATA 1  STRATA 2
#> 1                                           Plot Area 3000.0000 3000.0000
#> 2            Number of sampled plots per stratum (nj)    7.0000    8.0000
#> 3                   Total number of sampled plots (n)   22.0000   22.0000
#> 4            Number of maximum plots per stratum (Nj)   48.0000   54.6667
#> 5                         Number of maximum plots (N)  150.0000  150.0000
#> 6                                     Nj/N Ratio (Pj)    0.3200    0.3644
#> 7                                   Stratum sum (Eyj)   42.1000   98.2500
#> 8                        Stratum quadratic sum (Eyj2)  268.8950 1237.2275
#> 9                         Mean of Yi per stratum (Yj)    6.0143   12.2812
#> 10                                              PjSj2    0.8370    1.5929
#> 11                                               PjSj    0.5175    0.7619
#> 12                                               PjYj    1.9246    4.4758
#> 13                                          t-student    2.0796    2.0796
#> 14                             recalculated t-student    2.0129    2.0129
#> 15      Number of samples regarding the admited error   45.0000   45.0000
#> 16 Optimal number of samples per stratum (nj optimal)   11.0000   16.0000
#> 17              Optimal number of samples (n optimal)   46.0000   46.0000
#> 18               Total value of Y per stratum (Yhatj)  288.6857  671.3750
#>     STRATA 3
#> 1  3000.0000
#> 2     7.0000
#> 3    22.0000
#> 4    47.3333
#> 5   150.0000
#> 6     0.3156
#> 7    96.1000
#> 8  1365.5500
#> 9    13.7286
#> 10    2.4316
#> 11    0.8760
#> 12    4.3321
#> 13    2.0796
#> 14    2.0129
#> 15   45.0000
#> 16   19.0000
#> 17   46.0000
#> 18  649.8190
#> 
#> $Table2
#>                                  Variables     value
#> 1                                t-student    2.0796
#> 2          Standard error of the mean (Sy)    0.4228
#> 3                      Stratified Variance    4.8614
#> 4            Stratified Standard Deviation    2.1554
#> 5                Variance Quoeficient (VC)   20.0829
#> 6                      Stratified Mean (Y)   10.7325
#> 7                           Absolute Error    0.8793
#> 8                       Relative Error (%)    8.1925
#> 9             Estimated Total Value (Yhat) 1609.8798
#> 10                             Total Error  131.8894
#> 11       Inferior Confidence Interval (m3)    9.8533
#> 12       Superior Confidence Interval (m3)   11.6118
#> 13    Inferior Confidence Interval (m3/ha)   32.8442
#> 14    Superior Confidence Interval (m3/ha)   38.7060
#> 15 inferior Total Confidence Interval (m3) 1477.9904
#> 16 Superior Total Confidence Interval (m3) 1741.7691

Analyzing the first table, we can see that in order to achieve the desired error, we must sample 24 additional plots. 4 in stratum 1, 8 in stratum 2 and 12 in stratum 3.

After a new survey, the new data is shown below:

data_ace_def
#>    STRATA STRATA_AREA PLOT_AREA   VWB
#> 1       1        14.4      1000  7.90
#> 2       1        14.4      1000  3.80
#> 3       1        14.4      1000  4.40
#> 4       1        14.4      1000  6.25
#> 5       1        14.4      1000  5.55
#> 6       1        14.4      1000  8.10
#> 7       1        14.4      1000  6.10
#> 8       1        14.4      1000  6.60
#> 9       1        14.4      1000  7.40
#> 10      1        14.4      1000  5.35
#> 11      1        14.4      1000  5.90
#> 12      1        14.4      1000  4.65
#> 13      1        14.4      1000  4.25
#> 14      1        14.4      1000  8.25
#> 15      2        16.4      1000 10.20
#> 16      2        16.4      1000 15.25
#> 17      2        16.4      1000 13.40
#> 18      2        16.4      1000 13.60
#> 19      2        16.4      1000 14.20
#> 20      2        16.4      1000  9.85
#> 21      2        16.4      1000 10.20
#> 22      2        16.4      1000 11.55
#> 23      2        16.4      1000  9.25
#> 24      2        16.4      1000 11.30
#> 25      2        16.4      1000 13.95
#> 26      2        16.4      1000 12.70
#> 27      2        16.4      1000 10.15
#> 28      2        16.4      1000 14.90
#> 29      2        16.4      1000 10.80
#> 30      2        16.4      1000 11.55
#> 31      2        16.4      1000 13.90
#> 32      2        16.4      1000  9.20
#> 33      2        16.4      1000 12.45
#> 34      2        16.4      1000 11.90
#> 35      3        14.2      1000 10.65
#> 36      3        14.2      1000 12.15
#> 37      3        14.2      1000 14.60
#> 38      3        14.2      1000 10.90
#> 39      3        14.2      1000 16.55
#> 40      3        14.2      1000 17.90
#> 41      3        14.2      1000 13.35
#> 42      3        14.2      1000 14.90
#> 43      3        14.2      1000  9.70
#> 44      3        14.2      1000 15.20
#> 45      3        14.2      1000 13.45
#> 46      3        14.2      1000 12.40
#> 47      3        14.2      1000 14.45
#> 48      3        14.2      1000 13.55
#> 49      3        14.2      1000 12.30
#> 50      3        14.2      1000 15.65
#> 51      3        14.2      1000 14.20
#> 52      3        14.2      1000 17.80
#> 53      3        14.2      1000 14.80
#> 54      3        14.2      1000  9.35
#> 55      3        14.2      1000 12.60
#> 56      3        14.2      1000 13.80
#> 57      3        14.2      1000 15.85

Now we’ll run the inventory again, this time with the definitive data:

strs(data_ace_def, "VWB", "PLOT_AREA", "STRATA_AREA", 
     strata = "STRATA", error = 5, pop = "fin")
#> $Table1
#>                                             Variables  STRATA 1  STRATA 2
#> 1                                           Plot Area 1000.0000 1000.0000
#> 2            Number of sampled plots per stratum (nj)   14.0000   20.0000
#> 3                   Total number of sampled plots (n)   57.0000   57.0000
#> 4            Number of maximum plots per stratum (Nj)  144.0000  164.0000
#> 5                         Number of maximum plots (N)  450.0000  450.0000
#> 6                                     Nj/N Ratio (Pj)    0.3200    0.3644
#> 7                                   Stratum sum (Eyj)   84.5000  240.3000
#> 8                        Stratum quadratic sum (Eyj2)  538.3950 2955.9100
#> 9                         Mean of Yi per stratum (Yj)    6.0357   12.0150
#> 10                                              PjSj2    0.6985    1.3179
#> 11                                               PjSj    0.4728    0.6930
#> 12                                               PjYj    1.9314    4.3788
#> 13                                          t-student    2.0032    2.0032
#> 14                             recalculated t-student    2.0141    2.0141
#> 15      Number of samples regarding the admited error   46.0000   46.0000
#> 16 Optimal number of samples per stratum (nj optimal)   12.0000   17.0000
#> 17              Optimal number of samples (n optimal)   47.0000   47.0000
#> 18               Total value of Y per stratum (Yhatj)  869.1429 1970.4600
#>     STRATA 3
#> 1  1000.0000
#> 2    23.0000
#> 3    57.0000
#> 4   142.0000
#> 5   450.0000
#> 6     0.3156
#> 7   316.1000
#> 8  4461.3350
#> 9    13.7435
#> 10    1.6785
#> 11    0.7278
#> 12    4.3368
#> 13    2.0032
#> 14    2.0141
#> 15   46.0000
#> 16   18.0000
#> 17   47.0000
#> 18 1951.5739
#> 
#> $Table2
#>                                  Variables     value
#> 1                                t-student    2.0032
#> 2          Standard error of the mean (Sy)    0.2339
#> 3                      Stratified Variance    3.6949
#> 4            Stratified Standard Deviation    1.8936
#> 5                Variance Quoeficient (VC)   17.7851
#> 6                      Stratified Mean (Y)   10.6471
#> 7                           Absolute Error    0.4685
#> 8                       Relative Error (%)    4.4003
#> 9             Estimated Total Value (Yhat) 4791.1768
#> 10                             Total Error  210.8250
#> 11       Inferior Confidence Interval (m3)   10.1786
#> 12       Superior Confidence Interval (m3)   11.1156
#> 13    Inferior Confidence Interval (m3/ha)  101.7856
#> 14    Superior Confidence Interval (m3/ha)  111.1556
#> 15 inferior Total Confidence Interval (m3) 4580.3518
#> 16 Superior Total Confidence Interval (m3) 5002.0018

The desired error was met.

Systematic Sampling

Now we’ll survey an area of 18 hectares in which 18 plots of 200 m² each were systematically sampled:

data_as
#>    TOTAL_AREA PLOT_AREA VWB
#> 1          18       200   6
#> 2          18       200   8
#> 3          18       200   9
#> 4          18       200  10
#> 5          18       200  13
#> 6          18       200  12
#> 7          18       200  18
#> 8          18       200  19
#> 9          18       200  20
#> 10         18       200  20
#> 11         18       200  24
#> 12         18       200  23
#> 13         18       200  26
#> 14         18       200  30
#> 15         18       200  31
#> 16         18       200  31
#> 17         18       200  33
#> 18         18       200  32

First, let’s see what error we would get, if we used the simple random sampling method:

sprs(data_as, "VWB", 200, 18)
#>                                        Variables     Values
#> 1              Total number of sampled plots (n)    18.0000
#> 2                    Number of maximum plots (N)   900.0000
#> 3                      Variance Quoeficient (VC)    44.6505
#> 4                                      t-student     2.1098
#> 5                         recalculated t-student     1.9873
#> 6  Number of samples regarding the admited error    79.0000
#> 7                                  Variance (S2)    81.9771
#> 8                         Standard deviation (s)     9.0541
#> 9                                       Mean (Y)    20.2778
#> 10               Standard error of the mean (Sy)     2.1341
#> 11                                Absolute Error     4.5025
#> 12                            Relative Error (%)    22.2042
#> 13                  Estimated Total Value (Yhat) 18250.0000
#> 14                                   Total Error  4052.2580
#> 15             Inferior Confidence Interval (m3)    15.7753
#> 16             Superior Confidence Interval (m3)    24.7803
#> 17          Inferior Confidence Interval (m3/ha)   788.7634
#> 18          Superior Confidence Interval (m3/ha)  1239.0143
#> 19       inferior Total Confidence Interval (m3) 14197.7420
#> 20       Superior Total Confidence Interval (m3) 22302.2580

We got a 22.2% error. Now, let’s calculate the sampling error using the method of successive differences, with the ss_diffs function. To use this function, the data must be set in the measured order, the plot area must be in square meters, and the total area value must be in hectares.

ss_diffs(data_as, "VWB", 200, 18)
#>                                        Variables     Values
#> 1              Total number of sampled plots (n)    18.0000
#> 2                    Number of maximum plots (N)   900.0000
#> 3                      Variance Quoeficient (VC)    44.6505
#> 4                                      t-student     2.1098
#> 5                         recalculated t-student     1.9873
#> 6  Number of samples regarding the admited error    79.0000
#> 7                                  Variance (S2)    81.9771
#> 8                         Standard deviation (S)     9.0541
#> 9                                       Mean (Y)    20.2778
#> 10               Standard error of the mean (Sy)     0.4041
#> 11                                Absolute Error     0.8527
#> 12                            Relative Error (%)     4.2050
#> 13                  Estimated Total Value (Yhat) 18250.0000
#> 14                                   Total Error   767.4046
#> 15             Inferior Confidence Interval (m3)    19.4251
#> 16             Superior Confidence Interval (m3)    21.1304
#> 17          Inferior Confidence Interval (m3/ha)   971.2553
#> 18          Superior Confidence Interval (m3/ha)  1056.5225
#> 19       inferior Total Confidence Interval (m3) 17482.5954
#> 20       Superior Total Confidence Interval (m3) 19017.4046

We got a 4.2% error, which is significantly lower than before.