Social indicators of health included in this study are race/ethnicity, age
# load packages
packages <- c('tidyverse','tableone','lmtest','broom','car')
purrr::walk(packages,library,character.only=T)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr 1.1.1 ✔ readr 2.1.4
## ✔ forcats 1.0.0 ✔ stringr 1.5.0
## ✔ ggplot2 3.4.4 ✔ tibble 3.2.1
## ✔ lubridate 1.9.2 ✔ tidyr 1.3.0
## ✔ purrr 1.0.1
## ── 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
## Loading required package: zoo
##
##
## Attaching package: 'zoo'
##
##
## The following objects are masked from 'package:base':
##
## as.Date, as.Date.numeric
##
##
## 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
# load data
MOD_data <- read.csv("C:/Users/Gabby/Desktop/Maternal Mortality/Social_Factors_Influencing_MMR.csv")
race_age <- read.csv("C:/Users/Gabby/Desktop/Maternal Mortality/Summary_MMR_race_age.csv")
## Warning in read.table(file = file, header = header, sep = sep, quote = quote, :
## incomplete final line found by readTableHeader on
## 'C:/Users/Gabby/Desktop/Maternal Mortality/Summary_MMR_race_age.csv'
# transform race_age data
races <- c()
# loop through each of the 13 issues
for (race in race_age$Race.ethnicity)
# replicate 3 times
races <- c(races, rep(race, 3))
age_group <- colnames(race_age[,2:4])
age_group <- rep(age_group, 3)
values <- race_age[2:4]
values <- t(values)
values <- as.vector(values)
cleaned_race_age <- data.frame(races, age_group, values)
colnames(cleaned_race_age)[3] <- "Maternal Mortality Rate"
cleaned_race_age
## races age_group Maternal Mortality Rate
## 1 Black Under.25 26.100
## 2 Black X25.39 53.375
## 3 Black X40.and.over 242.575
## 4 White Under.25 13.000
## 5 White X25.39 18.175
## 6 White X40.and.over 92.725
## 7 Hispanic Under.25 9.475
## 8 Hispanic X25.39 18.650
## 9 Hispanic X40.and.over 86.200
# graph MMR by race and age
library(ggplot2)
library(RColorBrewer)
ggplot(cleaned_race_age, aes(fill = age_group, y = `Maternal Mortality Rate`, x = races)) +
geom_col(position = "dodge") +
scale_fill_manual(values = brewer.pal(n = 3, name = "Paired"),
labels = c("Under 25", "25 - 39", "Over 40")) +
theme(axis.text.x = element_text(angle = 45, margin = margin(t = 30, "pt"))) +
labs(title = "Maternal Mortality by Race/Ethnicity and Age Group",
x = "Race/Ethnicity",
y = "Maternal Mortality Rate",
fill = "Age Group")
## Warning in unit(c(t, r, b, l), unit): NAs introduced by coercion
#################################################
Statistical Analyses of Race/Ethnicity and age versus Maternal Mortality
cleaned_race_age<-cleaned_race_age%>%
rename( "MMR"= "Maternal Mortality Rate")
# ANOVA on MMR vs race/ethnicity and age group
MMR.by.race.age<- aov(MMR~races*age_group,
data = cleaned_race_age)
summary(MMR.by.race.age)
## Df Sum Sq Mean Sq
## races 2 9167 4584
## age_group 2 27841 13920
## races:age_group 4 7452 1863
Interpretation of ANOVA on MMR vs race/ethnicity and age: unfortunately the sample size was too small and no test statistic was returned
# next we attempted multivariate regression
#HO: the model age and ethnicity will not predictive of maternal mortality
#H1: the model that includes race and age is predictive of maternal mortality
mod.mmr<-lm(MMR~races +age_group, data = cleaned_race_age)
mod.mmr
##
## Call:
## lm(formula = MMR ~ races + age_group, data = cleaned_race_age)
##
## Coefficients:
## (Intercept) racesHispanic racesWhite
## 61.29 -69.24 -66.05
## age_groupX25.39 age_groupX40.and.over
## 13.87 124.31
Interpretation of multivariate regression of race/ethnicity and age vs MMR: The F statistic is 4.966, (4, 4) with am overall p value of 0.07. The overall model is not statistically significant, the only group that was statistically significant was age group 40 and over was statistically significant p=0.024. Adjusted r squared was 0.66, which means 66% of the maternal mortality ratio could be explained by age.
# multicollinearity assumption for multiple regression
# VIF for multicollinearity
car::vif(mod = mod.mmr)
## GVIF Df GVIF^(1/(2*Df))
## races 1 2 1
## age_group 1 2 1
Interpretation of multicollinearity: The VIF values are small. This assumption is met.Both predicitor variable are categorical so linearity was not tested.
# Checking the homoscedasticity assumption
# The Breusch-Pagan test was another way to check the assumption.
#HO: the variances are constant
#H1: the variances are not constant
MMR.con.var<-lmtest::bptest(formula=mod.mmr)
MMR.con.var
##
## studentized Breusch-Pagan test
##
## data: mod.mmr
## BP = 7.1913, df = 4, p-value = 0.1261
Interpretation of Breusch-Pagan test: The Breusch-Pagan test statistic has a large p-value (BP = 7.1913; p = 0.1261), indicating that the null hypothesis of constant variance is accepted. This assumptions is met.
# Testing the independence of residuals assumption using Durbin-Watson test ##
# HO:The residuals are independent.
# H1: The residuals are not independent.
lmtest::dwtest(formula = mod.mmr)
##
## Durbin-Watson test
##
## data: mod.mmr
## DW = 1.7586, p-value = 0.2305
## alternative hypothesis: true autocorrelation is greater than 0
Interpretation of Durbin-Watson test: The p value is high, so we retain the null hypothesis and conclude that the residuals are independent.
Checking the independent observations assumption: While there may be some similarities between the age groups, The data was aggregated from all of the states and it is reasonable to conclude that the observations are independent.
# Checking the continuous outcome assumption
# the outcome variable is Maternal Mortality ratio, which is continuous, therefore this assumption is met
# Assumption of Normality of residuals
# will use shapiro wilkes to test for normaility of residual
#HO: the residulas are normally distrubuted
#H1: the residuals are not normally distributed
shapiro.test(mod.mmr$residuals)
##
## Shapiro-Wilk normality test
##
## data: mod.mmr$residuals
## W = 0.89896, p-value = 0.246
Interpretation of Shapiro-Wilk normality test: The p value for the shapiro-wilk test is 0.246, therefore we accept the null hypothesis and conclude the residuals are normally distributed.
In conclusion, when looking at the demographic data for Maternal Morbidity, 2 way Anova was not able to produce any results. We ran multivariate linear regression to see if the model of racial group and age was predictive of Maternal Mortality. Suprisingly the overall model was not statistically significant, F= 4.966 (4, 4), p-value: 0.07486. The only category that appeared to predict maternal morbidity was Age equal to or greater than 40.
The assumptions appear to be met.
Our data appears to be different than what would be expected. When reviewing data from individual states there appeared to be a significant association between race and maternal mortality. It may be the aggregate nature of the data that is influencing our results, as we did not have access to the full data set. Caution should be used in using these results for programming due to the discrepancy between our results and other studies.
# clean MOD_data, removing NA values and looking at only MMR and median household income per state
median_income_MMR <- MOD_data %>%
select(State, MMR..per.100.000.live.births., Median.Household.Income) %>%
na.omit()
# remove commas in csv
median_income_MMR$Median.Household.Income <- as.numeric(gsub("[^0-9.]", "", median_income_MMR$Median.Household.Income))
median_income_MMR
## State MMR..per.100.000.live.births. Median.Household.Income
## 1 Alabama 41.1 51771
## 2 Alaska 25.8 77203
## 3 Arizona 31.4 62027
## 4 Arkansas 43.5 49020
## 5 California 10.1 80423
## 6 Colorado 15.2 77104
## 7 Connecticut 16.7 78920
## 9 Florida 26.3 59198
## 10 Georgia 33.9 61950
## 11 Hawaii 18.4 83734
## 12 Idaho 18.3 60830
## 13 Illinois 17.3 69212
## 14 Indiana 31.1 57617
## 15 Iowa 20.2 61807
## 16 Kansas 22.0 62028
## 17 Kentucky 38.4 52256
## 18 Louisiana 39.0 51108
## 20 Maryland 21.2 86644
## 21 Massachusetts 15.3 85700
## 22 Michigan 19.4 59522
## 23 Minnesota 12.6 74529
## 24 Mississippi 43.0 45928
## 25 Missouri 25.7 57375
## 26 Montana 29.1 57248
## 27 Nebraska 26.2 63290
## 28 Nevada 21.7 63268
## 30 New Jersey 25.7 85786
## 31 New Mexico 30.2 52021
## 32 New York 21.7 72038
## 33 North Carolina 26.5 57388
## 34 North Dakota 24.2 67402
## 35 Ohio 23.8 58704
## 36 Oklahoma 30.3 54447
## 37 Oregon 16.4 66955
## 38 Pennsylvania 16.7 63455
## 40 South Carolina 32.7 56360
## 41 South Dakota 28.5 60414
## 42 Tennessee 41.7 56047
## 43 Texas 28.1 64044
## 44 Utah 16.1 75705
## 46 Virginia 29.1 76471
## 47 Washington 20.4 78674
## 48 West Virginia 25.4 48659
## 49 Wisconsin 11.6 64177
## 51 US Average 23.5 NA
# graph MMR versus median household income per state
ggplot(median_income_MMR, aes(x = Median.Household.Income, y = MMR..per.100.000.live.births.)) +
geom_point(aes(size = "State"), color = "#7463AC", alpha = 0.7) +
labs(x = "Median Household Income", y = "Maternal Mortality Rate (per 100,000 live births)") +
ggtitle("Maternal Mortality Rate vs. Median Household Income") + geom_smooth(aes(linetype = "Linear fit line"), method = "lm",
se = FALSE, color = "gray60") +
theme_minimal() +
scale_x_continuous(name = 'Median Household Income', limits = c(45000, 90000), breaks = seq(45000, 90000, by = 5000))
## Warning: Using size for a discrete variable is not advised.
## `geom_smooth()` using formula = 'y ~ x'
## Warning: Removed 1 rows containing non-finite values (`stat_smooth()`).
## Warning: Removed 1 rows containing missing values (`geom_point()`).
Statistical Analyses on Median Household Income versus Maternal Mortality Rate
# ANOVA on MMR vs median income
aov_result <- aov(MMR..per.100.000.live.births. ~ Median.Household.Income, data = median_income_MMR)
aov_result
## Call:
## aov(formula = MMR..per.100.000.live.births. ~ Median.Household.Income,
## data = median_income_MMR)
##
## Terms:
## Median.Household.Income Residuals
## Sum of Squares 1442.314 1775.773
## Deg. of Freedom 1 42
##
## Residual standard error: 6.502331
## Estimated effects may be unbalanced
## 1 observation deleted due to missingness
Interpretation of ANOVA: This test failed to meet the assumptions of ANOVA, as indicated by the high residual error and warning that estimated effects may be unbalanced.
# Calculate confidence interval
conf_interval <- confint(aov_result, "Median.Household.Income", level = 0.95)
conf_interval
## 2.5 % 97.5 %
## Median.Household.Income -0.0007035427 -0.0003422102
Interpretation of confidence interval: The values of -0.0007035427 for the lower bound of 2.5% and -0.0003422102 for the upper bound of 97.5% indicates that there is a statistically significant negative correlation between median household income and maternal mortality rate.
# linear regression of median household income to maternal mortality rate
mmr_income_linear_regression <- lm(formula = MMR..per.100.000.live.births. ~ Median.Household.Income,
data = median_income_MMR, na.action = na.exclude)
summary(object = mmr_income_linear_regression)
##
## Call:
## lm(formula = MMR..per.100.000.live.births. ~ Median.Household.Income,
## data = median_income_MMR, na.action = na.exclude)
##
## Residuals:
## Min 1Q Median 3Q Max
## -13.9659 -4.6431 0.0407 5.1826 11.8831
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 5.912e+01 5.878e+00 10.058 9.42e-13 ***
## Median.Household.Income -5.229e-04 8.952e-05 -5.841 6.73e-07 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 6.502 on 42 degrees of freedom
## (1 observation deleted due to missingness)
## Multiple R-squared: 0.4482, Adjusted R-squared: 0.4351
## F-statistic: 34.11 on 1 and 42 DF, p-value: 6.732e-07
Interpretation of linear regression (Median household income vs MMR): It appears there is a very strong correlation between a state’s maternal mortality rate and its median household income (p < 0.001).
In conclusion, it appears that there is a strong negative correlation between maternal mortality rate per state, and that state’s median household income. Very small p values indicate this correlation is statistically significant.