The kwb.flusshygiene package provides functions in three major categories: model handling, model creation and model prediction.

Model handling

river_model_prediction

is the main function in this package. It uses all of the following functions from within.

get_paths

reads a serverpath library for easy directory accessing

search_existing_models

searches saved R-objects in the river directories.

Model creation

build_new_model

again a overhead function for model creation. Asks the user whether or not the new model shall be saved as R-object.

import_riverdata

reads all river data from a directory.

build_model

is a small function handling model creation and invokes stan_lm for model building.

ask_for_variables

asks the user which variables shall be included in the model. Creates plots as a side effect.

process_model_riverdata

processes a data.frame with the necessary data for the data argument in stan_lm

create_formula

creates a hygiene formula out of the variables with the form e.coli ~ Q * (R + Ka)

Model prediction

predict_quality

is the overhead function for the prediction. It also invokes posterior_predict.stanreg

get_newdata

gathers the latest data for prediction.

print_latest

prints the prediction of the latest day.

plot_predicted_quality

plots a whole season with quality assessment.

Utility functions

unroll_physical_data

unrolls a list with data with lagday combinations to 5 days (default)

correlation_scatterplot

plots a scatterplot matrix of the unrolled physical data together with correlation values.

Plotting functions

plot_stan_model

plots a stan_lm posterior predction with quality assessment.

plot_data_overview

plot data overview

plot_hygiene_overview

a statistical hygiene data overview

plot_q_overview

plot a overview of all q values

plot_rain_overview

plot a monthly overview of all rain gauges