TwoRegression-Function: Apply an existing two-regression model

TwoRegression-FunctionR Documentation

Apply an existing two-regression model

Description

Acts as a generic function that dispatches to specific implementation functions (crouter_2006, crouter_2010, crouter_2012, or hibbing_2018)

Usage

TwoRegression(
  AG,
  method = c("Crouter 2006", "Crouter 2010", "Crouter 2012", "Hibbing 2018"),
  verbose = FALSE,
  ...
)

crouter_2006(AG, movement_var, time_var, ...)

crouter_2010(AG, movement_var, time_var, ...)

crouter_2012(AG, movement_var, time_var, model, check = TRUE, ...)

hibbing_2018(
  AG,
  accel_var = "ENMO",
  gyro_var = "GVM",
  direction_var = "Direction",
  time_var = "Timestamp",
  site = c("Hip", "Left Wrist", "Right Wrist", "Left Ankle", "Right Ankle"),
  algorithm = 1:3,
  smooth = FALSE,
  verbose = FALSE,
  ...
)

Arguments

AG

data frame of ActiGraph data

method

character scalar telling which model to apply to the data. Currently supported selections are "Crouter 2006", "Crouter 2010", "Crouter 2012", and "Hibbing 2018". See following subsections

verbose

logical. Print updates to console?

...

arguments passed to the implementation function indicated by method, then further passed to predict.TwoRegression and (when method == "Hibbing 2018") to smooth_2rm as well

movement_var

character scalar. Name of the movement variable (default is "Axis1")

time_var

character scalar. Name of the timestamp variable (required to verify that input epoch length is 10 seconds)

model

character scalar. One of "VA" (for the vertical axis, youth-specific model of Crouter et al., 2012) or "VM" (for the vector magnitude youth-specific model from the same paper)

check

Logical. Should a warning be issued that will prompt you to check that the selected model matches the selected movement variable?

accel_var

Character scalar. Name of accelerometer variable to operate on (expected format is Euclidian Norm Minus One, in milli-gravitational units)

gyro_var

character scalar. Name of gyroscope variable to operate on (expected format is gyroscope vector magnitude, in degrees per second)

direction_var

character scalar. Name of magnetometer variable to operate on (expected format is a vector of directions, likely produced by AGread::classify_magnetometer)

site

character scalar or vector of attachment sites (more than one may be desired, e.g., if results are to be compared from running both of the wrist-specific algorithms)

algorithm

An integer/numeric scalar or vector giving the algorithm(s) to apply to the data from the primary accelerometer and (if applicable) IMU. Must be 1 (accelerometer only), 2 (accelerometer and gyroscope), 3 (accelerometer, gyroscope, and magnetometer), or any combination thereof

smooth

logical. Should data be averaged over a longer time period after processing?

Value

The original data appended with columns giving activity classification (sedentary, ambulatory, or intermittent) and energy expenditure (i.e, METs)

See Also

Crouter et al. (2006, J Appl Physiol) Crouter et al. (2010, Med Sci Sports Exerc) Crouter et al. (2012, Med Sci Sports Exerc) Hibbing et al. (2018, Med Sci Sports Exerc)

apply_two_regression_hibbing18 smooth_2rm

Examples


## Datasets

  data(count_data, package = "TwoRegression")
  data(all_data, package = "TwoRegression")

## Crouter 2006-2012 models

  TwoRegression(
    count_data, "Crouter 2006",
    movement_var = "Axis1", time_var = "time"
  )

  TwoRegression(
    count_data, "Crouter 2010",
    movement_var = "Axis1", time_var = "time"
  )

  TwoRegression(
    count_data, "Crouter 2012", movement_var = "Axis1",
    time_var = "time", model = "VA", check = FALSE
  )

  TwoRegression(
    count_data, "Crouter 2012", movement_var = "Vector.Magnitude",
    time_var = "time", model = "VM", check = FALSE
  )

## Hibbing 2018 models (can be vectorized)

  all_data$ENMO_CV10s <- NULL
  all_data$GVM_CV10s  <- NULL
  all_data$Direction  <- NULL

  result <- TwoRegression(
    all_data, "Hibbing 2018", gyro_var = "Gyroscope_VM_DegPerS",
    direction_var = "mean_magnetometer_direction",
    site = c("Left Ankle", "Right Ankle"), algorithm = 1:2
  )

  utils::head(result)


TwoRegression documentation built on Sept. 5, 2022, 9:07 a.m.