The hardware and bandwidth for this mirror is donated by dogado GmbH, the Webhosting and Full Service-Cloud Provider. Check out our Wordpress Tutorial.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]dogado.de.
ubair is an R package for Statistical Investigation of the Impact of External Conditions on Air Quality: it uses the statistical software R to analyze and visualize the impact of external factors, such as traffic restrictions, hazards, and political measures, on air quality. It aims to provide experts with a transparent comparison of modeling approaches and to support data-driven evaluations for policy advisory purposes.
install.packages("remotes")
::install_local() remotes
Git needs to be installed.
install.packages("remotes")
::install_git("git@gitlab.opencode.de:uba-ki-lab/ubair.git")
remotes# alternative via https
::install_git("https://gitlab.opencode.de/uba-ki-lab/ubair.git") remotes
For a more detailed explanation of the package, you can access the vignettes:
vignette("user_sample_1", package = "ubair")
, if the
package was installed with vignetteslibrary(ubair)
<- load_params()
params <- sample_data_DESN025 env_data
# Plot meteo data
plot_station_measurements(env_data, params$meteo_variables)
<- lubridate::ymd("20191201") # This coincides with the start of the reference window
application_start <- lubridate::ymd_hm("20200323 00:00") # This splits the forecast into reference and effect
date_effect_start <- lubridate::ymd("20200504") # This coincides with the end of the effect window
application_end
<- 24 * 14 # 14 days buffer
buffer
<- prepare_data_for_modelling(env_data, params)
dt_prepared <- dt_prepared[complete.cases(dt_prepared)]
dt_prepared <- split_data_counterfactual(
split_data
dt_prepared, application_start,
application_end
)<- run_counterfactual(split_data,
res
params,detrending_function = "linear",
model_type = "lightgbm",
alpha = 0.9,
log_transform = TRUE,
calc_shaps = TRUE
)
#> [LightGBM] [Info] Auto-choosing col-wise multi-threading, the overhead of testing was 0.023641 seconds.
#> You can set `force_col_wise=true` to remove the overhead.
#> [LightGBM] [Info] Total Bins 1557
#> [LightGBM] [Info] Number of data points in the train set: 104486, number of used features: 9
#> [LightGBM] [Info] Start training from score -0.000000
<- res$prediction
predictions
plot_counterfactual(predictions, params,
window_size = 14,
date_effect_start,buffer = buffer,
plot_pred_interval = TRUE
)
round(calc_performance_metrics(predictions, date_effect_start, buffer = buffer), 2)
#> RMSE MSE MAE MAPE Bias
#> 7.38 54.48 5.38 0.18 -2.73
#> R2 Coverage lower Coverage upper Coverage Correlation
#> 0.74 0.97 0.95 0.92 0.89
#> MFB FGE
#> -0.05 0.19
round(calc_summary_statistics(predictions, date_effect_start, buffer = buffer), 2)
true | prediction | |
---|---|---|
min | 3.36 | 5.58 |
max | 111.90 | 59.71 |
var | 212.96 | 128.16 |
mean | 30.80 | 28.07 |
5-percentile | 9.29 | 10.73 |
25-percentile | 19.85 | 19.40 |
median/50-percentile | 29.60 | 27.09 |
75-percentile | 40.54 | 36.27 |
95-percentile | 56.80 | 47.69 |
estimate_effect_size(predictions, date_effect_start, buffer = buffer, verbose = TRUE)
#> The external effect changed the target value on average by -6.294 compared to the reference time window. This is a -26.37% relative change.
#> $absolute_effect
#> [1] -6.294028
#>
#> $relative_effect
#> [1] -0.2637
::sv_importance(res$importance, kind = "bee") shapviz
<- c("TMP", "WIG", "GLO", "WIR")
xvars ::sv_dependence(res$importance, v = xvars) shapviz
Install the development version of ubair:
install.packages("renv")
::restore()
renv::build()
devtools::load_all() devtools
pip install pre-commit
If you add new dependencies to ubair package, make sure to update the renv.lock file:
::snapshot() renv
Before you commit your changes update documentation, ensure style complies with tidyverse styleguide and all tests run without error
# update documentation and check package integrity
::check()
devtools# apply tidyverse style (also applied as precommit hook)
::use_tidy_style()
usethis# you can check for existing lintr warnings by
::lint()
devtools# run tests
::test()
devtools# build README.md if any changes have been made to README.Rmd
::build_readme() devtools
in .pre-commit-hook.yaml pre-commit rules are defined and applied before each commmit. This includes: split - run styler to format code in tidyverse style - run roxygen to update doc - check if readme is up to date - run lintr to finally check code style format
If precommit fails, check the automatically applied changes, stage them and retry to commit.
Install covr to run this.
<- covr::package_coverage(type = "all")
cov <- covr::coverage_to_list(cov)
cov_list ::data.table(
data.tablepart = c("Total", names(cov_list$filecoverage)),
coverage = c(cov_list$totalcoverage, as.vector(cov_list$filecoverage))
)
::report(cov) covr
Jore Noa Averbeck JoreNoa.Averbeck@uba.de
Raphael Franke Raphael.Franke@uba.de
Imke Voß imke.voss@uba.de
These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.
Health stats visible at Monitor.