library(janitor)
library(naniar)
library(easystats)
library(tidyverse)
NHANES Codebook
In support of Labs for 432
R Packages and Setup
<- read_rds("https://github.com/THOMASELOVE/432-data/raw/refs/heads/master/data/nh_1500.Rds")
nh_1500 <- read_rds("https://github.com/THOMASELOVE/432-data/raw/refs/heads/master/data/nh_3143.Rds") nh_3143
The nh_1500
and nh_3143
data
These data are drawn from NHANES in the 2013-14, 2015-16 and 2017-18 cycles. I’ve removed observations with missing data, and adjusted the names and some details for the selected variables listed below.
The data set I generated from this work yielded 1500 + 3143 = 4643 observations, which I have partitioned into one sample called nh_1500
and another called nh_3143
. Each of the 4643 observations appears in exactly one of the two files. Each file contains the following set of 30 variables.
Variable Descriptions
My Variable | NHANES Name | Description | Source |
---|---|---|---|
SEQN |
SEQN | Subject ID code | all files |
sex |
RIAGENDR | sex (Male or Female) | DEMO |
age |
RIDAGEYR | age in years | DEMO |
race_eth |
RIDRETH1 | race/ethnicity (4 levels) | DEMO |
educ |
DMDEDUC2 | educational attainment (4 levels) | DEMO |
marital |
DMDMARTL | marital status (4 levels) | DEMO |
hh_size |
DMDHHSIZ | household size (1-6 people) | DEMO |
inc_pov |
INDFMPIR | income divided by poverty level (capped at 5) | DEMO |
wtint2yr |
WTINT2YR | sampling weight for interview questions | DEMO |
wtmec2yr |
WTMEC2YR | sampling weight for medical examination | DEMO |
weight |
BMXWT | weight in kilograms | Exam: BMX |
height |
BMXHT | standing height in centimeters | Exam: BMX |
waist |
BMXWAIST | waist circumference in centimeters | Exam: BMX |
pulse |
BPXPLS | 60-second heart rate (30-sec rate * 2) | Exam: BPX |
sbp1 |
BPXSY1 | (First) Systolic BP, in mm Hg | Exam: BPX |
dbp1 |
BPXDI1 | (First) Diastolic BP, in mm Hg | Exam: BPX |
sbp3 |
BPXSY3 | (Third) Systolic BP, in mm Hg | Exam: BPX |
dbp3 |
BPXDI3 | (Third) Diastolic BP, in mm Hg | Exam: BPX |
bun |
LBXSBU | Serum Blood Urea Nitrogen (mg/dl) | Lab: BIOPRO |
scr |
LBXSCR | Serum Creatinine (mg/dl) | Lab: BIOPRO |
glucose |
LBXSGL | Serum Glucose (mg/dl) | Lab: BIOPRO |
iron |
LBXSIR | Serum Iron (ug/dl) | Lab: BIOPRO |
bili |
LBXSTB | Serum Bilirubin (mg/dl) | Lab: BIOPRO |
uric |
LBXSUA | Uric acid (mg/dl) | Lab: BIOPRO |
wbc |
LBXWBCSI | White blood cell count (1000 cells/uL) | Lab: CBC_J |
rbc |
LBXRBCSI | Red blood cell count (1000 cells/uL) | Lab: CBC_J |
platelet |
LBXPLTSI | Platelet count (1000 cells/uL) | Lab: CBC_J |
health |
HSD010 | Self-reported overall health (E, VG, G, F, P) | Ques.: HSQ |
smk100 |
SMQ020 | Smoked at least 100 cigarettes in your life? (Yes/No) | Ques.: SMQ |
limited |
PFQ051 | Limited in the kind or amount of work you can do by a physical/mental/emotional problem? (Yes/No) | Ques.: PFQ |
Numerical Summaries for nh_1500
dim(nh_1500)
[1] 1500 30
data_codebook(nh_1500)
nh_1500 (1500 rows and 30 variables, 30 shown)
ID | Name | Type | Missings | Values | N
---+----------+-------------+----------+-------------------+-------------
1 | SEQN | character | 0 (0.0%) | 100055 | 1 ( 0.1%)
| | | | 100056 | 1 ( 0.1%)
| | | | 100105 | 1 ( 0.1%)
| | | | 100115 | 1 ( 0.1%)
| | | | 100123 | 1 ( 0.1%)
| | | | 100137 | 1 ( 0.1%)
| | | | 100172 | 1 ( 0.1%)
| | | | 100180 | 1 ( 0.1%)
| | | | 100190 | 1 ( 0.1%)
| | | | 100212 | 1 ( 0.1%)
| | | | (...) |
---+----------+-------------+----------+-------------------+-------------
2 | sex | categorical | 0 (0.0%) | Male | 732 (48.8%)
| | | | Female | 768 (51.2%)
---+----------+-------------+----------+-------------------+-------------
3 | age | numeric | 0 (0.0%) | [30, 59] | 1500
---+----------+-------------+----------+-------------------+-------------
4 | race_eth | categorical | 0 (0.0%) | NH_White | 645 (43.0%)
| | | | NH_Black | 334 (22.3%)
| | | | NH_Other | 296 (19.7%)
| | | | Hispanic | 225 (15.0%)
---+----------+-------------+----------+-------------------+-------------
5 | educ | categorical | 0 (0.0%) | Non_Grad | 167 (11.1%)
| | | | HS_Grad | 302 (20.1%)
| | | | Some_Coll | 545 (36.3%)
| | | | Coll_Grad | 486 (32.4%)
---+----------+-------------+----------+-------------------+-------------
6 | marital | categorical | 0 (0.0%) | Married | 885 (59.0%)
| | | | Former | 274 (18.3%)
| | | | Never | 236 (15.7%)
| | | | Partner | 105 ( 7.0%)
---+----------+-------------+----------+-------------------+-------------
7 | hh_size | numeric | 0 (0.0%) | [1, 6] | 1500
---+----------+-------------+----------+-------------------+-------------
8 | inc_pov | numeric | 0 (0.0%) | [0.13, 5] | 1500
---+----------+-------------+----------+-------------------+-------------
9 | wtint2yr | numeric | 0 (0.0%) | [5019.48, 407301] | 1500
---+----------+-------------+----------+-------------------+-------------
10 | wtmec2yr | numeric | 0 (0.0%) | [5374.38, 407801] | 1500
---+----------+-------------+----------+-------------------+-------------
11 | weight | numeric | 0 (0.0%) | [32.8, 185] | 1500
---+----------+-------------+----------+-------------------+-------------
12 | height | numeric | 0 (0.0%) | [141.9, 199.4] | 1500
---+----------+-------------+----------+-------------------+-------------
13 | waist | numeric | 0 (0.0%) | [55.5, 165] | 1500
---+----------+-------------+----------+-------------------+-------------
14 | pulse | numeric | 0 (0.0%) | [40, 140] | 1500
---+----------+-------------+----------+-------------------+-------------
15 | sbp1 | numeric | 0 (0.0%) | [86, 218] | 1500
---+----------+-------------+----------+-------------------+-------------
16 | dbp1 | numeric | 0 (0.0%) | [44, 120] | 1500
---+----------+-------------+----------+-------------------+-------------
17 | sbp3 | numeric | 0 (0.0%) | [82, 214] | 1500
---+----------+-------------+----------+-------------------+-------------
18 | dbp3 | numeric | 0 (0.0%) | [26, 114] | 1500
---+----------+-------------+----------+-------------------+-------------
19 | bun | numeric | 0 (0.0%) | [3, 73] | 1500
---+----------+-------------+----------+-------------------+-------------
20 | scr | numeric | 0 (0.0%) | [0.35, 12.74] | 1500
---+----------+-------------+----------+-------------------+-------------
21 | glucose | numeric | 0 (0.0%) | [55, 501] | 1500
---+----------+-------------+----------+-------------------+-------------
22 | iron | numeric | 0 (0.0%) | [9, 325] | 1500
---+----------+-------------+----------+-------------------+-------------
23 | bili | numeric | 0 (0.0%) | [0, 7.1] | 1500
---+----------+-------------+----------+-------------------+-------------
24 | uric | numeric | 0 (0.0%) | [0.8, 12.4] | 1500
---+----------+-------------+----------+-------------------+-------------
25 | wbc | numeric | 0 (0.0%) | [2.5, 22.8] | 1500
---+----------+-------------+----------+-------------------+-------------
26 | rbc | numeric | 0 (0.0%) | [2.89, 6.75] | 1500
---+----------+-------------+----------+-------------------+-------------
27 | platelet | numeric | 0 (0.0%) | [54, 583] | 1500
---+----------+-------------+----------+-------------------+-------------
28 | health | categorical | 0 (0.0%) | Excellent | 138 ( 9.2%)
| | | | V_Good | 404 (26.9%)
| | | | Good | 646 (43.1%)
| | | | Fair | 264 (17.6%)
| | | | Poor | 48 ( 3.2%)
---+----------+-------------+----------+-------------------+-------------
29 | smk100 | categorical | 0 (0.0%) | Yes | 671 (44.7%)
| | | | No | 829 (55.3%)
---+----------+-------------+----------+-------------------+-------------
30 | limited | categorical | 0 (0.0%) | Yes | 286 (19.1%)
| | | | No | 1214 (80.9%)
-------------------------------------------------------------------------
Numerical Summaries for nh_3143
dim(nh_3143)
[1] 3143 30
data_codebook(nh_3143)
nh_3143 (3143 rows and 30 variables, 30 shown)
ID | Name | Type | Missings | Values | N
---+----------+-------------+----------+-------------------+-------------
1 | SEQN | character | 0 (0.0%) | 100001 | 1 ( 0.0%)
| | | | 100016 | 1 ( 0.0%)
| | | | 100024 | 1 ( 0.0%)
| | | | 100025 | 1 ( 0.0%)
| | | | 100037 | 1 ( 0.0%)
| | | | 100046 | 1 ( 0.0%)
| | | | 100072 | 1 ( 0.0%)
| | | | 100087 | 1 ( 0.0%)
| | | | 100099 | 1 ( 0.0%)
| | | | 100100 | 1 ( 0.0%)
| | | | (...) |
---+----------+-------------+----------+-------------------+-------------
2 | sex | categorical | 0 (0.0%) | Male | 1504 (47.9%)
| | | | Female | 1639 (52.1%)
---+----------+-------------+----------+-------------------+-------------
3 | age | numeric | 0 (0.0%) | [30, 59] | 3143
---+----------+-------------+----------+-------------------+-------------
4 | race_eth | categorical | 0 (0.0%) | NH_White | 1367 (43.5%)
| | | | NH_Black | 685 (21.8%)
| | | | NH_Other | 627 (19.9%)
| | | | Hispanic | 464 (14.8%)
---+----------+-------------+----------+-------------------+-------------
5 | educ | categorical | 0 (0.0%) | Non_Grad | 366 (11.6%)
| | | | HS_Grad | 658 (20.9%)
| | | | Some_Coll | 1078 (34.3%)
| | | | Coll_Grad | 1041 (33.1%)
---+----------+-------------+----------+-------------------+-------------
6 | marital | categorical | 0 (0.0%) | Married | 1825 (58.1%)
| | | | Former | 580 (18.5%)
| | | | Never | 460 (14.6%)
| | | | Partner | 278 ( 8.8%)
---+----------+-------------+----------+-------------------+-------------
7 | hh_size | numeric | 0 (0.0%) | [1, 6] | 3143
---+----------+-------------+----------+-------------------+-------------
8 | inc_pov | numeric | 0 (0.0%) | [0.11, 5] | 3143
---+----------+-------------+----------+-------------------+-------------
9 | wtint2yr | numeric | 0 (0.0%) | [5356.64, 433085] | 3143
---+----------+-------------+----------+-------------------+-------------
10 | wtmec2yr | numeric | 0 (0.0%) | [5454.01, 419057] | 3143
---+----------+-------------+----------+-------------------+-------------
11 | weight | numeric | 0 (0.0%) | [40.3, 207.2] | 3143
---+----------+-------------+----------+-------------------+-------------
12 | height | numeric | 0 (0.0%) | [140.1, 202.7] | 3143
---+----------+-------------+----------+-------------------+-------------
13 | waist | numeric | 0 (0.0%) | [63.2, 177.9] | 3143
---+----------+-------------+----------+-------------------+-------------
14 | pulse | numeric | 0 (0.0%) | [42, 120] | 3143
---+----------+-------------+----------+-------------------+-------------
15 | sbp1 | numeric | 0 (0.0%) | [74, 236] | 3143
---+----------+-------------+----------+-------------------+-------------
16 | dbp1 | numeric | 0 (0.0%) | [34, 124] | 3143
---+----------+-------------+----------+-------------------+-------------
17 | sbp3 | numeric | 0 (0.0%) | [74, 218] | 3143
---+----------+-------------+----------+-------------------+-------------
18 | dbp3 | numeric | 0 (0.0%) | [30, 126] | 3143
---+----------+-------------+----------+-------------------+-------------
19 | bun | numeric | 0 (0.0%) | [2, 73] | 3143
---+----------+-------------+----------+-------------------+-------------
20 | scr | numeric | 0 (0.0%) | [0.3, 16.64] | 3143
---+----------+-------------+----------+-------------------+-------------
21 | glucose | numeric | 0 (0.0%) | [19, 521] | 3143
---+----------+-------------+----------+-------------------+-------------
22 | iron | numeric | 0 (0.0%) | [7, 476] | 3143
---+----------+-------------+----------+-------------------+-------------
23 | bili | numeric | 0 (0.0%) | [0, 3.3] | 3143
---+----------+-------------+----------+-------------------+-------------
24 | uric | numeric | 0 (0.0%) | [0.7, 18] | 3143
---+----------+-------------+----------+-------------------+-------------
25 | wbc | numeric | 0 (0.0%) | [2.3, 31.4] | 3143
---+----------+-------------+----------+-------------------+-------------
26 | rbc | numeric | 0 (0.0%) | [2.79, 7.14] | 3143
---+----------+-------------+----------+-------------------+-------------
27 | platelet | numeric | 0 (0.0%) | [36, 777] | 3143
---+----------+-------------+----------+-------------------+-------------
28 | health | categorical | 0 (0.0%) | Excellent | 337 (10.7%)
| | | | V_Good | 886 (28.2%)
| | | | Good | 1299 (41.3%)
| | | | Fair | 529 (16.8%)
| | | | Poor | 92 ( 2.9%)
---+----------+-------------+----------+-------------------+-------------
29 | smk100 | categorical | 0 (0.0%) | Yes | 1351 (43.0%)
| | | | No | 1792 (57.0%)
---+----------+-------------+----------+-------------------+-------------
30 | limited | categorical | 0 (0.0%) | Yes | 563 (17.9%)
| | | | No | 2580 (82.1%)
-------------------------------------------------------------------------