Skip to contents

Compute the standard CARWatch saliva response feature set

Usage

compute_features(
  data,
  saliva_type = "cortisol",
  group_levels = NULL,
  sample_level = NULL,
  sample_times = NULL,
  slope_pairs = NULL,
  remove_s0 = FALSE
)

Arguments

data

Saliva data or canonical results.

saliva_type

Measurement column name(s).

group_levels

Grouping column names.

sample_level

Sample-position column name.

sample_times

Sampling-time vector or column name.

slope_pairs

Sample pairs for slopes.

remove_s0

Whether to remove baseline sample S0.

Value

Group-level response features.

Examples

curve <- tibble::tibble(
  participant = "P01", sample = paste0("S", 1:4),
  time_min = c(0, 30, 45, 60), cortisol = c(5, 9, 8, 7)
)
compute_features(
  curve,
  group_levels = "participant",
  sample_level = "sample",
  sample_times = "time_min"
)
#> # A tibble: 1 × 7
#>   participant cortisol_auc_g cortisol_auc_i cortisol_ini_val cortisol_max_val
#>   <chr>                <dbl>          <dbl>            <dbl>            <dbl>
#> 1 P01                    450            150                5                9
#> # ℹ 2 more variables: cortisol_max_inc <dbl>, cortisol_slope14 <dbl>