Skip to content

Commit e624cab

Browse files
committed
More updates to Unit 02
1 parent 3b4ab63 commit e624cab

1 file changed

Lines changed: 12 additions & 12 deletions

File tree

vignettes/Unit02_BMIvDXA.Rmd

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -643,17 +643,17 @@ We can see that the *labeled* subset does *not* include any `"60+"` observations
643643

644644
```{r}
645645
# Recode age
646-
NHANES <- NHANES |>
646+
NHANES2 <- NHANES |>
647647
mutate(Age_recode = fct_collapse(Age, `40+` = c("40-59", "60+")))
648648
649649
# Split NHANES into labeled (DXA available) vs unlabeled
650-
labeled <- NHANES |> filter(Cohort == "2017-2018")
651-
unlabeled <- NHANES |> filter(Cohort == "2021-2023")
650+
labeled2 <- NHANES2 |> filter(Cohort == "2017-2018")
651+
unlabeled2 <- NHANES2 |> filter(Cohort == "2021-2023")
652652
653653
# Stack for IPD
654-
combined <- bind_rows(
655-
labeled |> mutate(set_label = "labeled"),
656-
unlabeled |> mutate(set_label = "unlabeled")
654+
combined2 <- bind_rows(
655+
labeled2 |> mutate(set_label = "labeled"),
656+
unlabeled2 |> mutate(set_label = "unlabeled")
657657
)
658658
```
659659

@@ -666,16 +666,16 @@ ipd_bmi_fit <- ipd(
666666
formula = obese_DXA - obese_BMI ~ Age_recode + Sex + Race,
667667
method = "pspa",
668668
model = "logistic",
669-
data = combined,
669+
data = combined2,
670670
label = "set_label"
671671
)
672672
673673
ipd_wc_fit <- ipd(
674674
formula = obese_DXA - obese_WC ~ Age_recode + Sex + Race,
675675
method = "pspa",
676676
model = "logistic",
677-
data = labeled,
678-
unlabeled_data = unlabeled
677+
data = labeled2,
678+
unlabeled_data = unlabeled2
679679
)
680680
681681
# Collect results using the tidy() method
@@ -690,19 +690,19 @@ ipd_wc_df <- tidy(ipd_wc_fit) |>
690690
# Rerun previous models
691691
# Naive on unlabeled using BMI
692692
naive_bmi_fit <- glm(obese_BMI ~ Age_recode + Sex + Race,
693-
family = binomial, data = unlabeled)
693+
family = binomial, data = unlabeled)2
694694
naive_bmi_df <- broom::tidy(naive_bmi_fit) |>
695695
mutate(method = "Naive (BMI)")
696696
697697
# Naive on unlabeled using WC
698698
naive_wc_fit <- glm(obese_WC ~ Age_recode + Sex + Race,
699-
family = binomial, data = unlabeled)
699+
family = binomial, data = unlabeled2)
700700
naive_wc_df <- broom::tidy(naive_wc_fit) |>
701701
mutate(method = "Naive (WC)")
702702
703703
# Classical on labeled using DXA
704704
class_fit <- glm(obese_DXA ~ Age_recode + Sex + Race,
705-
family = binomial, data = labeled)
705+
family = binomial, data = labeled2)
706706
class_df <- broom::tidy(class_fit) |>
707707
mutate(method = "Classical (DXA)")
708708

0 commit comments

Comments
 (0)