Creates a realistic simulated dataset matching WHO STEPS survey structure. Includes sampling design variables, demographics, and measures from all three steps (behavioural, physical, biochemical).

generate_test_data(n = 3000, seed = 42)

Arguments

n

Number of observations (default 3000).

seed

Random seed for reproducibility (default 42).

Value

A data frame with n rows and the following columns:

  • stratum: Strata identifier (S1-S5)

  • psu: Primary sampling unit (PSU1-PSU40)

  • wt_final: Final analysis weight

  • sex: Sex (1=Male, 2=Female)

  • age: Age in years (18-69)

  • Step 1 (behavioural): t1, t2 (tobacco), a1, a5 (alcohol), met_total (physical activity), d1-d4 (diet)

  • Step 2 (physical): m1 (height), m2 (weight), m3 (waist), b1-b6 (blood pressure), b7 (BP medication)

  • Step 3 (biochemical): c1_mmol (glucose), c5 (DM meds), c6 (cholesterol), c10 (cholesterol meds)

Details

Simulation parameters are realistic for low-middle income settings:

  • Tobacco prevalence: 32% males, 8% females

  • Alcohol current use: 55% males, 28% females

  • Heavy episodic drinking: 35% of drinkers

  • Physical activity: MET-minutes/week, mean 1800, SD 1200

  • Diet: Fruit/veg days and servings per day (0-7, 1-5)

  • BP increases with age; medication prevalence 12%

  • Glucose: mean 5.2 mmol/L, increases with age

  • Total cholesterol: mean 4.8 mmol/L

Use this function for:

  • Testing the STEPS pipeline

  • Developing reports before real data arrives

  • Training analysts on the analysis system

Examples

# \donttest{
  # Generate smaller dataset for quick testing
  test_data <- generate_test_data(n = 500, seed = 123)
#> ✓ Generated test data: 500 rows × 28 columns
  head(test_data)
#>   stratum   psu  wt_final sex age t1 t2 a1 a5 met_total d1 d2 d3 d4    m1    m2
#> 1      S3 PSU10 0.6874298   1  22  0  0  1  1      2092  4  2  5  4 169.0  68.8
#> 2      S3 PSU17 2.2301171   1  60  0  0  1  1      2370  7  3  5  5 171.1 107.0
#> 3      S2  PSU8 1.0531829   2  42  0  0  0  0      1964  1  2  6  1 156.5  77.1
#> 4      S2  PSU3 0.5545674   1  45  1  1  0  0      1214  0  3  5  5 170.6  84.2
#> 5      S3 PSU37 2.0747699   1  38  0  0  1  1      2880  1  3  7  2 166.4  65.4
#> 6      S5 PSU14 1.2173206   2  41  0  0  0  0      3093  4  4  7  4 165.0  47.8
#>      m3  b1 b2  b3  b4  b5 b6 b7 c1_mmol c5  c6 c10
#> 1 102.7  84 65  83  62  82 65  0     6.2  0 5.8   0
#> 2  95.5 108 99 112 101 109 99  0     6.4  0 4.7   0
#> 3  99.6 127 64 127  63 128 64  0     7.0  1 6.1   0
#> 4  90.7 133 74 130  79 129 67  0     5.8  0 4.2   0
#> 5 110.6 111 62 109  63 111 63  0     5.5  0 3.5   0
#> 6  70.0 108 72 110  68 102 64  0     6.4  0 5.6   0
# }