## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr     1.1.3     ✔ readr     2.1.4
## ✔ forcats   1.0.0     ✔ stringr   1.5.0
## ✔ ggplot2   3.4.3     ✔ tibble    3.2.1
## ✔ lubridate 1.9.2     ✔ tidyr     1.3.0
## ✔ purrr     1.0.2     
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
## 
## Attaching package: 'table1'
## 
## 
## The following objects are masked from 'package:base':
## 
##     units, units<-
## 
## 
## Registered S3 method overwritten by 'GGally':
##   method from   
##   +.gg   ggplot2
## 
## Loading required package: carData
## 
## 
## Attaching package: 'car'
## 
## 
## The following object is masked from 'package:dplyr':
## 
##     recode
## 
## 
## The following object is masked from 'package:purrr':
## 
##     some
## 
## 
## # Attaching packages: easystats 0.6.0 (red = needs update)
## ✔ bayestestR  0.13.1   ✔ correlation 0.8.4 
## ✔ datawizard  0.9.0    ✔ effectsize  0.8.6 
## ✖ insight     0.19.6   ✔ modelbased  0.8.6 
## ✖ performance 0.10.5   ✖ parameters  0.21.2
## ✔ report      0.5.7    ✖ see         0.8.0 
## 
## Restart the R-Session and update packages in red with `easystats::easystats_update()`.
## 
## 
## 
## Attaching package: 'modelsummary'
## 
## 
## The following object is masked from 'package:parameters':
## 
##     supported_models
## 
## 
## The following object is masked from 'package:insight':
## 
##     supported_models

The lab specifications can be found [here]

Exercise 1

Use the table1 package to create a table with appropriate descriptive information about the data set. Use the examples provided in the following vignette to help you build a table.

# Write your code here
natality_table<-natality
natality_table$CIG_REC <- ifelse(natality_table$CIG_REC == "Yes", "Smoker", "Non smoker")
label(natality_table$risks) <- "Risk Factors Reported"
label(natality_table$MRACEHISP) <- "Mother Race/Hispanic Origin"
label(natality_table$DMAR) <- "Marital Status"
label(natality_table$MEDUC) <- "Mother Education"
label(natality_table$PRIORLIVE) <- "Prior births (living)"
label(natality_table$PRIORDEAD) <- "Prior births (dead)"
table1(~ DBWT + risks + MAGER + MRACEHISP + DMAR + MEDUC + PRIORLIVE + PRIORDEAD + BMI | CIG_REC, data=natality_table, overall = F)
Non smoker
(N=1564)
Smoker
(N=124)
Birth Weight (g)
Mean (SD) 3250 (601) 3070 (597)
Median [Min, Max] 3290 [369, 5880] 3090 [630, 4220]
Risk Factors Reported
No 1088 (69.6%) 84 (67.7%)
Yes 476 (30.4%) 40 (32.3%)
Mother Age
Mean (SD) 29.0 (5.79) 27.8 (5.79)
Median [Min, Max] 29.0 [15.0, 49.0] 28.0 [17.0, 42.0]
Mother Race/Hispanic Origin
NH White 844 (54.0%) 94 (75.8%)
NH Black 266 (17.0%) 14 (11.3%)
NH Other 125 (8.0%) 10 (8.1%)
Hispanic 329 (21.0%) 6 (4.8%)
Marital Status
Married 1017 (65.0%) 40 (32.3%)
Unmarried 547 (35.0%) 84 (67.7%)
Mother Education
lower 177 (11.3%) 34 (27.4%)
HS 377 (24.1%) 45 (36.3%)
Some college 437 (27.9%) 37 (29.8%)
Uni 573 (36.6%) 8 (6.5%)
Prior births (living)
0 601 (38.4%) 38 (30.6%)
1 516 (33.0%) 41 (33.1%)
2 265 (16.9%) 17 (13.7%)
3 93 (5.9%) 17 (13.7%)
4+ 89 (5.7%) 11 (8.9%)
Prior births (dead)
0 1551 (99.2%) 123 (99.2%)
1+ 13 (0.8%) 1 (0.8%)
Mother BMI
Mean (SD) 26.9 (6.32) 27.3 (6.42)
Median [Min, Max] 25.6 [15.6, 58.4] 26.3 [16.5, 50.1]

