knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", fig.align = "center", fig.width = 6, fig.height = 4, dpi = 300, out.width = "90%", auto_pdf = TRUE, message = FALSE, warning = FALSE )
The goal of dorem
is to provide easy-to-use dose-response models utilized in sport science. This package is currently in active development phases.
You can install the development version from GitHub with:
# install.packages("devtools") devtools::install_github("mladenjovanovic/dorem") require(dorem)
To provide very simplistic example of dorem
, I will use example data provided in supplementary material of Clarke & Skiba, 2013 paper, freely available on the publisher website. Data set contains cycling training load (i.e. dose) measured using the BikeScore metric (in AU) over 165 days, with occasional training response measured using 5-min Power Test (in Watts). Banister model (explained in aforementioned paper) is applied to understand relationship between training dose (i.e., BikeScore metric) and training response (i.e., 5-min Power Test):
require(dorem) require(tidyverse) require(cowplot) data("bike_score") banister_model <- dorem( Test_5min_Power ~ BikeScore, bike_score, method = "banister" ) # Print results banister_model # get coefs coef(banister_model) # Get model predictions bike_score$pred <- predict(banister_model, bike_score)$.pred # Plot dose <- ggplot(bike_score, aes(x = Day, y = BikeScore)) + theme_cowplot(10) + geom_bar(stat = "identity") + xlab(NULL) response <- ggplot(bike_score, aes(x = Day, y = pred)) + theme_cowplot(10) + geom_line() + geom_point(aes(y = Test_5min_Power), color = "red") + ylab("Test 5min Power") cowplot::plot_grid(dose, response, ncol = 1)
dorem
also allows more control and setup using the control
parameter. In the next example, cross-validation of 3 repeats and 5 folds will be performed, with additional feature of shuffling the predictors and evaluating how the model predicts on random predictors (i.e., dose):
banister_model <- dorem( Test_5min_Power ~ BikeScore, bike_score, method = "banister", # control setup control = dorem_control( shuffle = TRUE, optim_method = "L-BFGS-B", optim_maxit = 1000, cv_folds = 3, cv_repeats = 5 ) ) banister_model
To plot model predictions, including the CV as gray area and shuffle as dotted line, use:
plot(banister_model, type = "pred") + theme_minimal()
To plot model coefficients across CV folds:
plot(banister_model, type = "coef") + theme_minimal()
To plot model performance across CV folds (i.e., training and testing folds):
plot(banister_model, type = "perf") + theme_minimal()
Clarke DC, Skiba PF. 2013. Rationale and resources for teaching the mathematical modeling of athletic training and performance. Advances in Physiology Education 37:134–152. DOI: 10.1152/advan.00078.2011.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.