knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  echo = TRUE,
  message = FALSE,
  warning = FALSE,
  fig.align = "center",
  dpi = 300
)

``{block, type = 'rmdinfo'} Please, note that currentlycyclingtools` only provide critical power analyses. However, more functionality is planned, such as training impulse analyses (iTRIMP, bTRIMP, eTRIMP, luTRIMP).

If you have a suggestion, feel free to open an issue.

## Critical Power analysis

For performing **critical power** analysis, the general `critical_power()` function was created. There are basically two main options in there: you can choose which model to fit (i.e., CP 3-hyp, CP 2-hyp, CP linear, and CP 1/time), and you can also choose whether to produce an analysis with all the combinations of the time-to-exhaustion trials provided.

Let's look at the main functionality:

```r
library(cyclingtools)

simple_results <- critical_power(
  .data = demo_critical_power, 
  power_output_column = "PO", 
  time_to_exhaustion_column = "TTE", 
  method = c("3-hyp", "2-hyp", "linear", "1/time"), 
  plot = TRUE, 
  all_combinations = FALSE,
  reverse_y_axis = FALSE
)

simple_results

In the above example, we chose to fit critical power on all the available methods, but you can also just choose one or two:

critical_power(
  .data = demo_critical_power, 
  power_output_column = "PO", 
  time_to_exhaustion_column = "TTE", 
  method = c("3-hyp", "2-hyp"), 
  plot = TRUE, 
  all_combinations = FALSE,
  reverse_y_axis = FALSE
)

The nice thing about the retrieved results is that the model is saved as well. So you can further explore it if you would like to. For example, using the base R function summary():

simple_results %>% 
  dplyr::slice(1) %>% 
  dplyr::pull(model) %>% 
  .[[1]] %>% 
  summary()

Or the broom::tidy() function:

simple_results %>% 
  dplyr::slice(1) %>% 
  dplyr::pull(model) %>% 
  .[[1]] %>% 
  broom::tidy()

The above can also be more quickly achieved with the following:

simple_results %>% 
  dplyr::select(method, model) %>% 
  dplyr::rowwise() %>% 
  dplyr::mutate(tidy_model = broom::tidy(model) %>% list()) %>% 
  tidyr::unnest(cols = tidy_model)

Multiple combinations

The all_combinations argument let you decide whether to perform multiple fits from all the possible combinations of trials provided:

combinations_results <- critical_power(
  .data = demo_critical_power, 
  power_output_column = "PO", 
  time_to_exhaustion_column = "TTE", 
  method = c("3-hyp", "2-hyp", "linear", "1/time"), 
  plot = TRUE, 
  all_combinations = TRUE,
  reverse_y_axis = FALSE
)

combinations_results

You can also check the plots of each estimation in case you set plot = TRUE:

combinations_results %>% 
  dplyr::slice(10) %>% 
  dplyr::pull(plot)

Shiny app

All of these functions can be performed in Critical Power Dashboard



fmmattioni/cyclingtools documentation built on March 28, 2022, 5:33 p.m.