# https://www.acefitness.org/fitness-certifications/ace-answers/exam-preparation-blog/616/rmr-versus-rmr
# https://www.ncbi.nlm.nih.gov/pmc/articles/PMC3572798/
#' @title Original Harris-Benedict equation
#'
#' @description
#' \lifecycle{stable}
#'
#' Calculates the rmr.
#'
#' @param weight weight in kg.
#' @param height height in centimeters.
#' @param age age in years.
#' @param sex `male` or `female`.
#'
#' @return metabolic rate.
#'
#' @details
#' Basal metabolic rate studies in Humans, CJK Henry, 2005. The H-B equation is
#' the most widely used equation in basal metabolic rate estimation. However,
#' according to the original publication, the measurements were taken during the
#' resting state, not under basal conditions.
#'
#' @references
#' Comparison of predictive equations for resting metabolic rate in healthy
#' nonobese and obese adults: a systematic review. Frankenfield D, Roth-Yousey
#' L, Compher C. J Am Diet Assoc. 2005 May; 105(5):775-89.)
#'
#' @importFrom checkmate assert_number
calculate_rmr_HB <- function(weight, height, age, sex) {
checkmate::assert_number(weight, lower = 0)
checkmate::assert_number(height, lower = 0)
checkmate::assert_number(age, lower = 0)
check_sex(sex)
if (sex == "male") {
w <- 13.7516 * weight
h <- 5.0033 * height
a <- 6.7550 * age
x <- 66.4730
}
if (sex == "female") {
w <- 9.5634 * weight
h <- 1.8496 * height
a <- 4.6756 * age
x <- 655.0955
}
return(x + w + h - a)
}
#' @title Revised Harris-Benedict equation
#'
#' @description
#' \lifecycle{stable}
#'
#' Calculates the rmr.
#'
#' @param weight weight in kg.
#' @param height height in centimeters.
#' @param age age in years.
#' @param sex `male` or `female`.
#'
#' @return Resting metabolic rate
#'
#' @details The 95% confidence range for men is ±213.0 kcal/day, and ±201.0
#' kcal/day for women.
#'
#' @importFrom checkmate assert_number
calculate_rmr_RHB <- function(weight, height, age, sex) {
checkmate::assert_number(weight, lower = 0)
checkmate::assert_number(height, lower = 0)
checkmate::assert_number(age, lower = 0)
check_sex(sex)
if (sex == "male") {
w <- 13.397 * weight
h <- 4.799 * height
a <- 5.677 * age
x <- 88.362
}
if (sex == "female") {
w <- 9.247 * weight
h <- 3.098 * height
a <- 4.330 * age
x <- 447.593
}
return(x + w + h - a)
}
#' @title Mifflin St Jeor Equation
#'
#' @description
#' \lifecycle{stable}
#'
#' Calculates the RMR
#'
#' @param weight weight in kg.
#' @param height height in centimeters.
#' @param age age in years.
#' @param sex `male` or `female`.
#'
#' @return Resting metabolic rate
#'
#' @details details
#'
#' @importFrom checkmate assert_number
calculate_rmr_MSJ <- function(weight, height, age, sex) {
checkmate::assert_number(weight, lower = 0)
checkmate::assert_number(height, lower = 0)
checkmate::assert_number(age, lower = 0)
check_sex(sex)
w <- 10 * weight
h <- 6.25 * height
a <- 5 * age
if (sex == "male") {
x <- 5
}
if (sex == "female") {
x <- -161
}
return(w + h - a + x)
}
#' @title The Katch-McArdle equation (Resting Daily Energy Expenditure)
#'
#' @description
#' \lifecycle{stable}
#'
#' Calculates the rmr.
#'
#' @param weight weight in kg.
#' @param bfp body fat percentage.
#'
#' @return Resting metabolic rate
#'
#' @details details
#'
#' @importFrom checkmate assert_number
calculate_rmr_KMA <- function(weight, bfp) {
checkmate::assert_number(weight, lower = 0)
checkmate::assert_number(bfp, lower = 0)
lbw <- weight * (1 - (bfp / 100))
return(370 + (21.6 * lbw))
}
#' @title The Katch-McArdle-hybrid equation (Resting Daily Energy Expenditure)
#'
#' @description
#' \lifecycle{stable}
#'
#' Calculates the rmr.
#'
#' @param weight weight in kg.
#' @param bfp body fat percentage.
#'
#' @return Resting metabolic rate
#'
#' @details details
#'
#' @importFrom checkmate assert_number
calculate_rmr_KMAH <- function(weight, bfp) {
checkmate::assert_number(weight, lower = 0)
checkmate::assert_number(bfp, lower = 0)
lbp <- 1 - bfp / 100
x1 <- 370 * lbp
x2 <- 21.6 * (weight * lbp)
x3 <- 6.17 * (weight * (bfp / 100))
return(x1 + x2 + x3)
}
#' @title The Cunningham equation (Resting Daily Energy Expenditure)
#'
#' @description
#' \lifecycle{stable}
#'
#' Calculates the rmr.
#'
#' @param weight weight in kg.
#' @param bfp body fat percentage.
#'
#' @return Resting metabolic rate
#'
#' @details details
#'
#' @importFrom checkmate assert_number
calculate_rmr_CH <- function(weight, bfp) {
checkmate::assert_number(weight, lower = 0)
checkmate::assert_number(bfp, lower = 0)
lbw <- weight * (1 - (bfp / 100))
return(500 + (22 * lbw))
}
#' @title Calculate resting metabolic rate
#'
#' @description
#' \lifecycle{stable}
#'
#' Calculates the resting metabolic rate using various equations. RMR is
#' synonymous with Resting energy expenditure (REE), but not with BMR or BEE
#' Keep in mind that these calculations are estimates. For more information go
#' to \url{https://en.wikipedia.org/wiki/Basal_metabolic_rate}.
#'
#' @param weight weight in kg.
#' @param height height in centimeters, Default: NULL.
#' @param age age in years, Default: NULL.
#' @param sex `male` or `female`, Default: NULL.
#' @param equation character string setting the equation (see details),
#' Default: 'revised-harris-benedict'.
#' @param bfp body fat percentage. Optional variable, used when equation is
#' 'katch-mcardle', Default: NULL.
#'
#' @return metabolic rate
#'
#' @details rmr is calculated as follows:
#' \deqn{rmr_{harris-benedict|male} = 66.4730 + 13.7516 \times weight +
#' 5.0033 \times height - 6.7550 \times age}
#' \deqn{rmr_{harris-benedict|female} = 655.0955 + 9.5634 \times weight +
#' 1.8496 \times height - 4.6756 \times age}
#' \deqn{rmr_{revised-harris-benedict|male} = 88.362 + 13.397 \times weight + 4.799 \times height - 5.677 \times age}
#' \deqn{rmr_{revised-harris-benedict|female} = 447.593 + 9.247 \times weight + 3.098 \times height - 4.330 \times age}
#' \deqn{rmr_{mifflin|male} = 10 \times weight + 6.25 \times height - 5 \times age + 5}
#' \deqn{rmr_{mifflin|female} = 10 \times weight + 6.25 \times height - 5 \times age - 161}
#' \deqn{rmr_{katch-mcardle} = 370 + 21.6 \times weight \times (1 - (\frac{bfp}{100}))}
#' \deqn{rmr_{katch-mcardle-hybrid} = 370 \times (1 - \frac{bfp}{100}) + 21.6 \times weight \times (1 - \frac{bfp}{100}) + 6.17 \times weight \times \frac{bfp}{100}}
#' \deqn{rmr_{cunningham} = 500 + 22 \times weight \times (1 - (\frac{bfp}{100})}
#'
#' @examples
#' calculate_rmr(
#' weight = 70,
#' height = 180,
#' age = 30,
#' sex = "male",
#' equation = "harris-benedict"
#' )
#' calculate_rmr(
#' weight = 55,
#' height = 170,
#' age = 30,
#' sex = "female",
#' equation = "harris-benedict"
#' )
#' @rdname calculate_rmr
#'
#' @seealso \code{\link{calculate_rmr}} \code{\link{calculate_ree}}
#'
#' @importFrom checkmate assert_choice
#'
#' @export
calculate_rmr <-
function(weight,
height = NULL,
age = NULL,
sex = NULL,
bfp = NULL,
equation = "mifflin") {
equation_choices <- c(
"mifflin",
"harris-benedict",
"revised-harris-benedict",
"katch-mcardle",
"katch-mcardle-hybrid",
"cunningham"
)
checkmate::assert_choice(equation, equation_choices)
rmr <- switch(
equation,
"mifflin" = {
calculate_rmr_MSJ(
weight = weight,
height = height,
age = age,
sex = sex
)
},
"harris-benedict" = {
calculate_rmr_HB(
weight = weight,
height = height,
age = age,
sex = sex
)
},
"revised-harris-benedict" = {
calculate_rmr_RHB(
weight = weight,
height = height,
age = age,
sex = sex
)
},
"katch-mcardle" = {
calculate_rmr_KMA(weight = weight, bfp = bfp)
},
"katch-mcardle-hybrid" = {
calculate_rmr_KMAH(weight = weight, bfp = bfp)
},
"cunningham" = {
calculate_rmr_CH(weight = weight, bfp = bfp)
}
)
return(rmr)
}
#' @rdname calculate_rmr
#' @export
calculate_ree <- calculate_rmr
#' @title Calculates the mean metabolic rate
#'
#' @description
#' \lifecycle{soft-deprecated}
#' `calculate_mean_rmr` calculates your mean rmr from all
#' available methods in calculate_rmr.
#'
#' @inheritParams calculate_rmr
#'
#' @return RMR for all equations
#'
#' @rdname calculate_rmr
#' @export
#' @importFrom dplyr bind_rows summarise_all mutate
calculate_mean_rmr <- function(weight,
height,
age,
sex,
bfp = NULL) {
equations <- c(
"mifflin",
"harris-benedict",
"revised-harris-benedict",
"katch-mcardle",
"katch-mcardle-hybrid",
"cunningham"
)
mean_rmr <-
tibble::enframe(
mapply(
calculate_rmr,
weight,
height,
age,
sex,
bfp,
equations
),
name = "equation",
value = "RMR"
) %>%
dplyr::mutate(Equation = equations) %>%
dplyr::select(Equation, RMR) %>%
dplyr::bind_rows(dplyr::summarise_all(
.,
list(~ if (is.numeric(.)) {
mean(.)
} else {
"mean"
})
))
return(mean_rmr)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.