Scope
Compute the Metabolic Syndrome Severity Score (MetSSS) using sex- and race-specific coefficients, with configurable NA/extreme handling and plausibility diagnostics.
When to use
- You have waist, blood pressure, fasting lipids/glucose, sex, and race and want a continuous MetS severity score.
- You need built-in NA policies, high-missingness warnings, and optional extreme-value scanning/capping.
- You are okay with a single parameter key (race/sex) applied to all rows—matching the original implementation.
Inputs
-
data: data.frame/tibble withwaist(cm),bp_sys/bp_dia(mmHg),TG/HDL_c/glucose(mmol/L),sex(1=male, 2=female),racein {NHW, NHB, HW, HA} or accepted synonyms. -
params: named list keyed byRACE_SEX(e.g.,NHW_M), each withinterceptand component vectors (waist,TG,HDL,glucose,MAP) containingmean,sd,coef. -
na_action:keep(default) propagates NA;omitdrops rows missing required inputs;erroraborts;ignore/warnact like keep (warnalso adds high-missingness warnings viana_warn_prop). -
check_extreme: set TRUE to scan inputs;extreme_action(warn/cap/error/ignore/NA) controls handling. Defaults (cm, mmHg, mmol/L): waist 40–200; bp_sys 60–300; bp_dia 30–200; TG 0–20; HDL_c 0–5; glucose 0–40. Override withextreme_rules. -
diagnostics: if TRUE (default), warns on implausible ranges and invalid sex/race encodings. -
verbose: log progress and summary.
Quick start
library(HealthMarkers)
library(tibble)
mets <- tibble::tibble(
waist = c(95, 108),
bp_sys = c(120, 138),
bp_dia = c(80, 86),
TG = c(1.5, 2.1),
HDL_c = c(1.2, 0.9),
glucose = c(5.5, 6.2),
sex = c(1, 1),
race = c("NHW", "NHW")
)
metss(
data = mets,
params = list(
NHW_M = list(
intercept = -2.344,
waist = c(mean = 94.0, sd = 12.4, coef = 0.846),
TG = c(mean = 1.5, sd = 0.6, coef = 0.701),
HDL = c(mean = 1.1, sd = 0.3, coef = -0.663),
glucose = c(mean = 5.3, sd = 0.6, coef = 0.658),
MAP = c(mean = 97, sd = 11, coef = 0.466)
)
),
na_action = "keep"
)
#> # A tibble: 2 × 1
#> MetSSS
#> <dbl>
#> 1 -2.43
#> 2 1.01Screen extremes and cap
extreme <- mets
extreme$TG[2] <- 25 # high TG
extreme$bp_sys[1] <- 400 # out of range
metss(
data = extreme,
params = list(
NHW_M = list(
intercept = -2.344,
waist = c(mean = 94.0, sd = 12.4, coef = 0.846),
TG = c(mean = 1.5, sd = 0.6, coef = 0.701),
HDL = c(mean = 1.1, sd = 0.3, coef = -0.663),
glucose = c(mean = 5.3, sd = 0.6, coef = 0.658),
MAP = c(mean = 97, sd = 11, coef = 0.466)
)
),
na_action = "warn",
check_extreme = TRUE,
extreme_action = "cap",
diagnostics = TRUE,
verbose = TRUE
)
#> # A tibble: 2 × 1
#> MetSSS
#> <dbl>
#> 1 0.109
#> 2 21.9Missing data policy
missing <- mets
missing$HDL_c[1] <- NA
metss(
data = missing,
params = list(
NHW_M = list(
intercept = -2.344,
waist = c(mean = 94.0, sd = 12.4, coef = 0.846),
TG = c(mean = 1.5, sd = 0.6, coef = 0.701),
HDL = c(mean = 1.1, sd = 0.3, coef = -0.663),
glucose = c(mean = 5.3, sd = 0.6, coef = 0.658),
MAP = c(mean = 97, sd = 11, coef = 0.466)
)
),
na_action = "omit"
)
#> # A tibble: 1 × 1
#> MetSSS
#> <dbl>
#> 1 1.01
metss(
data = missing,
params = list(
NHW_M = list(
intercept = -2.344,
waist = c(mean = 94.0, sd = 12.4, coef = 0.846),
TG = c(mean = 1.5, sd = 0.6, coef = 0.701),
HDL = c(mean = 1.1, sd = 0.3, coef = -0.663),
glucose = c(mean = 5.3, sd = 0.6, coef = 0.658),
MAP = c(mean = 97, sd = 11, coef = 0.466)
)
),
na_action = "warn"
)
#> # A tibble: 2 × 1
#> MetSSS
#> <dbl>
#> 1 NA
#> 2 1.01Outputs and expectations
- Returns a tibble with
MetSSSusing a single race/sex key derived from the first row (warns if multiple keys present). -
na_action = "omit"drops rows missing required inputs; otherwise missing inputs propagateNAintoMetSSS. - Extreme handling can cap/NA/warn/error; diagnostics run independently and can still warn after capping.
Verbose diagnostics
old_opt <- options(healthmarkers.verbose = "inform")
metss(
data = mets,
params = list(
NHW_M = list(
intercept = -2.344,
waist = c(mean = 94.0, sd = 12.4, coef = 0.846),
TG = c(mean = 1.5, sd = 0.6, coef = 0.701),
HDL = c(mean = 1.1, sd = 0.3, coef = -0.663),
glucose = c(mean = 5.3, sd = 0.6, coef = 0.658),
MAP = c(mean = 97, sd = 11, coef = 0.466)
)
),
verbose = TRUE
)
#> metss(): preparing inputs
#> metss(): column map: waist -> 'waist', bp_sys -> 'bp_sys', bp_dia -> 'bp_dia', TG -> 'TG', HDL_c -> 'HDL_c', glucose -> 'glucose', sex -> 'sex', race -> 'race'
#> metss(): results: MetSSS 2/2
#> # A tibble: 2 × 1
#> MetSSS
#> <dbl>
#> 1 -2.43
#> 2 1.01
options(old_opt)Tips
- Confirm sex encoded as 1/2 and race matches a
paramskey; only the first-row key is used. - Keep units consistent (waist cm, BP mmHg, lipids/glucose mmol/L); no unit conversion occurs here.
- Tighten
extreme_rulesto your cohort before usingextreme_action = "cap"or"error". - Leave
diagnostics = TRUEduring QA to catch implausible ranges; silence only if needed for tests.