Functions for modelbuilding \n build_model: takes the riverdata, handles the other functions and invokes stan_lm

build_model(riverdata, variables = ask_for_variables(riverdata),
  with_interaction = TRUE)

ask_for_variables(riverdata)

process_model_riverdata(riverdata, variables)

create_formula(variables, with_interaction = FALSE)

Arguments

riverdata

a list with riverdata (hygiene + physical data)

variables

character. Selected variables for the model

with_interaction

logical. Formula with interactions? Default set to TRUE

Value

Returns a model of the riverdata.

Returns a character-vector with the chosen model variables

Returns a data.frame with data for hygiene and chosen variables

Returns parsed model-formula. (Like model$formula)

Details

Build the model from hygiene data and physical data like flow, rain, wwtp. Asks for user input to select variables. Computes the data.frame with data for hygiene and chosen variables and creates a formula of the form: Q*(K + R) while multiple Qs will be multiplied, multiple Ks and Rs will be added.

Functions

  • ask_for_variables: Internal function. Quite time consuming

  • process_model_riverdata: Internal usage

  • create_formula: Internal usage

Examples

if (FALSE) variables <- c("e.coli","q_havel",...) lm(formula = eval(create_formula(variables)), data = process_model_riverdata(riverdata, variables))
#> Error in create_formula(variables): object 'variables' not found
create_formula(c("log_e.coli","q_havel","ka_ruhleben","r_berlin"))
#> log_e.coli ~ q_havel + ka_ruhleben + r_berlin #> <environment: 0x12124e28>
create_formula(c("e.coli","r_mitte","r_charlottenburg","r_spandau"))
#> e.coli ~ r_mitte + r_charlottenburg + r_spandau #> <environment: 0x12189af0>