Calculates prevalence of raised blood pressure and mean systolic and diastolic blood pressure from a survey design object.
compute_bp_indicators(design)A survey design object from setup_survey_design().
A named list of survey estimates. Each element contains estimates (as tibble with columns: estimate, lower, upper, etc.) for:
raised_bp_total: raised blood pressure, overall
raised_bp_by_sex: raised blood pressure, by sex
raised_bp_by_age: raised blood pressure, by age group
mean_sbp_mean_total: mean systolic BP, overall
mean_sbp_mean_by_sex: mean systolic BP, by sex
mean_sbp_mean_by_age: mean systolic BP, by age group
mean_dbp_mean_total: mean diastolic BP, overall
mean_dbp_mean_by_sex: mean diastolic BP, by sex
mean_dbp_mean_by_age: mean diastolic BP, by age group
(if the corresponding variables exist in design)
# \donttest{
test_data <- generate_test_data(n = 500, seed = 42)
#> ✓ Generated test data: 500 rows × 28 columns
cols <- detect_steps_columns(test_data)
#> Detecting STEPS columns...
#> ✓ Age: 'age'
#> ✓ Sex: 'sex'
#> ⚠ Could not auto-detect column for: Age range group
#> ⚠ Could not auto-detect column for: Valid/consent flag
#> ⚠ Could not auto-detect column for: Urban/rural
#> ✓ Weight Step 1 (behavioural): 'wt_final'
#> ⚠ Could not auto-detect column for: Weight Step 2 (physical)
#> ⚠ Could not auto-detect column for: Weight Step 3 (biochemical)
#> ✓ Stratum: 'stratum'
#> ✓ PSU: 'psu'
#> ✓ Current tobacco use: 't1'
#> ✓ Daily tobacco use: 't2'
#> ⚠ Could not auto-detect column for: Age started smoking
#> ⚠ Could not auto-detect column for: Smoking duration
#> ⚠ Could not auto-detect column for: Manufactured cigarettes/day
#> ⚠ Could not auto-detect column for: Manufactured cigarettes/week
#> ⚠ Could not auto-detect column for: Hand-rolled cigarettes/day
#> ⚠ Could not auto-detect column for: Pipes/day
#> ⚠ Could not auto-detect column for: Cigars/day
#> ⚠ Could not auto-detect column for: Shisha/day
#> ⚠ Could not auto-detect column for: Quit attempt past 12m
#> ⚠ Could not auto-detect column for: Advised to quit by HCP
#> ⚠ Could not auto-detect column for: Past smoking
#> ⚠ Could not auto-detect column for: Past daily smoking
#> ⚠ Could not auto-detect column for: Quitting age
#> ⚠ Could not auto-detect column for: Duration since quitting
#> ⚠ Could not auto-detect column for: Current smokeless tobacco
#> ⚠ Could not auto-detect column for: Daily smokeless tobacco
#> ⚠ Could not auto-detect column for: Snuff mouth/day
#> ⚠ Could not auto-detect column for: Chewing tobacco/day
#> ⚠ Could not auto-detect column for: Betel quid/day
#> ⚠ Could not auto-detect column for: Past smokeless tobacco
#> ⚠ Could not auto-detect column for: Past daily smokeless
#> ⚠ Could not auto-detect column for: Second-hand smoke at home
#> ⚠ Could not auto-detect column for: Second-hand smoke at workplace
#> ⚠ Could not auto-detect column for: Any tobacco product
#> → Skipped 'a1' for Ever consumed alcohol (label '' does not match)
#> ⚠ Could not auto-detect column for: Ever consumed alcohol
#> ⚠ Could not auto-detect column for: Alcohol past 12 months
#> → Skipped 'a5' for Current alcohol use (past 30 days) (label '' does not match)
#> → Skipped 'a1' for Current alcohol use (past 30 days) (label '' does not match)
#> ⚠ Could not auto-detect column for: Current alcohol use (past 30 days)
#> ⚠ Could not auto-detect column for: Heavy episodic drinking
#> ⚠ Could not auto-detect column for: Stopped drinking
#> ⚠ Could not auto-detect column for: Alcohol frequency (past 12m)
#> ⚠ Could not auto-detect column for: Drinking occasions (past 30d)
#> ⚠ Could not auto-detect column for: Drinks per occasion
#> ⚠ Could not auto-detect column for: Largest drinks on one occasion
#> ⚠ Could not auto-detect column for: Times with 6+ drinks
#> ⚠ Could not auto-detect column for: Alcohol 7-day frequency
#> ⚠ Could not auto-detect column for: Homebrew consumption
#> ⚠ Could not auto-detect column for: Drinking level category
#> ✓ Total MET minutes: 'met_total'
#> ⚠ Could not auto-detect column for: Vigorous work activity
#> ⚠ Could not auto-detect column for: Moderate work activity
#> ⚠ Could not auto-detect column for: Walk/bicycle transport
#> ⚠ Could not auto-detect column for: Vigorous recreational activity
#> ⚠ Could not auto-detect column for: Moderate recreational activity
#> ⚠ Could not auto-detect column for: Sedentary behaviour
#> ✓ Fruit days/week: 'd1'
#> ✓ Fruit servings/day: 'd2'
#> ✓ Vegetable days/week: 'd3'
#> ✓ Vegetable servings/day: 'd4'
#> ⚠ Could not auto-detect column for: Salt added at table
#> ⚠ Could not auto-detect column for: Salt added in cooking
#> ⚠ Could not auto-detect column for: Processed food high in salt
#> ⚠ Could not auto-detect column for: Perceived salt intake
#> ⚠ Could not auto-detect column for: Importance of lowering salt
#> ⚠ Could not auto-detect column for: Knowledge of salt effects
#> ⚠ Could not auto-detect column for: Limit processed food for salt
#> ⚠ Could not auto-detect column for: Check salt labels
#> ⚠ Could not auto-detect column for: Buy low-salt alternatives
#> ⚠ Could not auto-detect column for: Use spices instead of salt
#> ⚠ Could not auto-detect column for: Avoid food outside home
#> ⚠ Could not auto-detect column for: Other salt control action
#> ⚠ Could not auto-detect column for: Type of cooking oil/fat
#> ⚠ Could not auto-detect column for: Meals outside home per week
#> ⚠ Could not auto-detect column for: Vigorous work days/week
#> ⚠ Could not auto-detect column for: Vigorous work hours
#> ⚠ Could not auto-detect column for: Vigorous work minutes
#> ⚠ Could not auto-detect column for: Moderate work days/week
#> ⚠ Could not auto-detect column for: Moderate work hours
#> ⚠ Could not auto-detect column for: Moderate work minutes
#> ⚠ Could not auto-detect column for: Transport days/week
#> ⚠ Could not auto-detect column for: Transport hours
#> ⚠ Could not auto-detect column for: Transport minutes
#> ⚠ Could not auto-detect column for: Vigorous recreation days/week
#> ⚠ Could not auto-detect column for: Vigorous recreation hours
#> ⚠ Could not auto-detect column for: Vigorous recreation minutes
#> ⚠ Could not auto-detect column for: Moderate recreation days/week
#> ⚠ Could not auto-detect column for: Moderate recreation hours
#> ⚠ Could not auto-detect column for: Moderate recreation minutes
#> ⚠ Could not auto-detect column for: Sedentary hours
#> ⚠ Could not auto-detect column for: Sedentary minutes
#> ⚠ Could not auto-detect column for: BP ever measured
#> ⚠ Could not auto-detect column for: Ever diagnosed raised BP
#> ⚠ Could not auto-detect column for: BP diagnosed past 12m
#> ⚠ Could not auto-detect column for: Traditional healer for BP
#> ⚠ Could not auto-detect column for: Herbal remedy for BP
#> ⚠ Could not auto-detect column for: Blood sugar ever measured
#> ⚠ Could not auto-detect column for: Ever diagnosed diabetes
#> ⚠ Could not auto-detect column for: DM diagnosed past 12m
#> ⚠ Could not auto-detect column for: Currently on insulin
#> ⚠ Could not auto-detect column for: Traditional healer for DM
#> ⚠ Could not auto-detect column for: Herbal remedy for DM
#> ⚠ Could not auto-detect column for: Cholesterol ever measured
#> ⚠ Could not auto-detect column for: Ever diagnosed raised cholesterol
#> ⚠ Could not auto-detect column for: Chol diagnosed past 12m
#> ⚠ Could not auto-detect column for: Traditional healer for chol
#> ⚠ Could not auto-detect column for: Herbal remedy for chol
#> ⚠ Could not auto-detect column for: CVD history (heart attack/stroke)
#> ⚠ Could not auto-detect column for: Currently taking aspirin
#> ⚠ Could not auto-detect column for: Currently taking statins
#> ⚠ Could not auto-detect column for: Advised: quit tobacco
#> ⚠ Could not auto-detect column for: Advised: reduce salt
#> ⚠ Could not auto-detect column for: Advised: eat fruit/veg
#> ⚠ Could not auto-detect column for: Advised: reduce fat
#> ⚠ Could not auto-detect column for: Advised: more PA
#> ⚠ Could not auto-detect column for: Advised: healthy weight
#> ⚠ Could not auto-detect column for: Cervical cancer screening
#> ⚠ Could not auto-detect column for: Education years
#> ✓ Highest education level: 'c5'
#> ✓ Ethnicity/Caste: 'c6'
#> ⚠ Could not auto-detect column for: Marital status
#> ⚠ Could not auto-detect column for: Employment status
#> ⚠ Could not auto-detect column for: Household income
#> ✓ Height (cm): 'm1'
#> ✓ Weight (kg): 'm2'
#> ✓ Waist circumference (cm): 'm3'
#> ⚠ Could not auto-detect column for: Hip circumference (cm)
#> ✓ SBP reading 1: 'b1'
#> ✓ SBP reading 2: 'b3'
#> ✓ SBP reading 3: 'b5'
#> ✓ DBP reading 1: 'b2'
#> ✓ DBP reading 2: 'b4'
#> ✓ DBP reading 3: 'b6'
#> ✓ BP medications: 'b7'
#> ⚠ Could not auto-detect column for: Pregnancy status
#> ⚠ Could not auto-detect column for: Heart rate reading 1
#> ⚠ Could not auto-detect column for: Heart rate reading 2
#> ⚠ Could not auto-detect column for: Heart rate reading 3
#> ⚠ Could not auto-detect column for: Mean heart rate
#> ✓ Fasting blood glucose: 'b5'
#> ⚠ Could not auto-detect column for: Random blood glucose
#> ✓ Fasting status: 'b1'
#> ✓ Diabetes medications: 'b6'
#> ✓ Total cholesterol: 'c6'
#> ⚠ Could not auto-detect column for: HDL cholesterol
#> ⚠ Could not auto-detect column for: Triglycerides
#> ✓ Cholesterol medications: 'c10'
#> → 29/147 columns detected automatically
clean <- clean_steps_data(test_data, cols)
#> ⚠ No Step 2 weight found - copying Step 1 weight
#> ⚠ No Step 3 weight found - copying Step 1 weight
#> ✓ GPAQ special codes (77/88/99) cleaned, values capped at valid ranges
#> ✓ GPAQ screening questions used to set non-active domains to 0
#> ✓ Diet special codes (77/88) cleaned; zero-days → 0 servings
#> ✓ Cleaning complete. Final dataset: 500 rows x 64 columns
design <- setup_survey_design(clean)
#> Setting up survey designs (per WHO STEPS Step)...
#> Design: Stratified cluster sampling with weights
#> → Unweighted n = 500
#> → Weighted N (Step 1) = 753
#> Survey design created
bp_results <- compute_bp_indicators(design)
#> Computing blood pressure indicators...
# }