Introduction

In this project I will explore whether depression scores impact a persons overall health. For the statistical modeling I will use ANOVA and Tukey’s testing to compare the means between sample populations. Medical data from Florida, New York, and North Carolina will be used within this analysis to reveal impact of depression on a persons health.


Installed packages:

To begin, I loaded the Tidyverse package to perform my analysis on this assignment. I also loaded the Readxl package to open the spreadsheet files containing the medical data. Next, I set the working directory to a folder that contained both of the medical data files for this assignment. Lastly, I created a dataset titled “medical” that contained all patients in both study groups. Group 1 is patients with a non-conditions and group 2 is patients with arthritis, hypertension, and/or heart ailment.

library(tidyverse)
library(readxl)
setwd("C:/Users/justi/OneDrive/Desktop/Grad School/UTSA 1st semester/STA 6443 Statistical Modeling")
medical <- read_excel("medical.xlsx")

Question 1: Summary Statistics

Use descriptive statistics to summarize the data from the two studies. What are your preliminary observations about the depression scores?

#View Summary Stats
medical |> group_by(state, group) |>
  summarize(mean_score = mean(score))

Observations: My first observation was that the means from medical1 were 5.55, 8, and 7.05, while the means from medical2 were significantly larger being 14.5, 15.25, and 13.95. My second observation was that New York contained the highest levels of depression over North Carolina and New York.

Takeaway: The increase in means shows that patients with arthritis, hypertension, and/or heart ailment have higher depression rates than patients that do not have these conditions. Additionally, new york showed the highest mean scores in both group 1 and 2.


Question 2: ANOVA Testing

Use analysis of variance on both data sets. State the hypotheses being tested in each case. What are your conclusions?

The Hypotheses We test two null hypothesis in this test:

  1. The mean depression score is the same across all states (florida, new york, north carolina).
  2. The mean depression score is the same across all groups (1 and 2)
#Convert key variables to factors for testing
medical$state<-as.factor(medical$state)
medical$group<-as.factor(medical$group)
# Create Boxplot Visuals
library(ggplot2)
ggplot(medical, aes(x = state, y = score, fill = group)) +
      geom_boxplot() +
      labs(title = "medical data",
           x = "state",
           y = "score") +
      theme_minimal()

# Summarize Results
two_way_anova_model <- aov(score ~ state+group, data = medical)
summary(two_way_anova_model)
##              Df Sum Sq Mean Sq F value Pr(>F)    
## state         2     54    27.0   3.025 0.0524 .  
## group         1   1779  1778.7 199.227 <2e-16 ***
## Residuals   116   1036     8.9                   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

ANOVA test Conclusions:

Based off the states p = .0516 value state was not significant to depression score

Based off the groups p = <2e-16 value groups are significant to depression score


Question 3: Tukey’s Test

Use inferences about individual treatment means where appropriate. What are your conclusions?

Tukey’s Test The Tukey’s test will answer the question of “which groups specifically are different from each other?”

# Perform Tukeys
tukeys <- TukeyHSD(two_way_anova_model)
print(tukeys)
##   Tukey multiple comparisons of means
##     95% family-wise confidence level
## 
## Fit: aov(formula = score ~ state + group, data = medical)
## 
## $state
##                           diff         lwr       upr     p adj
## new york-florida         1.600  0.01373707 3.1862629 0.0475483
## north carolina-florida   0.475 -1.11126293 2.0612629 0.7575288
## north carolina-new york -1.125 -2.71126293 0.4612629 0.2157333
## 
## $group
##     diff      lwr      upr p adj
## 2-1  7.7 6.619513 8.780487     0

Tukey test Conclusions: On average New Yorkers score 1.6 points higher than Floridian test subjects. The test revealed that New York and Florida are states that impact a persons overall health, suggesting that other states may contain different scores.

On average North Carolina subjects score .475 points higher than Florida test subjects. The North Carolina-Florida p value = .76~ making north Carolina and Florida insignificant state factors that affect test score.

On average North Carolina subjects score .475 points higher than New Yorkers The north carolina-new york p value = .22~ making North Carolina and new York insignificant state factors that affect test score


Key Takeaways

  1. People with chronic illness have higher levels of depression than people in reasonably good health.

  2. New York patients have a 1.6 score increase over Florida patients in health scores.

We fail to reject the first null hypothesis “The mean depression score is the same across all states (florida, new york, north carolina).” due to the .0524 p value. Meaning we do not have have enough evidence to support state being a factor in major factor in depression score.