Function to calculate prediction interval

pred_int(df, analysis_result = "analysis_result",
  distribution = "distribution", method = "Bonferroni", n_mean = 1,
  k = 1, pi_type = "upper", conf_level = 0.95)

Arguments

df

df data frame of groundwater data in tidy format

analysis_result

the analysis result column

distribution

the distribution column

method

default is "Bonferroni"

n_mean

n.mean positive integer specifying the sample size associated with the future averages. The default value is n.mean=1 (i.e., individual observations). Note that all future averages must be based on the same sample size.

k

k positive integer specifying the number of future observations or averages the prediction interval should contain with confidence level conf.level. The default value is k=1.

pi_type

character string indicating what kind of prediction interval to compute. The possible values are pi_type="two-sided" (the default), pi_type="upper", and pi_type="lower".

conf_level

a scalar between 0 and 1 indicating the confidence level of the prediction interval. The default value is conf.level=0.95

Examples

data("gw_data") wells <- c("MW-1", "MW-2", "MW-3", "MW-4") params <- c("Sulfate, total", "Arsenic, dissolved", "Boron, dissolved") background <- lubridate::ymd(c("2007-12-20", "2012-01-01"), tz = "UTC") # first group data by location, param, and background # estimate percent less than and distribution background_data <- gw_data %>% filter(location_id %in% wells, param_name %in% params, sample_date >= background[1] & sample_date <= background[2]) %>% group_by(location_id, param_name, default_unit) %>% percent_lt() %>% est_dist(., keep_data_object = TRUE) %>% arrange(location_id, param_name) background_data %>% pred_int(., pi_type = "upper", conf_level = 0.99)
#> Warning: `cols` is now required. #> Please use `cols = c(sample_size, lpl, upl, conf_level)`
#> # A tibble: 12 x 8 #> # Groups: location_id, default_unit, param_name [12] #> location_id default_unit param_name distribution sample_size lpl upl #> <chr> <chr> <chr> <chr> <int> <dbl> <dbl> #> 1 MW-1 ug/L Arsenic, … Nonparametr… 14 -Inf 10 #> 2 MW-1 mg/L Boron, di… Nonparametr… 14 -Inf 1.37 #> 3 MW-1 mg/L Sulfate, … Nonparametr… 14 -Inf 117 #> 4 MW-2 ug/L Arsenic, … Nonparametr… 14 -Inf 10 #> 5 MW-2 mg/L Boron, di… Lognormal 14 0 2.69 #> 6 MW-2 mg/L Sulfate, … Nonparametr… 14 -Inf 200 #> 7 MW-3 ug/L Arsenic, … Nonparametr… 14 -Inf 10 #> 8 MW-3 mg/L Boron, di… Lognormal 14 0 2.00 #> 9 MW-3 mg/L Sulfate, … Lognormal 14 0 172. #> 10 MW-4 ug/L Arsenic, … Normal 14 -Inf 14.3 #> 11 MW-4 mg/L Boron, di… Normal 14 -Inf 1.00 #> 12 MW-4 mg/L Sulfate, … Nonparametr… 14 -Inf 120 #> # … with 1 more variable: conf_level <dbl>