Type: | Package |
Title: | Streamline Physical Activity Research |
Version: | 1.2.1 |
Depends: | R (≥ 3.5.0) |
Description: | Functions that support a broad range of common tasks in physical activity research, including but not limited to creation of Bland-Altman plots (<doi:10.1136/bmj.313.7049.106>), metabolic calculations such as basal metabolic rate predictions (https://europepmc.org/article/med/4044297/reloa), demographic calculations such as age-for-body-mass-index percentile (https://www.cdc.gov/growthcharts/cdc_charts.htm), and analysis of bout detection algorithm performance (https://pubmed.ncbi.nlm.nih.gov/34258524/). |
License: | GPL-3 |
Encoding: | UTF-8 |
LazyData: | true |
URL: | https://github.com/paulhibbing/PAutilities |
BugReports: | https://github.com/paulhibbing/PAutilities/issues |
RoxygenNote: | 7.2.3 |
Imports: | dplyr (≥ 0.7), equivalence, ggplot2 (≥ 2.2), graphics, lazyeval (≥ 0.2), lubridate (≥ 1.7.4), magrittr (≥ 1.5), methods, reshape2, rlang (≥ 0.3.1), stats, utils, Rcpp |
Suggests: | testthat, knitr, rmarkdown, matchingMarkets (≥ 1.0.1) |
VignetteBuilder: | knitr |
LinkingTo: | Rcpp |
NeedsCompilation: | yes |
Packaged: | 2025-06-07 20:50:48 UTC; phibbing |
Author: | Paul R. Hibbing [aut, cre], Centers for Disease Control and Prevention [ctb] |
Maintainer: | Paul R. Hibbing <paulhibbing@gmail.com> |
Repository: | CRAN |
Date/Publication: | 2025-06-11 15:30:11 UTC |
Assess risk using the method of D'Agostino et al. (2008)
Description
Assess risk using the method of D'Agostino et al. (2008)
Usage
DAgostino_wrapper(
sex,
age,
total_cholesterol,
hdl,
systolic,
bp_treated,
diabetes,
smoker,
points = TRUE
)
risk_DAgostino(
age,
total_cholesterol,
hdl,
systolic,
age_points,
tc_points,
sbp_breaks,
sbp_points,
diabetes,
smoker
)
get_risk(x, breaks, values)
DAgostino_raw(result, sex)
Arguments
sex |
character scalar indicating either sex for one person (i.e.,
|
age |
either a numeric scalar indicating age for one person, or a
character scalar indicating the name of the column in |
total_cholesterol |
same as |
hdl |
same as |
systolic |
same as |
bp_treated |
either a logical scalar indicating whether a person is
taking blood pressure medication, or a character scalar pointing to the
column in |
diabetes |
same as |
smoker |
same as |
points |
logical. Return as points (default) or risk percentage? |
age_points |
numeric vector giving the risk values assigned to each age
group. Used as a lookup reference for |
tc_points |
same as |
sbp_breaks |
numeric vector specifying which blood pressure levels to cut at |
sbp_points |
same as |
x |
a value on which to lookup a risk score |
breaks |
passed to |
values |
numeric vector giving the risk values assigned to each interval
in |
result |
output from |
Note
Parameter descriptions have been inherited from cvd_risk
,
but only direct scalar values (i.e., not column names) are allowed for this
function
References
PAutilities: Streamline Physical Activity Research
Description
A collection of utilities that are useful for a broad range of tasks that are common in physical activity research. The main features (with associated functions in parentheses) are:
Details
* Bland-Altman plots (ba_plot
)
* Bout analysis for moderate-to-vigorous physical activity (bout_mvpa
)
* Formatted descriptive statistics descriptives
* Demographic calculations (get_age
and get_BMI_percentile
)
* Metabolic calculations (get_bmr
, weir_equation
, and get_kcal_vo2_conversion
)
* Analysis of bout detection algorithm performance (get_transition_info
and associated methods, e.g. summary
and plot
)
Addition and subtraction for objects of class summaryTransition
Description
Addition and subtraction for objects of class summaryTransition
Usage
add_summaryTransition(e1, e2)
## S4 method for signature 'summaryTransition,summaryTransition'
e1 + e2
subtract_summaryTransition(e1, e2)
## S4 method for signature 'summaryTransition,summaryTransition'
e1 - e2
Arguments
e1 |
the first object |
e2 |
the second object |
Value
a summaryTransition
object (see summary.transition
As("summaryTransition", "data.frame")
Description
As("summaryTransition", "data.frame")
As("summaryTransition", "list")
Perform Bland-Altman analysis on a data frame
Description
Perform Bland-Altman analysis on a data frame
Usage
ba_analysis(df, x_var, y_var, regress_against = c("Y", "XY_mean"), ...)
Arguments
df |
the data frame on which to operate |
x_var |
character. The column name of the X variable |
y_var |
character. The column name of the Y variable (criterion measure, if applicable) |
regress_against |
character. One of |
... |
optional arguments passed to |
Value
A data frame that has various summaries (means, standard deviations,
and missing data details) plus mean bias (mean_bias
column) and
limits of agreement (lower_LOA
and upper_LOA
columns)
Examples
data(ex_data, package = "PAutilities")
ba_analysis(ex_data, "Axis1", "Vector.Magnitude", "XY_mean")
ba_analysis(
ex_data, "Axis1", "Vector.Magnitude", "XY_mean",
an_arbitrary_added_column = "Example of passing an extra column"
)
Create a Bland-Altman plot
Description
Create a Bland-Altman plot
Usage
ba_plot(plotdata, x_var, y_var, x_name, y_name, shape = 16, ...)
Arguments
plotdata |
dataframe from which to build the plot |
x_var |
character expression to evaluate for the x-axis |
y_var |
character expression to evaluate for the y-axis |
x_name |
axis label for the x-axis |
y_name |
axis label for the y-axis |
shape |
numeric. The point shape to display. |
... |
further arguments passed to |
Value
a Bland-Altman plot
References
Bland, J. M., & Altman, D. G. (1986). Statistical methods for assessing agreement between two methods of clinical measurement. lancet, 1(8476), 307-310.
See Also
Examples
data(ex_data, package = "PAutilities")
# Reduce the number of data points (for illustration purposes) by isolating
# the 150 largest cases
illustration_threshold <-
quantile(ex_data$Axis1, probs = 1 - (150 / nrow(ex_data)))
ex_data <- ex_data[ex_data$Axis1 > illustration_threshold, ]
# Generate the plot
my_ba <- ba_plot(
ex_data,
"(Axis1 + Axis3) / 2",
"Axis1 - Axis3",
"mean(Axis1, Axis3)",
"Axis1 - Axis3"
)
my_ba
# You can add to the plot as you would a normal ggplot object
my_ba +
ggplot2::geom_text(
x = 2000, y = 9000, label = "A",
size = 8, fontface = "bold", colour = "blue"
)
# With caution, you can change some automatic options (e.g. color of
# regression line) by overwriting in a new layer
my_ba + ggplot2::geom_smooth(method = "lm", se = FALSE, colour = "blue")
Internal helper functions for get_BMI_percentile
Description
Internal helper functions for get_BMI_percentile
Usage
percentile_age(age_mos, age_yrs)
percentile_BMI(BMI, weight_kg, height_cm)
percentile_index(reference, age_mos)
percentile_lms(reference, colname, lesser_index, greater_index, increment)
percentile_reference(sex)
percentile_sex(sex = c("error", "male", "female"))
percentile_z(BMI, L, M, S)
percentile_back_calculate(p = 0.95, L, M, S)
Arguments
age_mos |
age in months (optional) |
age_yrs |
age in years |
BMI |
numeric. Body mass index |
weight_kg |
Weight in kilograms |
height_cm |
height in centimeters |
reference |
reference subset for calculations |
colname |
character. Column name of |
lesser_index |
lower match index of |
greater_index |
upper match index of |
increment |
proportional distance between
|
sex |
Character scalar indicating participant's sex |
L |
lambda |
M |
mu |
S |
sigma |
p |
percentile for which to back-calculate a BMI (must be between 0 and 1) |
See Also
Classify moderate-to-vigorous physical activity in bouts of a specific minimum length
Description
Classify moderate-to-vigorous physical activity in bouts of a specific minimum length
Usage
bout_mvpa(
intensity,
var_type = c("METs", "Intensity"),
min_duration = 10,
termination = 3,
MoreArgs = list(breaks = c(-Inf, 1.51, 3, Inf), labels = c("SB", "LPA", "MVPA"), right
= FALSE),
...,
timestamps = NULL,
output_var = c("is_MVPA", "bout_tracker")
)
Arguments
intensity |
a vector of intensity classifications to be re-classified according to the bout definition |
var_type |
character scalar indicating whether the |
min_duration |
numeric scalar: minimum duration of a qualifying bout, in minutes |
termination |
numeric scalar: consecutive minutes of non-MVPA required to terminate the bout |
MoreArgs |
required arguments passed to |
... |
optional arguments passed to |
timestamps |
optional vector of POSIX-formatted timestamps. Must have
same length as |
output_var |
the output variable(s) to give |
Value
based on the setting of output_var
, one or both of
is_MVPA
and bout_tracker
will be returned, the former being
a vector of indicators (1 or 0) specifying whether a minute is part of a
valid MVPA bout, and the latter being a collapsed data frame giving only
the valid bouts of MVPA and the relevant information (i.e., duration of
the bout, minutes of MVPA, and percentage of time spent in MVPA within
the bout). If both are selected, they are returned in a list.
Examples
data(ex_data, package = "PAutilities")
ex_data$DateTime <- as.POSIXct(ex_data$DateTime, "UTC")
# Runs with a warning
bout_mvpa(ex_data$METs, "METs")
bout_mvpa(ex_data$METs, "METs", timestamps = ex_data$DateTime)
# Recommended usage
lapply(split(ex_data, strftime(ex_data$DateTime, "%Y-%m-%d", "UTC")),
function(x) {
bout_mvpa(x$METs, "METs", timestamps = x$DateTime)
})
lapply(split(ex_data, strftime(ex_data$DateTime, "%Y-%m-%d", "UTC")),
function(x) {
bout_mvpa(x$METs,
"METs",
timestamps = x$DateTime,
output_var = "is_MVPA")
})
lapply(split(ex_data, strftime(ex_data$DateTime, "%Y-%m-%d", "UTC")),
function(x) {
bout_mvpa(x$METs,
"METs",
timestamps = x$DateTime,
output_var = "bout_tracker")
})
Calculate risk of cardiovascular disease
Description
Calculate risk of cardiovascular disease
Usage
cvd_risk(
x = NULL,
method = "D'Agostino_2008",
sex,
age,
total_cholesterol,
hdl,
systolic,
bp_treated,
diabetes,
smoker,
points = TRUE,
...
)
## Default S3 method:
cvd_risk(
x = NULL,
method = "D'Agostino_2008",
sex,
age,
total_cholesterol,
hdl,
systolic,
bp_treated,
diabetes,
smoker,
points = TRUE,
...
)
## S3 method for class 'data.frame'
cvd_risk(
x = NULL,
method = "D'Agostino_2008",
sex,
age,
total_cholesterol,
hdl,
systolic,
bp_treated,
diabetes,
smoker,
points = TRUE,
combine = TRUE,
...
)
Arguments
x |
optional data frame. If provided, the other arguments will be taken as column names under the assumption that each row represents a separate person, and each column provides one of the requested pieces of information |
method |
character. Currently only |
sex |
character scalar indicating either sex for one person (i.e.,
|
age |
either a numeric scalar indicating age for one person, or a
character scalar indicating the name of the column in |
total_cholesterol |
same as |
hdl |
same as |
systolic |
same as |
bp_treated |
either a logical scalar indicating whether a person is
taking blood pressure medication, or a character scalar pointing to the
column in |
diabetes |
same as |
smoker |
same as |
points |
logical. Return as points (default) or risk percentage? |
... |
arguments passed to other methods |
combine |
logical. Give results as a list of |
Value
One or more risk profiles (for default method with points = TRUE
, or for data frames with combine = FALSE & points = TRUE
). Otherwise numeric risk percentage (for points = FALSE
, scalars and data frames) or an integer vector (for data frames with combine = TRUE & points = FALSE
)
References
Examples
cvd_risk(sex = "Female", age = 111, total_cholesterol = 111, systolic = 111,
hdl = 11, bp_treated = FALSE, diabetes = TRUE, smoker = TRUE)
df <- data.frame(
sex = sample(c("Male", "Female"), 5, TRUE),
age = sample(30:100, 5, TRUE),
tc = sample(150:300, 5, TRUE),
hdl = sample(30:70, 5, TRUE),
sbp = sample(100:180, 5, TRUE),
bpmed = sample(c(TRUE, FALSE), 5, TRUE),
diabetes = sample(c(TRUE, FALSE), 5, TRUE),
smoker = sample(c(TRUE, FALSE), 5, TRUE)
)
cvd_risk(
df, sex = "sex", age = "age",
total_cholesterol = "tc", hdl = "hdl",
systolic = "sbp", bp_treated = "bpmed",
diabetes = "diabetes", smoker = "smoker",
combine = FALSE
)
Compute descriptive statistics for a variable in the metabolic data set
Description
Compute descriptive statistics for a variable in the metabolic data set
Usage
descriptives(dataset, variable, group = NULL)
Arguments
dataset |
the dataset to analyze |
variable |
character scalar giving the variable name to summarize |
group |
character scalar giving an optional grouping variable for the summary |
Value
a data frame of formatted summary statistics
Examples
data(ex_data, package = "PAutilities")
ex_data$group_var <- rep(
c("One", "Two", "Three"),
each = ceiling(nrow(ex_data)/3)
)[seq(nrow(ex_data))]
descriptives(ex_data, "Axis1", "group_var")
Check if a dataframe is continuous
Description
Check if a dataframe is continuous
Usage
df_continuous(df, time_var = "Timestamp", digits = 6, ...)
Arguments
df |
the input data frame |
time_var |
character scalar giving the column name of the variable
containing timestamp information (either |
digits |
see |
... |
arguments passed to |
Value
a logical scalar indicating whether the dataframe reflects a continuous time series
Examples
data(ex_data, package = "PAutilities")
df_continuous(ex_data, "DateTime", tz = "UTC")
df_continuous(ex_data[-c(300:500), ], "DateTime", tz = "UTC")
Reorder the columns of a data frame
Description
Reorder the columns of a data frame
Usage
df_reorder(df, columns, after)
Arguments
df |
the data frame |
columns |
the column(s) to move (either as character names or numeric indices) |
after |
the column after which to insert |
Value
The reordered data frame
Examples
df <- data.frame(a = 1:10, b = 11:20, c = 21:30, d = 31:40)
df_reorder(df, 2:3, "d")
df_reorder(df, c("c", "d"), "a")
Account for cases that refuse all matches
Description
To run the college admissions algorithm, it is assumed that each
student/college has at least one possible match. In the activity transition
application, possible matches are restricted to "nearby" cases, i.e. within
some specified window_size
. Thus, if there are no matches close by,
there are no possible matches, and the case needs to be removed from the
analysis in the college admissions algorithm. It needs to be re-inserted
afterwards and labeled as a false positive or false negative, depending on
whether it was a college (i.e., a predicted transition) or a student (i.e.,
an actual transition), respectively.
Usage
dim_check(x)
prune_prefs(prefs)
Arguments
prefs |
an object passed from |
Value
A pruned list of matrices containing only cases with at least one possible match
Determine epoch length in seconds
Description
Determine epoch length in seconds
Usage
epoch_length_sec(timestamps, digits = 6)
Arguments
timestamps |
POSIX-formatted input |
digits |
for rounding. See details |
Details
The function is designed to work even when the epoch length is less
than one second (e.g., for raw accelerometry data). Thus, it is not
possible to base the code on convenient difftime
methods. Instead,
numeric operations are performed after running unclass
on the input.
This sometimes results in minuscule fluctuations of the calculated epoch
length (e.g., +/- 0.0000002). Thus, the code rounds everything to the
precision indicated by digits
. For most applications, the default
value (digits = 6
) should be well past the range of meaningful
fluctuations and lead to a favorable outcome. But the digits
argument can also be adjusted if greater assurance is needed.
After rounding, the code checks for the existence of multiple epoch lengths. If they are detected (e.g., due to a discontinuity in the file), a warning is issued and the most prevalent epoch length is returned. The warning will specify all the different epoch lengths that were detected, which may be useful information for troubleshooting.
Value
The epoch length of the data, in seconds
Examples
epoch_length_sec(Sys.time() + 0:5)
epoch_length_sec(Sys.time() + seq(0, 25, 5))
Determine the minimum equivalence zone necessary for establishing equivalence in a paired equivalence test
Description
Paired equivalence tests are conducted based on a pre-specified zone of equivalence. Following the test, it is useful to know how minimally small or large the zone would have needed to be in order for the test to indicate equivalence.
Usage
equivalent_at(result)
get_absolute_equivalent_at(result)
get_relative_equivalent_at(result)
Arguments
result |
data frame constructed in
|
Example data for calculating bouts of moderate-to-vigorous physical activity
Description
A dataset containing accelerometer data and predicted energy expenditure in metabolic equivalents (METs) that can be used to classify moderate-to-vigorous physical activity in continuous bouts.
Usage
ex_data
Format
A data frame with 10080 rows and 12 variables:
- FileID
character. Name of the file originating the data
- Date
character giving the date ("%m/%d/%Y")
- Time
character giving the time ("%H:%M:%S")
- DateTime
full timestamp (%Y-%m-%d %H:%M:%S) given as character
- dayofyear
numeric day of the year (i.e., julian date)
- minofday
numeric minute of the day (i.e., 0 for midnight and 1439 for 11:59)
- Axis1
activity counts for the device's first axis
- Axis2
activity counts for the device's second axis
- Axis3
activity counts for the device's third axis
- Steps
number of steps taken
- Vector.Magnitude
vector magnitude (Euclidian norm) of the activity counts from the three axes
- METs
predicted energy expenditure, in metabolic equivalents
Drop incomplete days from a dataset
Description
Drop incomplete days from a dataset
Usage
full_days(
df,
time_var = "Timestamp",
drop = c("all", "leading", "trailing", "label"),
epoch_length_sec = NULL,
label_name = "is_full_day",
digits = 6,
check_continuous = TRUE,
discontinuous_action = c("stop", "warn"),
...
)
Arguments
df |
the input data frame |
time_var |
character scalar giving the column name of the variable
containing timestamp information (either |
drop |
character scalar indicating which incomplete days to drop.
Can be |
epoch_length_sec |
optional. The epoch length of the data. If no value
is passed, |
label_name |
character scalar. Name to give the indicator column when
|
digits |
see |
check_continuous |
logical. Check the dataframe after dropping to see if it is continuous? |
discontinuous_action |
character scalar telling what to do if a
discontinuity is expected when |
... |
arguments passed to |
Value
an updated copy of df
, in which incomplete days are addressed
according to the selected value of drop
.
See Also
Examples
data(ex_data, package = "PAutilities")
ex_data <- full_days(
ex_data, "DateTime", "label", 60,
"full_day_indicator", tz = "UTC"
)
head(ex_data)
Calculate youth BMI percentile from CDC standards
Description
Calculate youth BMI percentile from CDC standards
Usage
get_BMI_percentile(
weight_kg,
height_cm,
age_yrs = NULL,
age_mos = NULL,
sex = c("Male", "Female"),
BMI = NULL,
df = NULL,
output = c("percentile", "classification", "both", "summary")
)
percentile_df(
df,
weight_kg = "default",
height_cm = "default",
age_yrs = "default",
age_mos = "default",
sex = "default",
BMI = "default",
output = c("percentile", "classification", "both", "summary")
)
Arguments
weight_kg |
Weight in kilograms |
height_cm |
height in centimeters |
age_yrs |
age in years |
age_mos |
age in months (optional) |
sex |
Character scalar indicating participant's sex |
BMI |
numeric. Body mass index |
df |
Optional data frame on which to operate. Default is |
output |
What should be returned: raw percentile, weight status classification, both percentile and classification, or a full summary (BMI, percentile, classification, and severe obesity cutoff)? |
Details
Only one of age_mos
and age_yrs
is required. The
former will be used if both are provided. If age_mos
is not
provided, it will be calculated based on age_yrs
, assuming 365.2425
days per year and 30.4375 days per month. Depending on how the initial age
calculation was made, rounding error will occur. Thus, use of the
get_age
function is recommended, with units =
"months"
. If BMI
is provided, there is no need to pass
weight_kg
or height_cm
.
Value
One of: A numeric scalar giving the BMI percentile (for output
= "percentile"
); a factor scalar giving the weight status (for
output = "classification"
); a list with the percentile and
classification (for output = "both"
); or a list with the BMI,
percentile, classification, and severe obesity cutoff (for output =
"summary"
).
References
This function was developed with reference to public domain resources provided by the Centers for Disease Control and Prevention. For more information, see:
https://www.cdc.gov/bmi/adult-calculator/bmi-categories.html
https://www.cdc.gov/growthcharts/cdc_charts.htm
See Also
doi:10.3945/ajcn.2009.28335 Kelly et al. (2013)
Examples
get_BMI_percentile(39.4, 144.5, 12.35, sex = "Male")
Calculate age
Description
Takes two Date objects and calculates age based on
difftime
(in days) divided by 365.2425 days per year (for
age in years) or 30.4375 days per month (for age in months).
Usage
get_age(birthdate, current_date, units = c("years", "months"))
Arguments
birthdate |
Date object giving the date of birth |
current_date |
Date object giving the date from which age is to be calculated |
units |
The units in which age should be reported |
Value
Numeric value giving age in the specified units.
Examples
get_age(as.Date("2000-01-01"), Sys.Date(), "years")
Calculate body mass index
Description
Calculate body mass index
Usage
get_bmi(
wt,
wt_unit = c("kg", "lb", "oz", "st"),
ht,
ht_unit = c("cm", "m", "in", "ft"),
target = NULL
)
get_wt_kg(wt, wt_unit = c("kg", "lb", "oz", "st"))
get_ht_m2(ht, ht_unit = c("cm", "m", "in", "ft"))
bmi_check(bmi)
target_wt(
target,
ht,
ht_unit = c("cm", "m", "in", "ft"),
wt_unit = c("kg", "lb", "oz", "st")
)
Arguments
wt |
body mass |
wt_unit |
character. Units of body mass (or desired units if
|
ht |
height |
ht_unit |
character. Units of height |
target |
an optional target BMI (kg/m^2), for which the corresponding body mass will be returned |
bmi |
internal argument |
Value
If target
is NULL
(default), the function returns the
body mass index. If target
is provided, the function will use
target
and ht
to back-calculate a target body mass in the
units defined by wt_unit
(kg by default).
Examples
get_bmi(160, "lb", 180, "cm")
get_bmi(ht = 5.90, ht_unit = "ft", target = 24, wt_unit = "st")
get_bmi(wt = c(60:79, NA), ht = c(NA, 160:179))
Retrieve estimated basal metabolic rate for an individual
Description
Retrieve estimated basal metabolic rate for an individual
Usage
get_bmr(
Sex = c("M", "F"),
Ht = NULL,
Wt,
Age,
verbose = FALSE,
RER = NULL,
equation = c("ht_wt", "wt", "both"),
kcal_table = c("Lusk", "Peronnet", "both"),
method = c("Schofield", "FAO", "both"),
MJ_conversion = c("thermochemical", "dry", "convenience", "all"),
kcal_conversion = 5
)
Arguments
Sex |
The individual's sex |
Ht |
The individual's height, in meters |
Wt |
The individual's weight, in kilograms |
Age |
The individual's age, in years |
verbose |
Logical. Should processing updates be printed? |
RER |
numeric. The respiratory exchange ratio |
equation |
The equation to apply |
kcal_table |
The table to reference for converting kilocalories to
oxygen consumption. See |
method |
The calculation method to use |
MJ_conversion |
The value to use for converting megajoules to kilocalories. Defaults to thermochemical. |
kcal_conversion |
numeric. If RER is NULL (default), the factor to use for converting kilocalories to oxygen consumption |
Value
a data frame containing predictions of basal metabolic rate in one column, along with additional columns that indicate how the predictions were obtained (e.g., which sources and conversions were applied)
References
Schofield, W. N. (1985). Predicting basal metabolic rate, new standards and review of previous work. Human nutrition. Clinical nutrition, 39, 5-41.
Examples
# Get BMR for an imaginary 900-year-old person (Age is only
# used to determine which equations to use, in this case the
# equations for someone older than 60)
get_bmr(
Sex = "M", Ht = 1.5, Wt = 80, Age = 900, equation = "both",
method = "both", RER = 0.865, kcal_table = "both",
MJ_conversion = c("all")
)
get_bmr(
Sex = "M", Ht = 1.5, Wt = 80, Age = 900, MJ_conversion = "all",
kcal_conversion = 4.86
)
get_bmr(
Sex = "M", Ht = 1.5, Wt = 80, Age = 900, method = "FAO",
kcal_conversion = 4.86
)
Retrieve indices for a rolling window analysis
Description
Retrieve indices for a rolling window analysis
Usage
get_indices(y_var, window_size = 15L)
Arguments
y_var |
NumericVector. Input on which to define the indices for each roll of the window |
window_size |
int. The size of the window |
Value
a list in which each element contains window_size
consecutive
integers that indicate which elements of y_var
would be extracted
for that roll of the window
Note
For this function, the output elements contain positions (i.e., indices) from
y_var
, whereas for rolling_groups
the output elements
contain the raw values found at each index
See Also
Examples
result <- get_indices(1:100, 10)
head(result)
tail(result)
Classify activity intensity
Description
Supports intensity classification via energy expenditure with or without additional posture requirements (i.e., for sedentary behavior to be in lying/seated posture)
Usage
get_intensity(mets, posture = NULL, ...)
Arguments
mets |
numeric vector of metabolic equivalents to classify |
posture |
character vector of postures |
... |
further arguments passed to |
Details
If breaks
and labels
arguments are not provided, default values
are <= 1.5 METs for sedentary behavior, 1.51-2.99 METs for light physical
activity, and >= 3.0 METs for moderate-to-vigorous physical activity.
It is expected for the elements of posture
to be one of c("lie",
"sit", "stand", "other")
. The function will run (with a warning) if that
requirement is not met, but the output will likely be incorrect.
Value
a factor giving intensity classifications for each element of
mets
Examples
mets <- seq(1, 8, 0.2)
posture <- rep(
c("lie", "sit", "stand", "other"), 9
)
intensity_no_posture <- get_intensity(mets)
intensity_posture <- get_intensity(mets, posture)
head(intensity_no_posture)
head(intensity_posture)
Retrieve conversion factors from kilocalories to oxygen consumption
Description
Retrieve conversion factors from kilocalories to oxygen consumption
Usage
get_kcal_vo2_conversion(RER, kcal_table = c("Lusk", "Peronnet", "both"))
Arguments
RER |
numeric. The respiratory exchange ratio |
kcal_table |
The table to reference for converting kilocalories to
oxygen consumption. See |
Details
RER values are matched to the table entries based on the minimum absolute difference. If there is a tie, the lower RER is taken.
Value
numeric vector giving the conversion factor from the specified table(s)
References
Peronnet, F., & Massicotte, D. (1991). Table of nonprotein respiratory quotient: an update. Can J Sport Sci, 16(1), 23-29.
Lusk, G. (1924). Analysis of the oxidation of mixtures of carbohydrate and fat: a correction. Journal of Biological Chemistry, 59, 41-42.
Examples
get_kcal_vo2_conversion(0.85, "both")
Obtain the matchings for predicted and actual activity transitions using the college admissions algorithm
Description
Obtain the matchings for predicted and actual activity transitions using the college admissions algorithm
Usage
get_matchings(prefs)
Arguments
prefs |
an object passed from |
Value
A data frame giving the relative and absolute indices of the matchings, based on optimal outcomes for the students (i.e., the actual transitions)
Obtain preference lists for predicted and actual (reference) activity transitions
Description
When predicting activity transitions, the behavior of the predictor is not
known a priori. It may predict too many or too few transitions, and its
"intent" is also unknown. Therefore, some method is necessary in order to
determine which predictions (if any) should be taken to correspond to a
reference transition. There should also be a record of false positives and
false negatives. The problem is treated as an instance of the college
admissions problem, wherein both parties give their preferences for who they
would like to be matched with, and a stable arrangement is sought. This
function supports the overall goal by assigning the preferences based on the
temporal proximity of predicted and actual transitions. Preferences beyond a
specified window_size
are not allowed.
Usage
get_preferences(predictions, references, window_size, missing_info)
## S3 method for class 'transition'
summary(object, ...)
Arguments
predictions |
A dummy-coded vector of predicted transitions (1) interspersed with non-transitions (0). Logical vectors are coerced to numeric. |
references |
A dummy-coded vector of actual (i.e., reference) transitions (1) interspersed with non-transitions (0). Logical vectors are coerced to numeric. |
window_size |
The maximum number of indices that are allowed to separate a predicted and reference transition, before the two are considered incompatible |
object |
a |
... |
further arguments passed to or from methods, currently unused |
Value
A list of matrices giving distance-based preferences for both the
predicted and reference transitions, formatted to pass directly to
hri
a data frame containing indicators that reflect, in different ways, the effectiveness of predicted transitions compared to the set of actual (reference) transitions
Examples
predictions <- (sample(1:100)%%2)
references <- (sample(1:100)%%2)
window_size <- 7
if (isTRUE(requireNamespace("matchingMarkets", quietly = TRUE))){
transitions <- get_transition_info(
predictions, references, window_size
)
summary(transitions)
}
Rank preferences for an arbitrary proposer and rejecter, based on distance (i.e., difference) between them
Description
Rank preferences for an arbitrary proposer and rejecter, based on distance (i.e., difference) between them
Usage
get_proposer_rank(proposer, rejecter, window_size)
Arguments
proposer |
A vector containing indices of transitions for the proposing (optimal) party |
rejecter |
A vector containing indices of transitions for the rejecting (pessimal) party |
window_size |
The maximum number of indices that are allowed to separate a predicted and reference transition, before the two are considered incompatible |
Value
A matrix with length(proposer)
columns and
length(rejecter)
rows, giving ordered preferences for the proposer,
based on the absolute difference between the ith proposer index and the
rejecter indices, where differences larger than window_size
are
treated as omitted preferences, i.e., non-possibilities.
Calculate resting energy expenditure
Description
Calculate resting energy expenditure
Usage
get_ree(
method = c("harris_benedict", "schofield_wt", "schofield_wt_ht", "fao", "muller_wt_ht",
"muller_ffm"),
sex,
age_yr = NA,
...,
output = c("default", "mj_day", "kcal_day", "vo2_ml_min"),
calorie = c("thermochemical", "convenience", "dry"),
RER = 0.86,
kcal_table = c("Lusk", "Peronnet", "both"),
df = NULL
)
Arguments
method |
character. The equation(s) to use, chosen from
|
sex |
character. The participant/patient sex, one of |
age_yr |
numeric. The participant/patient age in years. Not used for
|
... |
arguments (e.g. |
output |
character. The desired output unit(s), chosen from
|
calorie |
character. The desired conversion factor(s) for calculating MJ
from kcal, chosen from |
RER |
numeric. The respiratory exchange ratio |
kcal_table |
character. The desired conversion table(s) to use for
converting kcal to oxygen consumption, chosen from |
df |
optional data frame. If passed, all prior arguments should be
character scalars pointing to a column in |
Value
Calculated resting energy expenditure
Examples
get_ree("schofield_wt_ht", "female", 57.8, wt_kg = 80, ht_m = 1.50)
Internal functions for calculating resting energy expenditure
Description
Internal functions for calculating resting energy expenditure
Usage
get_ree_dataframe(df, method, sex, age_yr, ...)
get_ree_default(method, sex, age_yr, ...)
ree_single(
sex = c("female", "male"),
age_yr,
method,
breaks = c(-Inf, 3, 10, 18, 30, 60, Inf),
labels = c("less3", "3to10", "10to18", "18to30", "30to60", "over60"),
...
)
get_stratum(method, sex = c("female", "male"), age_yr, breaks, labels)
get_ree_single_setting(method, sex, age_yr, ..., df)
get_ree_grid(method, output, calorie, RER, kcal_table)
ree_profile(settings)
Arguments
df |
optional data frame. If passed, all prior arguments should be
character scalars pointing to a column in |
method |
character. The equation(s) to use, chosen from
|
sex |
character. The participant/patient sex, one of |
age_yr |
numeric. The participant/patient age in years. Not used for
|
... |
arguments (e.g. |
breaks |
age breaks to use (passed to |
labels |
age labels to use (passed to |
output |
character. The desired output unit(s), chosen from
|
calorie |
character. The desired conversion factor(s) for calculating MJ
from kcal, chosen from |
RER |
numeric. The respiratory exchange ratio |
kcal_table |
character. The desired conversion table(s) to use for
converting kcal to oxygen consumption, chosen from |
settings |
output from |
Invoke the Transition Pairing Method
Description
Invoke the Transition Pairing Method
Usage
get_transition_info(predictions, references, window_size = 1, ...)
validate_transition_info_input(predictions, references)
impute_trans(x, out_length)
recode_trans_names(x)
Arguments
predictions |
A dummy-coded vector of predicted transitions (1) interspersed with non-transitions (0). Logical vectors are coerced to numeric. |
references |
A dummy-coded vector of actual (i.e., reference) transitions (1) interspersed with non-transitions (0). Logical vectors are coerced to numeric. |
window_size |
The maximum number of indices that are allowed to separate a predicted and reference transition, before the two are considered incompatible |
... |
additional arguments passed to or from methods, not currently used |
Value
an object of class transition
that contains necessary
information for evaluating the effectiveness of the predictions.
Note
If the lengths of predictions
and references
differ, a
warning is issued, and the shorter vector will be expanded to match the
length of the longer, using the original relative/proportional positions of
the transitions to determine where they should be placed in the expanded
vector. The relative position could be determined different ways, each
having unique implications for how well aligned predictions
and
references
are. Therefore, while this function is not unusable when
the lengths differ, you should make sure you know what you're doing if you
want to use it that way. The safest solution is to expand the shorter
vector yourself.
See Also
Examples
set.seed(100)
predictions <- (sample(1:100)%%2)
references <- (sample(1:100)%%2)
window_size <- 7
if (isTRUE(requireNamespace("matchingMarkets", quietly = TRUE))) {
get_transition_info(predictions, references, window_size)
}
Run length encoding with indices
Description
Run length encoding with indices
Usage
index_runs(x, zero_index = FALSE)
Arguments
x |
vector of values on which to perform run length encoding |
zero_index |
logical. Should indices be indexed from zero (useful for Rcpp)? |
Value
A data frame with information about the runs and start/stop indices
Examples
x <- c(
FALSE, TRUE, FALSE, FALSE, FALSE, TRUE,
FALSE, TRUE, TRUE, FALSE, TRUE, FALSE,
FALSE, FALSE, FALSE, FALSE, TRUE, TRUE,
FALSE, TRUE
)
head(index_runs(x))
Printing and timing utility for managing processes
Description
Printing and timing utility for managing processes
Usage
manage_procedure(part = c("Start", "End"), ..., timer = NULL, verbose = TRUE)
get_duration(timer)
Arguments
part |
character scalar, either |
... |
character strings to print. Default messages will print if no arguments are provided. |
timer |
a proc_time object. Required for |
verbose |
logical. Print to console? |
Value
For part = "Start"
, a proc_time object (i.e., a timer passable
to an eventual part = "End"
command); for part = "End"
,
invisible
Examples
manage_procedure("Start", "String will be printed\n")
timer <- manage_procedure(
"Start", "Printing a string is optional", verbose = FALSE
)
## Default starting message
manage_procedure("Start")
## Default ending message
manage_procedure("End", timer = timer)
## Other examples
get_duration(timer)
manage_procedure("End", "Custom ending message")
Compute the mean and standard deviation of a vector, returning a formatted string containing the values as 'M +/- SD'
Description
Compute the mean and standard deviation of a vector, returning a formatted string containing the values as 'M +/- SD'
Usage
mean_sd(
x = NULL,
MoreArgs = NULL,
give_df = TRUE,
...,
mean_x = NULL,
sd_x = NULL
)
## Default S3 method:
mean_sd(
x = NULL,
MoreArgs = NULL,
give_df = TRUE,
...,
mean_x = NULL,
sd_x = NULL
)
## S3 method for class 'data.frame'
mean_sd(
x = NULL,
MoreArgs = NULL,
give_df = TRUE,
...,
mean_x = NULL,
sd_x = NULL
)
Arguments
x |
numeric vector of values to summarize |
MoreArgs |
named list of arguments to pass to |
give_df |
logical. Should mean, sd, and summary string be returned in a data frame? |
... |
additional arguments passed to |
mean_x |
an already-calculated mean value for |
sd_x |
an already-calculated sd value for |
Value
either a formatted character scalar (if give_df == FALSE
), or
else a data frame containing columns for the mean value, standard
deviation, and formatted character string combining the two.
Examples
mean_sd(rnorm(100, 50))
Dispatch resting metabolic rate calculations based on data frame input that specifies conversions etc.
Description
Dispatch resting metabolic rate calculations based on data frame input that specifies conversions etc.
Usage
metabolic_row_wise(calculation, weights)
assemble_wt_ht(calculation, weights)
assemble_wt(calculation, weights)
assemble_fao(calculation, weights)
Arguments
calculation |
data frame giving instructions and values for the calculations |
weights |
list of weights to choose from for the calculation |
Determine the number of temporal conflicts among the pairs assigned by the Gale-Shapley algorithm
Description
Determine the number of temporal conflicts among the pairs assigned by the Gale-Shapley algorithm
Usage
n_crossings(matchings)
Arguments
matchings |
data frame with pairing information. |
Value
integer vector specifying the number of conflicts for each pairing
A combined constructor and validator for paired_equivalence
objects
Description
A combined constructor and validator for paired_equivalence
objects
Usage
new_paired_equivalence(
x,
y,
y_type = c("both", "criterion", "comparison"),
alpha = 0.05,
na.rm = TRUE,
scale = c("relative", "absolute"),
absolute_region_width = NULL,
relative_region_width = NULL
)
Arguments
x |
numeric vector representing the (possibly surrogate) sample |
y |
numeric vector representing the (possibly criterion) sample. Index
paired with |
y_type |
classification of |
alpha |
the alpha level for the test |
na.rm |
logical. Omit mean values for mean calculations? |
scale |
character specifying whether the test should occur on an
absolute or relative scale. Must be one of |
absolute_region_width |
the region width for use when |
relative_region_width |
the region width for use when |
Value
an initialized paired_equivalence
object
Perform equivalence testing on paired samples
Description
Perform equivalence testing on paired samples
Usage
## S3 method for class 'data.frame'
paired_equivalence_test(
x,
y,
y_type = c("both", "criterion", "comparison"),
alpha = 0.05,
na.rm = TRUE,
scale = c("relative", "absolute"),
absolute_region_width = NULL,
relative_region_width = NULL,
...
)
## Default S3 method:
paired_equivalence_test(
x,
y,
y_type = c("both", "criterion", "comparison"),
alpha = 0.05,
na.rm = TRUE,
scale = c("relative", "absolute"),
absolute_region_width = NULL,
relative_region_width = NULL,
...
)
paired_equivalence_test(
x,
y,
y_type = c("both", "criterion", "comparison"),
alpha = 0.05,
na.rm = TRUE,
scale = c("relative", "absolute"),
absolute_region_width = NULL,
relative_region_width = NULL,
...
)
Arguments
x |
numeric vector representing the (possibly surrogate) sample |
y |
numeric vector representing the (possibly criterion) sample. Index
paired with |
y_type |
classification of |
alpha |
the alpha level for the test |
na.rm |
logical. Omit mean values for mean calculations? |
scale |
character specifying whether the test should occur on an
absolute or relative scale. Must be one of |
absolute_region_width |
the region width for use when |
relative_region_width |
the region width for use when |
... |
further arguments passed to methods. Currently unused. |
Value
a 'paired_equivalence' object summarizing the test input and results
Note
If a value is not specified for the region width that corresponds with
scale
, a default value will be assigned with a warning.
References
Examples
set.seed(1544)
x <- data.frame(
var1 = rnorm(500, 15, 4),
var2 = rnorm(500, 23, 7.3)
)
y <- rnorm(500, 17.4, 9)
test_result <- paired_equivalence_test(
x, y, relative_region_width = 0.25
)
lapply(test_result, head)
A template function for conducting a paired equivalence test
Description
A template function for conducting a paired equivalence test
Usage
paired_equivalence_wrapper(
x,
y,
y_type,
width,
epsilon,
alpha,
scale,
na.rm,
do_test = TRUE
)
Arguments
x |
numeric vector representing the (possibly surrogate) sample |
y |
numeric vector representing the (possibly criterion) sample. Index
paired with |
y_type |
classification of |
width |
the user-specified width of the equivalence region, possibly a proportion of an initially-uncalculated mean |
epsilon |
the calculated width of the equivalence region |
alpha |
the alpha level for the test |
scale |
character specifying whether the test should occur on an
absolute or relative scale. Must be one of |
na.rm |
logical. Omit mean values for mean calculations? |
do_test |
logical. Complete the test? Enables premature return that is useful in some cases |
Plot the outcome of a paired equivalence test
Description
Plot the outcome of a paired equivalence test
Usage
## S3 method for class 'paired_equivalence'
plot(x, shade = "auto", ...)
shaded_equivalence_plot(results, ...)
unshaded_equivalence_plot(results, ...)
Arguments
x |
the object to be plotted |
shade |
logical. Should the results be plotted using a shaded equivalence region? |
... |
arguments passed to |
results |
data frame. The |
Details
shaded_equivalence_plot
plots the results of an equivalence test in
which a single equivalence region applies to all variables. In that case, the
equivalence region is displayed as a shaded region.
unshaded_equivalence_plot
plots the results of an equivalence test in
which variables have unique equivalence regions. In that case, the
equivalence regions are displayed as dodged "confidence intervals".
Value
A plot of the equivalence test
Examples
set.seed(1544)
y <- rnorm(500, 17.4, 9)
z <- data.frame(
var1 = rnorm(500, 15, 4),
var2 = rnorm(500, 23, 7.3)
)
# Optionally create artificial missing values to trigger unshaded plot
missing_indices <- sample(seq(nrow(z)), 250)
z$var1[missing_indices] <- NA
x <- paired_equivalence_test(
z, y, "criterion", scale = "relative",
relative_region_width = 0.25
)
plot(x)
Plot a spurious curve
Description
Plot a spurious curve
Usage
## S3 method for class 'spurious_curve'
plot(x, ...)
Arguments
x |
a |
... |
further arguments (currently unused) |
Value
a plot of the object
See Also
Examples
set.seed(100)
predictions <- (sample(1:100)%%2)
references <- (sample(1:100)%%2)
trans <- get_transition_info(
predictions, references, 7
)
result <- spurious_curve(trans)
plot(result)
Plot the transitions and matchings from a transition
object
Description
Plot the transitions and matchings from a transition
object
Usage
## S3 method for class 'transition'
plot(x, ...)
Arguments
x |
the object to plot |
... |
further methods passed to or from methods, currently unused |
Value
A plot of the predicted and actual transitions in a transition
object, as well as the matchings between them
Examples
predictions <- (sample(1:100)%%2)
references <- (sample(1:100)%%2)
window_size <- 7
if (isTRUE(requireNamespace("matchingMarkets", quietly = TRUE))){
transitions <- get_transition_info(
predictions, references, window_size
)
plot(transitions)
}
Impute placeholder values into a transition
object
Description
If missing values are passed to get_transition_info
, the
prediction and criterion data streams become irregularly spaced. This fixes
the spacing issue.
Usage
reconstruct_transitions(x)
Arguments
x |
Effectively a |
Perform residual adjustment on an epidemiologic variable
Description
Perform residual adjustment on an epidemiologic variable
Usage
residual_adjust(d, variable, confounder, label, verbose = FALSE)
Arguments
d |
the input data frame on which to perform the adjustment |
variable |
character. Name of variable needing adjustment |
confounder |
character. Name of the confounder to adjust for |
label |
character. Name to give the adjusted variable |
verbose |
logical. Print updates to console? |
Value
The original d
object, with an extra column reflecting
residual adjustments on the selected variable.
Examples
d <- data.frame(
VARIABLE = rnorm(100, 10, 2),
CONFOUNDER = rnorm(100, 3, 7)
)
result <- residual_adjust(d, "VARIABLE", "CONFOUNDER", "ADJUSTED")
head(d)
head(result)
Calculate resting metabolic rate using a sliding window method
Description
Calculate resting metabolic rate using a sliding window method
Usage
rmr_sliding(
vo2_values,
vo2_timestamps,
start_time,
stop_time,
window_size_minutes = 5
)
Arguments
vo2_values |
numeric vector of oxygen consumption values |
vo2_timestamps |
timestamps corresponding to each element of
|
start_time |
the beginning time of the assessment period |
stop_time |
the ending time of the assessment period |
window_size_minutes |
the size of the sliding window, in minutes |
Value
A data frame giving the oxygen consumption from the lowest window, as well as the time difference from first to last breath in the same window.
Examples
set.seed(144)
fake_start_time <- Sys.time()
fake_stop_time <- fake_start_time + 1800
fake_timestamps <- fake_start_time + cumsum(sample(1:3, 500, TRUE))
fake_timestamps <- fake_timestamps[fake_timestamps <= fake_stop_time]
fake_breaths <- rnorm(length(fake_timestamps), 450, 0.5)
window_size <- 5
rmr_sliding(
fake_breaths, fake_timestamps,
fake_start_time, fake_stop_time,
window_size
)
Loop along a vector, returning n elements at a time in a list
Description
Loop along a vector, returning n elements at a time in a list
Usage
rolling_groups(values, n = 2L)
Arguments
values |
IntegerVector. The vector to loop along |
n |
int. The number of elements to return in each element of the resulting list |
Value
a list in which each element contains n
elements from
values
Note
For this function, the output elements contain raw values from
values
, whereas for get_indices
the output elements
contain the positions (i.e., indices) rather than the raw values
See Also
Examples
groups <- rolling_groups(0:50, 3)
head(groups)
tail(groups)
Label matchings for rejection if the assignment violates sequential nature of the data
Description
Label matchings for rejection if the assignment violates sequential nature of the data
Usage
sequence_check(prefs)
Arguments
prefs |
a list assembled in |
Value
a list ready for assignment as class transition
Perform a spurious curve analysis
Description
Assess performance using the Transition Pairing Method when the spurious pairing threshold is varied
Usage
spurious_curve(trans, predictions, references, thresholds = 1:20)
Arguments
trans |
a |
predictions |
vector of predictions indicating transition |
references |
vector of criteria indicating transition |
thresholds |
the threshold settings to test |
Value
an object with class spurious_curve
Examples
set.seed(100)
predictions <- (sample(1:100)%%2)
references <- (sample(1:100)%%2)
trans <- get_transition_info(
predictions, references, 7
)
head(spurious_curve(trans))
An S4 class containing summary information about a transition
object
Description
An S4 class containing summary information about a transition
object
Slots
result
a data frame with the summary information
Compare numeric variables in a data frame based on root-squared differences
Description
Compare numeric variables in a data frame based on root-squared differences
Usage
test_errors(
reference,
target,
vars,
tolerance = 0.001005,
return_logical = TRUE
)
Arguments
reference |
a data frame giving reference data |
target |
a data frame giving target data |
vars |
character vector of variable names to compare in each data frame |
tolerance |
allowable difference between numeric values |
return_logical |
logical. Should result be given as a logical vector (indicating TRUE/FALSE equality within tolerance) or a data frame of error summary values? |
Value
If return_logical = TRUE
, a named logical vector with one
element per variable compared, indicating whether the maximum and
root-mean-squared differences fall within the tolerance. If
return_logical = FALSE
, a data frame indicating the variables
compared and the maximum and root-mean-squared differences.
Note
It is assumed that reference
and target
have equal
numbers of rows.
Examples
reference <- data.frame(
a = 1:100, b = 75:174
)
target <- data.frame(
a = 0.001 + (1:100),
b = 76:175
)
test_errors(reference, target, c("a", "b"))
test_errors(reference, target, c("a", "b"), return_logical = FALSE)
Determine weight status from body mass index
Description
Allows users to determine weight status from body mass index (BMI). The
function is designed to classify adult weight status, with default settings
yielding weight classes defined by the Centers for Disease Control and
Prevention (see reference below). Alternatively, the function can be used as
a wrapper for get_BMI_percentile
to obtain classifications for
youth.
Usage
weight_status(BMI = NULL, breaks = c(-Inf, 18.5, 25, 30, 35, 40, Inf),
labels = c("Underweight", "Healthy Weight", "Overweight", "Class 1 Obese",
"Class 2 Obese", "Class 3 Obese"), right = FALSE, youth = FALSE, ...)
#get_BMI_percentile(weight_kg, height_cm, age_yrs = NULL, age_mos = NULL,
#sex = c("Male", "Female"), BMI = NULL, df = NULL,
#output = c("percentile", "classification", "both", "summary"))
Arguments
BMI |
numeric. The participant body mass index |
breaks |
numeric vector. The boundaries for each weight class; passed to
|
labels |
character vector. The labels for each weight class; passed to
|
right |
logical. See |
youth |
logical. Use function as a wrapper for
|
... |
Arguments passed to |
Value
a factor reflecting weight status
References
https://www.cdc.gov/bmi/adult-calculator/bmi-categories.html
Examples
weight_status(17:42)
Calculate energy expenditure using the Weir equation
Description
Calculate energy expenditure using the Weir equation
Usage
weir_equation(VO2, VCO2, epochSecs)
Arguments
VO2 |
Oxygen consumption |
VCO2 |
Carbon dioxide production |
epochSecs |
The averaging window of the metabolic data, in seconds |
Value
numeric scalar indicating predicted energy expenditure from the Weir equation, based on the inputs
References
De V Weir, J. B. (1949). New methods for calculating metabolic rate with special reference to protein metabolism. The Journal of physiology, 109(1-2), 1.
Examples
weir_equation(3.5, 3.1, 60)