Exercise 2

Use the ggpairs function to explore the association between the different variables. Try to replicate the figure below, or create your own variation.

# Write your code here
natality_figure <- natality[, c(1,3,4,6,10,2,5,7,8,9)]
ggpairs(natality_figure, columns = 1:5, aes(color = CIG_REC), legend = 1,
        columnLabels = c("Birth Weight (g)", "Risks", "Mother Age", "Marital Status", "Mother BMI"),
        upper = list(continuous = wrap("density"), combo = wrap("facethist"), discrete = wrap("colbar")),
        lower = list(continuous = wrap("cor"), combo = wrap("facethist"), discrete = wrap("facetbar")), 
        diag = list(continuous = wrap("densityDiag", alpha = 0.5, color=NA), discrete = wrap("densityDiag"), na = wrap("barDiag"))) +
  theme_minimal() +
  theme(legend.position = 'bottom', legend.direction = "horizontal") +
  labs(fill='Smoking')
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

Exercise 3

Fit four linear models, each nested within the other: the null model, the unadjusted model, the full model and the optimal model. Use the step function find the optimal model using the stepwise method. Then use anova to compare the four models. What is your conclusion? Now compare your models using modelsummary function. What does the number in the (brackets) mean? How can you identify the optimal model just by looking at the \(R^2\) and the AIC?

# Write your code here
Model_Null <- lm(DBWT ~ 1, natality) #Null Model
Model_unadjusted <- lm(DBWT ~ CIG_REC, natality) #Unadjusted Model
Model_Full <- lm(DBWT ~ ., natality) #Full Model
Model_option <- step(Model_Full,
     scope = list(upper = Model_Full),
     direction="both",
     data=natality)
## Start:  AIC=21453.74
## DBWT ~ CIG_REC + risks + MAGER + MRACEHISP + DMAR + MEDUC + PRIORLIVE + 
##     PRIORDEAD + BMI
## 
##             Df Sum of Sq       RSS   AIC
## - MEDUC      3    227681 547644018 21448
## - MAGER      1    506449 547922786 21453
## <none>                   547416336 21454
## - PRIORDEAD  1    971142 548387479 21455
## - CIG_REC    1   2532079 549948416 21460
## - PRIORLIVE  4   6414220 553830557 21465
## - BMI        1   6958800 554375136 21473
## - risks      1   7453843 554870179 21475
## - DMAR       1   9585796 557002132 21481
## - MRACEHISP  3  16306858 563723195 21497
## 
## Step:  AIC=21448.44
## DBWT ~ CIG_REC + risks + MAGER + MRACEHISP + DMAR + PRIORLIVE + 
##     PRIORDEAD + BMI
## 
##             Df Sum of Sq       RSS   AIC
## - MAGER      1    361028 548005046 21448
## <none>                   547644018 21448
## - PRIORDEAD  1    946465 548590483 21449
## + MEDUC      3    227681 547416336 21454
## - CIG_REC    1   2767445 550411463 21455
## - PRIORLIVE  4   6331487 553975505 21460
## - BMI        1   6787528 554431546 21467
## - risks      1   7576696 555220714 21470
## - DMAR       1  11070941 558714959 21480
## - MRACEHISP  3  16567825 564211843 21493
## 
## Step:  AIC=21447.56
## DBWT ~ CIG_REC + risks + MRACEHISP + DMAR + PRIORLIVE + PRIORDEAD + 
##     BMI
## 
##             Df Sum of Sq       RSS   AIC
## <none>                   548005046 21448
## - PRIORDEAD  1    922493 548927539 21448
## + MAGER      1    361028 547644018 21448
## + MEDUC      3     82260 547922786 21453
## - CIG_REC    1   2708955 550714001 21454
## - PRIORLIVE  4   5984714 553989760 21458
## - BMI        1   6749558 554754604 21466
## - risks      1   8234365 556239411 21471
## - DMAR       1  10970232 558975278 21479
## - MRACEHISP  3  16594210 564599256 21492
anova(Model_Null,Model_unadjusted,Model_option,Model_Full)
## Analysis of Variance Table
## 
## Model 1: DBWT ~ 1
## Model 2: DBWT ~ CIG_REC
## Model 3: DBWT ~ CIG_REC + risks + MRACEHISP + DMAR + PRIORLIVE + PRIORDEAD + 
##     BMI
## Model 4: DBWT ~ CIG_REC + risks + MAGER + MRACEHISP + DMAR + MEDUC + PRIORLIVE + 
##     PRIORDEAD + BMI
##   Res.Df       RSS Df Sum of Sq       F    Pr(>F)    
## 1   1687 611839087                                   
## 2   1686 608153901  1   3685187 11.2491 0.0008144 ***
## 3   1675 548005046 11  60148855 16.6914 < 2.2e-16 ***
## 4   1671 547416336  4    588710  0.4493 0.7730024    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
modelsummary(
  list(
    null = Model_Null, 
    unadjasted = Model_unadjusted, 
    optional = Model_option, 
    Full = Model_Full
    ), 
  stars = TRUE
  )
