Create prior probability matrix for the value of information analysis.

prior_probability_matrix(
  site_data,
  feature_data,
  site_detection_columns,
  site_n_surveys_columns,
  site_probability_columns,
  feature_survey_sensitivity_column,
  feature_survey_specificity_column,
  feature_model_sensitivity_column,
  feature_model_specificity_column
)

Arguments

site_data

sf::sf() object with site data.

feature_data

base::data.frame() object with feature data.

site_detection_columns

character names of numeric columns in the argument to site_data that contain the proportion of surveys conducted within each site that detected each feature. Each column should correspond to a different feature, and contain a proportion value (between zero and one). If a site has not previously been surveyed, a value of zero should be used.

site_n_surveys_columns

character names of numeric columns in the argument to site_data that contain the total number of surveys conducted for each each feature within each site. Each column should correspond to a different feature, and contain a non-negative integer number (e.g. 0, 1, 2, 3). If a site has not previously been surveyed, a value of zero should be used.

site_probability_columns

character names of numeric columns in the argument to site_data that contain modeled probabilities of occupancy for each feature in each site. Each column should correspond to a different feature, and contain probability data (values between zero and one). No missing (NA) values are permitted in these columns.

feature_survey_sensitivity_column

character name of the column in the argument to feature_data that contains probability of future surveys correctly detecting a presence of each feature in a given site (i.e. the sensitivity of the survey methodology). This column should have numeric values that are between zero and one. No missing (NA) values are permitted in this column.

feature_survey_specificity_column

character name of the column in the argument to feature_data that contains probability of future surveys correctly detecting an absence of each feature in a given site (i.e. the specificity of the survey methodology). This column should have numeric values that are between zero and one. No missing (NA) values are permitted in this column.

feature_model_sensitivity_column

character name of the column in the argument to feature_data that contains probability of the initial models correctly predicting a presence of each feature in a given site (i.e. the sensitivity of the models). This column should have numeric values that are between zero and one. No missing (NA) values are permitted in this column. This should ideally be calculated using fit_xgb_occupancy_models() or fit_hglm_occupancy_models().

feature_model_specificity_column

character name of the column in the argument to feature_data that contains probability of the initial models correctly predicting an absence of each feature in a given site (i.e. the specificity of the models). This column should have numeric values that are between zero and one. No missing (NA) values are permitted in this column. This should ideally be calculated using fit_xgb_occupancy_models() or fit_hglm_occupancy_models().

Value

A matrix object containing the prior probabilities of each feature occupying each site. Each row corresponds to a different feature and each column corresponds to a different site.

Examples

# set seeds for reproducibility
set.seed(123)

# load example site data
data(sim_sites)
print(sim_sites)
#> Simple feature collection with 6 features and 13 fields
#> Geometry type: POINT
#> Dimension:     XY
#> Bounding box:  xmin: 0.10513 ymin: 0.04556193 xmax: 0.9764926 ymax: 0.8637977
#> CRS:           NA
#> # A tibble: 6 × 14
#>   survey_cost management_cost    f1    f2    f3    n1    n2    n3      e1     e2
#>         <dbl>           <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>   <dbl>  <dbl>
#> 1          14             102     1   1       1     3     3     3  1.00   -0.848
#> 2          25              90     0   0       0     0     0     0 -1.44    1.27 
#> 3          25             165     1   0.6     0     5     5     5  1.25    0.817
#> 4          17             104     0   0       0     0     0     0 -0.484  -0.292
#> 5          18             100     0   0       0     0     0     0  0.0135  0.380
#> 6          15              94     0   0       0     0     0     0 -0.347  -1.33 
#> # ℹ 4 more variables: p1 <dbl>, p2 <dbl>, p3 <dbl>, geometry <POINT>

# load example feature data
data(sim_features)
print(sim_features)
#> # A tibble: 3 × 7
#>   name  survey survey_sensitivity survey_specificity model_sensitivity
#>   <chr> <lgl>               <dbl>              <dbl>             <dbl>
#> 1 f1    TRUE                0.954              0.886             0.718
#> 2 f2    TRUE                0.974              0.875             0.705
#> 3 f3    TRUE                0.956              0.823             0.768
#> # ℹ 2 more variables: model_specificity <dbl>, target <dbl>

# calculate prior probability matrix
prior_matrix <- prior_probability_matrix(
  sim_sites, sim_features,
  c("f1", "f2", "f3"), c("n1", "n2", "n3"), c("p1", "p2", "p3"),
  "survey_sensitivity", "survey_specificity",
  "model_sensitivity", "model_specificity")

# preview prior probability matrix
print(prior_matrix)
#>         [,1]      [,2]         [,3]      [,4]      [,5]      [,6]
#> f1 0.9983146 0.2580030 9.999761e-01 0.2580030 0.2580030 0.2580030
#> f2 0.9978829 0.2556825 2.948501e-01 0.8342984 0.2556825 0.8342984
#> f3 0.9936754 0.2072052 4.363968e-07 0.8716228 0.2072052 0.8716228