You will be analyzing data from the Jackson Heart Study (JHS). You can find the data on Canvas. For full credit, you must include all code chunks and R output backing up your responses.
0. Import the JHS data; you can download it from Canvas. You need to research how to read a SAS data file into R (hint: look into the haven package).
1a. Model systolic blood pressure (sbp; mmHg) as a function of age (age; years), education (HSgrad; 0=no, 1=yes), and health status as defined by body mass index (BMI3cat; 0=poor health, 1=intermediate health, 2=ideal health). Remember to report the resulting model.
#Null hyppothesis = there is not evidence to support a significant regression line
#Alternate hypothesis= there is evidence to support a significant regression line
F Statistic and p-Value
age: f statistic = 328.6472, p value = < 2.2e-16
BMI3cat: f statistic = 18.5846, p value = 1.685e-05
Rejection Region
# Reject null if p < 0.05
Conclusion/Interpretation
# We reject the null hypothesis. There is significant evidence to suggest a significant regression line
1d. Which predictors, if any, are significant predictors of systolic blood pressure? Test at the \(\alpha=0.05\) level. Remember to state your conclusions.
Error in `mutate()`:
ℹ In argument: `outlier = if_else(abs(rstandard(m1)) > 2.5, "Suspected",
"Not Suspected")`.
Caused by error:
! `outlier` must be size 2653 or 1, not 2642.
JHS_data %>%count(outlier)
Error in `count()`:
! Must group by variables found in `.data`.
✖ Column `outlier` is not found.
JHS_data <- JHS_data %>%filter(outlier ==TRUE)
Error in `filter()`:
ℹ In argument: `outlier == TRUE`.
Caused by error:
! object 'outlier' not found
JHS_data %>%count(outlier)
Error in `count()`:
! Must group by variables found in `.data`.
✖ Column `outlier` is not found.
Insert your answer here :)
1g. How many suspected influential/leverage points exist? You must justify your answer statistically. Remember to state your conclusion.
cooks(m1)
There are many spikes in this graph, meaning there are many leverage points...
1h. Is multicollinearity a problem in this model? You must justify your answer statistically. Remember to state your conclusion.
car::vif(m1)
age HSgrad BMI3cat
1.095162 1.094919 1.000371
Since multicollinearity is present if VIF > 10, multicollinearity is not present
1i. Assess the assumptions on the linear model. Remember to draw your conclusion with appropriate justification.
anova_check(m1)
Based on the scatterplot and the qq plot the assumptions are normal.
1j. Construct an appropriate data visualization to help with explaining the model results. Systolic blood pressure should be on the y-axis, age should be on the x-axis. Create lines for BMI (BMI3cat); remember that we will plug in a combination of 0’s and 1’s to represent BMI.
JHS_data %>%ggplot(aes(x = age, y = sbp, color =as.factor(BMI3cat))) +geom_point() +labs(x ="age",y ="sbp",color ="BMI 3 Categories") +theme_bw()
2. Required for graduate students / extra credit for undergraduate students: Write a paragraph to summarize the above analysis, written such that a non-quantitative person could understand. Note - knowledge about medicine/health is not required. I am only looking for you to report results in a digestible manner.
Given the data, age and body mass index are significant predictors of systolic blood pressure. We can also note that a high school diploma is not indicated to be a signifcant predictor of systolic blood pressue. We can also see from the graph that as age increases, blood pressue also rises.
Week 2: Interaction Terms
3a. Model systolic blood pressure (sbp; mmHg) as a function of age (age; years), education (HSgrad; 0=no, 1=yes), and body mass index (BMI; kg/m2), and the following interactions: body mass index \(\times\) age and body mass index \(\times\) education. Remember to report the resulting model.
m3 <-glm(sbp ~ age + HSgrad + BMI + BMI:age + BMI:HSgrad, data = JHS_data) summary(m3)
Call:
glm(formula = sbp ~ age + HSgrad + BMI + BMI:age + BMI:HSgrad,
data = JHS_data)
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 74.749725 7.884470 9.481 < 2e-16 ***
age 0.869644 0.115042 7.559 5.56e-14 ***
HSgrad -2.772950 4.009951 -0.692 0.489301
BMI 0.885513 0.243923 3.630 0.000288 ***
age:BMI -0.013472 0.003571 -3.773 0.000165 ***
HSgrad:BMI 0.055666 0.123568 0.450 0.652393
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
(Dispersion parameter for gaussian family taken to be 211.7859)
Null deviance: 640015 on 2641 degrees of freedom
Residual deviance: 558268 on 2636 degrees of freedom
(11 observations deleted due to missingness)
AIC: 21655
Number of Fisher Scoring iterations: 2
3b. Perform the appropriate hypothesis test to determine if the interaction between body mass index and age is significant. Test at the \(\alpha=0.05\) level. Remember to state your conclusion.
summary(m3)
Call:
glm(formula = sbp ~ age + HSgrad + BMI + BMI:age + BMI:HSgrad,
data = JHS_data)
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 74.749725 7.884470 9.481 < 2e-16 ***
age 0.869644 0.115042 7.559 5.56e-14 ***
HSgrad -2.772950 4.009951 -0.692 0.489301
BMI 0.885513 0.243923 3.630 0.000288 ***
age:BMI -0.013472 0.003571 -3.773 0.000165 ***
HSgrad:BMI 0.055666 0.123568 0.450 0.652393
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
(Dispersion parameter for gaussian family taken to be 211.7859)
Null deviance: 640015 on 2641 degrees of freedom
Residual deviance: 558268 on 2636 degrees of freedom
(11 observations deleted due to missingness)
AIC: 21655
Number of Fisher Scoring iterations: 2
Hypotheses
#Null hyppothesis = there is not interaction between body mass index and age
#Alternate hypothesis= there is evidence to support interaction between body mass index and age
Test Statistic and p-Value
# test statistic = -3.773
# p value = 0.000165
Rejection Region
# Reject null if p < 0.05
Conclusion/Interpretation
# We reject the null hypothesis. There is significant evidence to suggest an interaction between body mass index and age
3c. Perform the appropriate hypothesis test to determine if the interaction between body mass index and education is significant Test at the \(\alpha=0.05\) level. Remember to state your conclusion.
summary(m3)
Call:
glm(formula = sbp ~ age + HSgrad + BMI + BMI:age + BMI:HSgrad,
data = JHS_data)
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 74.749725 7.884470 9.481 < 2e-16 ***
age 0.869644 0.115042 7.559 5.56e-14 ***
HSgrad -2.772950 4.009951 -0.692 0.489301
BMI 0.885513 0.243923 3.630 0.000288 ***
age:BMI -0.013472 0.003571 -3.773 0.000165 ***
HSgrad:BMI 0.055666 0.123568 0.450 0.652393
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
(Dispersion parameter for gaussian family taken to be 211.7859)
Null deviance: 640015 on 2641 degrees of freedom
Residual deviance: 558268 on 2636 degrees of freedom
(11 observations deleted due to missingness)
AIC: 21655
Number of Fisher Scoring iterations: 2
Hypotheses
#Null hyppothesis = there is not interaction between body mass and education
#Alternate hypothesis = there is evidence to support interaction between body mass and education
Test Statistic and p-Value
# test statistic = 0.450
# p value = 0.652393
Rejection Region
# Reject null if p < 0.05
Conclusion/Interpretation
# We do not reject the null hypothesis. There is not enough evidence to suggest an interaction between body mass and education.
3d. Create the following models (i.e., plug in the following values and algebraically simplify): (1) body mass index of 32, and (2) body mass index of 25. Remember to report the resulting simplified models.
sbp = bmi32 + age
sbp = bmi25 + age
74.75=.87age+.89bmi-.01age:BMI
3e. Provide brief interpretations for the slopes of the predictors for the one of the models in 3d (your choice, but make sure you specify which model you are interpreting).
bmi (body mass index) when increased by 25 will also increase systolic blood pressue, but bmi when increased by 32 will increase systolic blood pressue even more.
3f. Construct an appropriate data visualization to help with explaining the model results. Systolic blood pressure should be on the y-axis, age should be on the x-axis, and use the regression lines constructed in 3d to construct predicted values.
JHS_data %>%ggplot(aes(x = age, y = sbp, color =as.factor(BMI3cat))) +geom_point() +labs(x ="Age",y ="Systolic Blood Pressue",color ="Body Mass Index") +theme_bw()
4. Required for graduate students / extra credit for undergraduate students: Write a paragraph to summarize the above analysis, written such that a non-quantitative person could understand. Note - knowledge about medicine/health is not required. I am only looking for you to report results in a digestible manner.
There is significant evidence to support that BMI and Age together is a predictor of SBP (systolic blood pressure). This means that as body mass index and age both increase, there is indication that SBP also increases.