null unadjasted optional Full
(Intercept) 3234.746*** 3247.903*** 3080.559*** 3162.373***
(14.658) (15.187) (64.625) (107.021)
CIG_RECYes -179.096** -160.083** -156.593**
(56.032) (55.632) (56.325)
risksYes -158.808*** -152.902***
(31.655) (32.055)
MRACEHISPNH Black -292.140*** -290.175***
(41.690) (41.829)
MRACEHISPNH Other -121.695* -120.774*
(52.796) (52.960)
MRACEHISPHispanic -74.492+ -72.464+
(38.075) (39.120)
DMARUnmarried -184.275*** -189.782***
(31.823) (35.084)
PRIORLIVE1 130.686*** 140.483***
(33.814) (34.725)
PRIORLIVE2 107.170* 123.385**
(41.746) (43.880)
PRIORLIVE3 138.776* 161.298*
(59.972) (63.149)
PRIORLIVE4+ 131.949* 162.508*
(62.333) (67.562)
PRIORDEAD1+ 258.434+ 265.467+
(153.905) (154.184)
BMI 10.261*** 10.493***
(2.259) (2.277)
MAGER -3.836
(3.085)
MEDUCHS 8.448
(49.909)
MEDUCSome college -0.240
(50.838)
MEDUCUni 31.610
(56.902)
Num.Obs. 1688 1688 1688 1688
R2 0.000 0.006 0.104 0.105
R2 Adj. 0.000 0.005 0.098 0.097
AIC 26401.9 26393.7 26239.9 26246.1
BIC 26412.7 26410.0 26315.9 26343.8
Log.Lik. -13198.942 -13193.843 -13105.946 -13105.039
F 10.217 16.259 12.291
RMSE 602.05 600.23 569.78 569.47
+ p < 0.1, * p < 0.05, ** p < 0.01, *** p < 0.001

