| Title: | Apply Sojourn Methods for Processing ActiGraph Accelerometer Data |
|---|---|
| Description: | Provides a simple way for utilizing Sojourn methods for accelerometer processing, as detailed in Lyden K, Keadle S, Staudenmayer J, & Freedson P (2014) <doi:10.1249/MSS.0b013e3182a42a2d>, Ellingson LD, Schwabacher IJ, Kim Y, Welk GJ, & Cook DB (2016) <doi:10.1249/MSS.0000000000000915>, and Hibbing PR, Ellingson LD, Dixon PM, & Welk GJ (2018) <doi:10.1249/MSS.0000000000001486>. |
| Authors: | Paul R. Hibbing [aut, cre], Kate Lyden [aut], Isaac J. Schwabacher [aut] |
| Maintainer: | Paul R. Hibbing <[email protected]> |
| License: | GPL-3 |
| Version: | 1.2.1 |
| Built: | 2026-05-13 09:01:33 UTC |
| Source: | https://github.com/paulhibbing/sojourn |
Function for using the youth Sojourn method developed by Hibbing et al. (2018)
apply_youth_sojourn( AG, vm = c("Vector.Magnitude", "ENMO"), Site = c("Hip", "Wrist"), demo_interactive = FALSE, verbose = FALSE, ... )apply_youth_sojourn( AG, vm = c("Vector.Magnitude", "ENMO"), Site = c("Hip", "Wrist"), demo_interactive = FALSE, verbose = FALSE, ... )
AG |
a data frame of monitor and demographic data |
vm |
the variable to use for processing, either
|
Site |
the wear location of the monitor, either |
demo_interactive |
logical. Input demographics interactively if missing variables are identified during format checking? |
verbose |
logical. Print processing updates to the console? |
... |
Further arguments passed to |
The original data frame, plus additional predictions made by the Sojourn method
The functions AGread::read_AG_counts and
AGread::read_AG_raw are recommended for assembling the
monitor-specific portion of the AG data frame.
data(example_data, package = "Sojourn") results_youth_soj <- apply_youth_sojourn( AG = example_data, vm = "Vector.Magnitude", Site = "Hip" ) utils::head(results_youth_soj)data(example_data, package = "Sojourn") results_youth_soj <- apply_youth_sojourn( AG = example_data, vm = "Vector.Magnitude", Site = "Hip" ) utils::head(results_youth_soj)
A function to summarize predictions made by the original Sojourn method of Lyden et al. (2014).
compute.bouts.info(est.mets, units = c("secs", "mins"))compute.bouts.info(est.mets, units = c("secs", "mins"))
est.mets |
numeric vector of predicted metabolic equivalents |
units |
time units associated with each row of data |
a data frame summarizing the predictions made by the Sojourn method.
data(example_data, package = "Sojourn") example_data <- soj_3x_original( example_data$axis1, example_data$axis2, example_data$axis3, example_data$Vector.Magnitude ) compute.bouts.info(example_data$METs)data(example_data, package = "Sojourn") example_data <- soj_3x_original( example_data$axis1, example_data$axis2, example_data$axis3, example_data$Vector.Magnitude ) compute.bouts.info(example_data$METs)
Merge data streams for separate monitors in the SIP method
enhance_actigraph(ag, ap, verbose = FALSE)enhance_actigraph(ag, ap, verbose = FALSE)
ag |
ActiGraph data |
ap |
activPAL data |
verbose |
logical. Print information to console? |
data frame of combined ActiGraph and activPAL data
data(SIP_ag, package = "Sojourn") data(SIP_ap, package = "Sojourn") combined_data <- enhance_actigraph(SIP_ag, SIP_ap) utils::head(combined_data)data(SIP_ag, package = "Sojourn") data(SIP_ap, package = "Sojourn") combined_data <- enhance_actigraph(SIP_ag, SIP_ap) utils::head(combined_data)
Sample data for exploring original and youth Sojourn methods
example_dataexample_data
A data frame with 79989 rows and 11 variables:
An example ID for the data set
An example sex for the data set
An example age (in years) for the data set
An example body mass index (in kg/m^2) for the data set
POSIX-formatted variable giving the timestamp for each observation
Activity counts from the first axis
Activity counts from the second axis
Activity counts from the third axis
Vector magnitude of activity counts (sqrt(sum(axis1^2, axis2^2, axis3^2)))
Predicted steps taken
Inclinometer status (0 = off, 1 = lying, 2 = sitting, 3 = standing)
Identify Sojourns using the algorithm of Hibbing et al. (2018)
get_youth_sojourns( vm, short = 30, Output = c("Counts", "Raw"), Site = c("Hip", "Wrist"), epoch = 1, difference = 15, threshold = 100, verbose = FALSE )get_youth_sojourns( vm, short = 30, Output = c("Counts", "Raw"), Site = c("Hip", "Wrist"), epoch = 1, difference = 15, threshold = 100, verbose = FALSE )
vm |
vector of triaxial accelerometer values, either the vector magnitude for activity counts, or the Euclidian Norm Minus One for raw acceleration |
short |
numeric scalar. Shortest allowable duration for a Sojourn. Should be detected automatically from the internally-stored grid search values for the attachment site (hip or wrist) and data type (counts or raw) |
Output |
the data type (counts or raw) |
Site |
the attachment site (hip or wrist) |
epoch |
the epoch length, in seconds |
difference |
the difference parameter |
threshold |
the threshold parameter |
verbose |
logical. Print processing updates to the console? |
A data frame (with nrow equal to length(vm)) that gives
sojourn labels and durations
data(example_data, package = "Sojourn") get_youth_sojourns(example_data$Vector.Magnitude, Output = "Counts", Site = "Hip")data(example_data, package = "Sojourn") get_youth_sojourns(example_data$Vector.Magnitude, Output = "Counts", Site = "Hip")
Interactively input demographic information
input_demographic(...)input_demographic(...)
... |
Further arguments passed to svDialogs functions |
A data frame containing an ID, attachment site of the monitor (hip or wrist), and the participant's sex, age, and BMI
if (interactive()) { input_demographic() }if (interactive()) { input_demographic() }
Read an activPAL events file
read_AP(filename, tz = "UTC")read_AP(filename, tz = "UTC")
filename |
character. Path to the file |
tz |
character. The timezone to use |
Data frame reflecting the data contained in filename.
There must be a corresponding .def file located in the same
directory as filename
ap_file <- system.file( "extdata/sampledata_Events.csv", package = "Sojourn" ) if (isTRUE(requireNamespace("data.table"))) { ap_data <- read_AP(ap_file) utils::head(ap_data) }ap_file <- system.file( "extdata/sampledata_Events.csv", package = "Sojourn" ) if (isTRUE(requireNamespace("data.table"))) { ap_data <- read_AP(ap_file) utils::head(ap_data) }
ActiGraph sample data for exploring Sojourns Including Posture (SIP) method.
SIP_agSIP_ag
A data frame with 12257 rows and 5 variables:
Activity counts from the first axis
Activity counts from the second axis
Activity counts from the third axis
Vector magnitude of activity counts
POSIX-formatted variable giving the timestamp for each observation
activPAL sample data for exploring Sojourns Including Posture (SIP) method
SIP_apSIP_ap
A data frame with 12257 rows and 5 variables:
POSIX-formatted variable giving the timestamp for each observation
Integer value giving the index of the sample from which the row of data is drawn
Duration (in seconds) of the interval from one data point to the next
Integer giving the posture activity classification: 0 is sedentary, 1 is standing, and 2 is stepping
Integer giving the cumulative step count from the start of the file to the current data point.
Numeric giving MET-hours
Calls the uni-axial Sojourn method from Lyden et al. (2014).
soj_1x_original( counts, perc.cut = 0.05, perc.cut.2 = 0.12, perc.cut.3 = 0.55, too.short = 10, sit.cut = 90, long.soj = 120 )soj_1x_original( counts, perc.cut = 0.05, perc.cut.2 = 0.12, perc.cut.3 = 0.55, too.short = 10, sit.cut = 90, long.soj = 120 )
counts |
numeric vector of vertical axis counts |
perc.cut |
decision tree threshold 1 |
perc.cut.2 |
decision tree threshold 2 |
perc.cut.3 |
decision tree threshold 3 |
too.short |
minimum length of one Sojourn |
sit.cut |
cut-point for determining sitting |
long.soj |
maximum length of one Sojourn |
a data frame of processed data
data(example_data, package = "Sojourn") results_1x <- soj_1x_original(example_data$axis1) utils::head(results_1x)data(example_data, package = "Sojourn") results_1x <- soj_1x_original(example_data$axis1) utils::head(results_1x)
Calls the triaxial Sojourn method from Lyden et al. (2014).
soj_3x_original( counts, counts.2, counts.3, vect.mag, short = 30, verbose = FALSE )soj_3x_original( counts, counts.2, counts.3, vect.mag, short = 30, verbose = FALSE )
counts |
numeric vector of activity counts from the first axis |
counts.2 |
numeric vector of activity counts from the second axis |
counts.3 |
numeric vector of activity counts from the third axis |
vect.mag |
vector magnitude of the activity counts |
short |
minimum length of one Sojourn |
verbose |
logical. Print updates to console? |
a data frame of processed data
data(example_data, package = "Sojourn") results_3x <- soj_3x_original( example_data$axis1, example_data$axis2, example_data$axis3, example_data$Vector.Magnitude ) utils::head(results_3x)data(example_data, package = "Sojourn") results_3x <- soj_3x_original( example_data$axis1, example_data$axis2, example_data$axis3, example_data$Vector.Magnitude ) utils::head(results_3x)
The Sojourn package provides a convenient way to apply the family of Sojourn methods published in previous works including Lyden K, Keadle S, Staudenmayer J, & Freedson P (2014) <doi:10.1249/MSS.0b013e3182a42a2d>, Ellingson LD, Schwabacher IJ, Kim Y, Welk GJ, & Cook DB (2016) <doi:10.1249/MSS.0000000000000915>, and Hibbing PR, Ellingson LD, Dixon PM, & Welk GJ (2018) <doi:10.1249/MSS.0000000000001486>.
It is meant for use with data from ActiGraph monitors and (in the case of Sojourns Including Posture, by Ellingson et al. (2016)) activPAL monitors. File reading is not included in the functionality of the Sojourn package. For help with that preliminary step, users are directed to the packages AGread (for ActiGraph files) and activpalProcessing (for activPAL files).
Triaxial Sojourn method for the SIP method
sojourn_3x_SIP(ag, short = 30)sojourn_3x_SIP(ag, short = 30)
ag |
combined ActiGraph and activPAL data on which to identify transitions and make predictions |
short |
the minimum duration of a qualifying Sojourn |
A data frame of processed data using the SIP method
data(SIP_ag, package = "Sojourn") data(SIP_ap, package = "Sojourn") data <- Sojourn::enhance_actigraph(SIP_ag, SIP_ap) utils::head(sojourn_3x_SIP(data))data(SIP_ag, package = "Sojourn") data(SIP_ap, package = "Sojourn") data <- Sojourn::enhance_actigraph(SIP_ag, SIP_ap) utils::head(sojourn_3x_SIP(data))