Answer: (1) What is your conclusion? The four models were nested, and according to the “Anova” results, I think optional model (model 3) is best. Comparing with model 1,2, and 3, model 2 is better than model 1 significantly, and model 3 is better than model 2 significantly. As for model 3 and model 4, there was no significant different. To keep model as simple as possible, I would like to say model 3 (optional model) is the most proper model among these four models. (2) What does the number in the (brackets) mean? The number in the (brackets) means the standard error for each estimated parameter (3)How can you identify the optimal model just by looking at the R2 and the AIC? For R2, the more R2 means better fitting (better to use asjusted R2 in comparasion. As for AIC, the less AIC means better fitting. In this study, model 3 and model 4 has comparable R2 and AIC, to keep the model simple, I would like to say model 3 is the best fitting model

Exercise 4

Center and scale all the continuous variables, and create a forest plot for the optimal model.

# Write your code here
natality.ctr <- natality |> 
  standardize(two_sd = TRUE) #centeral all variables
Model_option.ctr <- lm(
  DBWT ~ CIG_REC + DMAR + MRACEHISP + BMI + risks + PRIORLIVE + PRIORDEAD, 
  data = natality.ctr
  )
Model_option.ctr %>% 
  model_parameters() %>% 
  plot()

Answer: The dots indicate the estimate parameter, and the lines means its 95% confidence interval. In this plot, “smoked”, “race”,“marital statue” and “risk” (all red dots) have negative effects on children’s birth weight, “Mother’s BMI”, “prior births now living” and “prior births now dead” (all blue dots) have positive effects on children’s birth weight. However, we have to pay attention the 95% confidence interval of “prior births now dead”, because it shows wild range on effect, which means the high standard error. Especially, some part of line is in the negative effect, so we have to consider it when drawing conclusions.

Exercise 5

How do the effect estimate of smoking, the standard error of its estimate, its 95% confidence interval, and its statistical significance change between the un-adjusted, optimal and full models? Please use the centered and scaled models to answer this question.

# Write your code here
Model_unadjusted.ctr <- lm(DBWT ~ CIG_REC, natality.ctr) #centered Unadjusted Model
Model_option.ctr <- lm(DBWT ~ CIG_REC + DMAR + MRACEHISP + BMI + risks + PRIORLIVE + PRIORDEAD, natality.ctr) #centered optional model
Model_Full.ctr <- lm(DBWT ~ ., natality.ctr) #centered full model
tidy_model1 <- tidy(Model_unadjusted.ctr, conf.int = TRUE)
tidy_model2 <- tidy(Model_option.ctr, conf.int = TRUE)
tidy_model3 <- tidy(Model_Full.ctr,conf.int = TRUE)
CIG_model1 <- tidy_model1[tidy_model1$term == "CIG_RECYes", ]
CIG_model2 <- tidy_model2[tidy_model2$term == "CIG_RECYes", ]
CIG_model3 <- tidy_model3[tidy_model3$term == "CIG_RECYes", ]
CIG_model1$term = c("Unadjusted")
CIG_model2$term = c("Optimal")
CIG_model3$term = c("Full")
library(dplyr)
combined_CIG_data <- bind_rows(CIG_model1, CIG_model2, CIG_model3)
combined_CIG_data <- combined_CIG_data %>%
  rename (
    model = term,
    CIG_RECYes = estimate
  )
print(combined_CIG_data)
## # A tibble: 3 × 7
##   model      CIG_RECYes std.error statistic p.value conf.low conf.high
##   <chr>           <dbl>     <dbl>     <dbl>   <dbl>    <dbl>     <dbl>
## 1 Unadjusted     -0.149    0.0465     -3.20 0.00142   -0.240   -0.0575
## 2 Optimal        -0.133    0.0462     -2.88 0.00406   -0.224   -0.0423
## 3 Full           -0.130    0.0468     -2.78 0.00549   -0.222   -0.0383

Answer: [Replace this with your answer]

Exercise 6

Does the association between cigarette smoking during pregnancy and birth weight depend on mother’s education? Modify the FULL model appropriately to be able to answer this question. Use anova to test whether the model with the interaction is significantly better than the one without it. Regardless of statistical significance, create a dumbell plot illustrating the smoking effect at each level of mother’s education and estimate the cigarette smoking effect at each level of mother’s education. Hint: When creating the dataset for plotting, include the value zero for each predictor not included in the interaction (the reference level for all categorical variables). Picking the value zero in a centered predictor is like choosing the mean of that variable, which is a reasonable choice.

# Write your code here
library(marginaleffects)
Model_FULL_int.ctr <- lm(formula = DBWT ~ . + CIG_REC * MEDUC, data = natality.ctr)
anova(Model_Full.ctr,Model_FULL_int.ctr)
## Analysis of Variance Table
## 
## Model 1: DBWT ~ CIG_REC + risks + MAGER + MRACEHISP + DMAR + MEDUC + PRIORLIVE + 
##     PRIORDEAD + BMI
## Model 2: DBWT ~ CIG_REC + risks + MAGER + MRACEHISP + DMAR + MEDUC + PRIORLIVE + 
##     PRIORDEAD + BMI + CIG_REC * MEDUC
##   Res.Df    RSS Df Sum of Sq      F Pr(>F)
## 1   1671 377.34                           
## 2   1668 376.70  3   0.64613 0.9537 0.4138
newdata_1 <- predictions(Model_FULL_int.ctr, 
             newdata = datagrid(
              MRACEHISP = c("NH White", "NH Black", "NH Other", "Hispanic"),
              MEDUC   = c("lower", "HS", "Some college", "Uni"),
              CIG_REC = c("No", "Yes")
              )
            ) |>  as.data.frame() |> 
  mutate(DBWT = estimate)  |> 
  select(DBWT, MRACEHISP, CIG_REC, MEDUC)
newtransdata_1 <- newdata_1 %>%
  group_by(MRACEHISP, MEDUC, CIG_REC) %>%
  summarise(avg_DBWT = mean(DBWT, na.rm = TRUE)) %>%
  pivot_wider(names_from = CIG_REC, values_from = avg_DBWT, 
              names_prefix = "", ) %>%
  rename(`No_smoking` = `No`, `Smoking` = `Yes`)
## `summarise()` has grouped output by 'MRACEHISP', 'MEDUC'. You can override
## using the `.groups` argument.
ggplot(newtransdata_1) +
  geom_segment(
    aes(
      x = "No_smoking", y = No_smoking, 
      xend = "Smoking", yend = Smoking, 
      color = MEDUC
      ),
    linewidth = 1) + 
  facet_wrap(~MRACEHISP) +
  geom_point(
    aes(x = "No_smoking", y = No_smoking, color = MEDUC), 
    size = 3) +
  geom_point(
    aes(x = "Smoking", y = Smoking, color = MEDUC), 
    size = 3
    )

Answer: (1) Use anova to test whether the model with the interaction is significantly better than the one without it. According to our anova result, the interaction model does not reported better fitting significantly. (2)Provide a brief description, interpretation or reflection about what you see in the plot. We have to say that our results are really different with given results. According to our results, for all mother races, smoking always make child’s birth weigh gets lower. However, only from the view, we can also see that for matter mother races, mother with low education level do not report too much declines on birth weight after smoking, but for mother with college education level, birth weigh declines more after smoking.

Exercise 7

Does the association between mother’s BMI and birth-weight differ between mothers of different race/ethnicity? Modify the OPTIMAL model appropriately to be able to answer this question, using the dataset with the centered variables. Use anova to test whether the model with the interaction is significantly better than the one without it. Regardless of statistical significance, estimate the BMI effect at each level of mother’s race/ethnicity and plot the BMI effect at each level of mother’s race/ethnicity using a dumbell plot.

# Write your code here
Model_option_int.ctr <- lm(DBWT ~ CIG_REC + DMAR + MRACEHISP + BMI + risks + PRIORLIVE + PRIORDEAD + BMI * MRACEHISP, data = natality.ctr)
anova(Model_option.ctr,Model_option_int.ctr)
## Analysis of Variance Table
## 
## Model 1: DBWT ~ CIG_REC + DMAR + MRACEHISP + BMI + risks + PRIORLIVE + 
##     PRIORDEAD
## Model 2: DBWT ~ CIG_REC + DMAR + MRACEHISP + BMI + risks + PRIORLIVE + 
##     PRIORDEAD + BMI * MRACEHISP
##   Res.Df    RSS Df Sum of Sq      F Pr(>F)
## 1   1675 377.75                           
## 2   1672 377.04  3   0.71163 1.0519 0.3685
newdata_2 <- data.frame(
  BMI = c(0,2,0,2,0,2,0,2),  
  MRACEHISP   = c("Hispanic", "Hispanic", "NH Black", "NH Black",  "NH Other", "NH Other", "NH White", "NH White") 
  ) |> 
  mutate(
    CIG_REC = "No",
    risks = "No", 
    DMAR = "Married", 
    PRIORLIVE = "0", 
    PRIORDEAD = "0"
    )
newdata_2 |> 
  mutate(
    DBWT = predict(
      Model_option_int.ctr, 
      newdata_2
      )
  ) |> select(BMI, MRACEHISP, DBWT)
##   BMI MRACEHISP         DBWT
## 1   0  Hispanic  0.042158252
## 2   2  Hispanic  0.190671430
## 3   0  NH Black -0.136664894
## 4   2  NH Black  0.002678953
## 5   0  NH Other  0.010786473
## 6   2  NH Other  0.491499237
## 7   0  NH White  0.102843774
## 8   2  NH White  0.342827274
tribble(
  ~Race, ~BMIMean, ~BMIMeanSD, 
  "Hispanic",    0.04215825,  0.190671430, 
  "NH Black",       -0.13666489,  0.002678953, 
  "NH Other",        0.01078647,  0.491499237, 
  "NH White",        0.10284377,  0.342827274
  ) |> ggplot() + 
  geom_segment(
    aes(
      x = "Mean(BMI)", y = BMIMean, 
      xend = "Mean(BMI)+SD(BMI)", yend = BMIMeanSD, 
      color = Race
      ),
    linewidth = 2
    ) + 
  geom_point(
    aes(x = "Mean(BMI)", y = BMIMean, color = Race), 
    size = 6
    ) + 
  geom_point(
    aes(x = "Mean(BMI)+SD(BMI)", y = BMIMeanSD, color = Race), 
    size = 6
    ) +
  labs (y = "Birth weight")

Answer: (1) Use anova to test whether the model with the interaction is significantly better than the one without it. According to our result, the model with intereaction did not report signiticant better model fitting. (2) Provide a brief description, interpretation or reflection about what you see in the plot (e.g., what do you notice? what do you wonder? For all mother races, higher mother’s BMI report higher birth weight. It is interesting that mothers in NH other group are more sensitive. According to this plot, plus one unit BMI, mothers in this group report more birth weigh increase on birth weight, comparing with other 3 groups.

Exercise 8

Does the association between mother’s BMI and birth-weight depend on mother’s age? Modify the FULL model appropriately to be able to answer this question, using the dataset with the centered variables. Use anova to test whether the model with the interaction is significantly better than the one without it. Regardless of statistical significance, estimate the BMI effect for mothers age 20, 30, and 40 years and make a plot illustrating the BMI effect at each of these ages.

# Write your code here
Model_FULL_int.ctr2 <- lm(formula = DBWT ~ . + BMI * MAGER, data = natality.ctr)
anova(Model_Full.ctr,Model_FULL_int.ctr2)
## Analysis of Variance Table
## 
## Model 1: DBWT ~ CIG_REC + risks + MAGER + MRACEHISP + DMAR + MEDUC + PRIORLIVE + 
##     PRIORDEAD + BMI
## Model 2: DBWT ~ CIG_REC + risks + MAGER + MRACEHISP + DMAR + MEDUC + PRIORLIVE + 
##     PRIORDEAD + BMI + BMI * MAGER
##   Res.Df    RSS Df Sum of Sq      F Pr(>F)
## 1   1671 377.34                           
## 2   1670 377.28  1  0.060384 0.2673 0.6052
newdata_3 <- data.frame(
  BMI = c(0,2,0,2,0,2),  
  MAGER   = c(20, 20, 30, 30, 40, 40) 
  ) |> 
  mutate(
    CIG_REC = "No",
    risks = "No",
    MRACEHISP = "NH White", 
    DMAR = "Married",
    MEDUC = "lower",
    PRIORLIVE = "0", 
    PRIORDEAD = "0", 
    )

newdata_3 |> 
  mutate(
    DBWT = predict(
      Model_FULL_int.ctr2, 
      newdata_3
      )
  ) |> select(BMI,MAGER, DBWT)
##   BMI MAGER       DBWT
## 1   0    20 -0.6575681
## 2   2    20 -1.4076355
## 3   0    30 -1.0279007
## 4   2    30 -2.2629360
## 5   0    40 -1.3982333
## 6   2    40 -3.1182366
tribble(
  ~Age, ~BMIMean,~BMIMeanSD, 
  "20",    -0.6575681,-1.4076355, 
  "30",    -1.0279007,-2.2629360, 
  "40",   -1.3982333, -3.1182366
  ) |> ggplot() + 
  geom_segment(
    aes(
      x = "mean(BMI)", y = BMIMean, 
      xend = "mean(BMI)+sd(BMI)", yend = BMIMeanSD, 
      color = Age
      ),
    linewidth = 2
    ) + 
  geom_point(
    aes(x = "mean(BMI)", y = BMIMean, color = Age), 
    size = 6
    ) + 
  geom_point(
    aes(x = "mean(BMI)+sd(BMI)", y = BMIMeanSD, color = Age), 
    size = 6
    )+
  labs (y ="Birth weight")

Answer: (1)Use anova to test whether the model with the interaction is significantly better than the one without it.According to our result, the model with intereaction did not report signiticant better model fitting. (2)Provide a brief description, interpretation or reflection about what you see in the plot (e.g., what do you notice? what do you wonder? Based on our results, we could see that mother in different ages, higher BMI reported less birth weight. However, the decline speed is comparable.