Loaded Dataset

main_data <- read.csv("analytic_data2025_v3.csv")

texas_data <- subset(main_data, State.Abbreviation == "TX")

texas_data <- subset(texas_data, County.FIPS.Code != "000")

dim(texas_data)
## [1] 254 796
regression_data <- texas_data[, c(
  "Poor.or.Fair.Health.raw.value",
  "Uninsured.Adults.raw.value",
  "Adult.Smoking.raw.value",
  "Physical.Inactivity.raw.value"
)]

regression_data[] <- lapply(regression_data, as.numeric)

summary(regression_data)
##  Poor.or.Fair.Health.raw.value Uninsured.Adults.raw.value
##  Min.   :0.1240                Min.   :0.03226           
##  1st Qu.:0.2050                1st Qu.:0.20192           
##  Median :0.2280                Median :0.23041           
##  Mean   :0.2355                Mean   :0.23303           
##  3rd Qu.:0.2605                3rd Qu.:0.26161           
##  Max.   :0.4650                Max.   :0.40732           
##  Adult.Smoking.raw.value Physical.Inactivity.raw.value
##  Min.   :0.0880          Min.   :0.1740               
##  1st Qu.:0.1590          1st Qu.:0.2690               
##  Median :0.1735          Median :0.2945               
##  Mean   :0.1729          Mean   :0.2998               
##  3rd Qu.:0.1900          3rd Qu.:0.3275               
##  Max.   :0.2770          Max.   :0.4730
colSums(is.na(regression_data))
## Poor.or.Fair.Health.raw.value    Uninsured.Adults.raw.value 
##                             0                             0 
##       Adult.Smoking.raw.value Physical.Inactivity.raw.value 
##                             0                             0
model <- lm(Poor.or.Fair.Health.raw.value ~
              Uninsured.Adults.raw.value +
              Adult.Smoking.raw.value +
              Physical.Inactivity.raw.value,
            data = regression_data)

summary(model)
## 
## Call:
## lm(formula = Poor.or.Fair.Health.raw.value ~ Uninsured.Adults.raw.value + 
##     Adult.Smoking.raw.value + Physical.Inactivity.raw.value, 
##     data = regression_data)
## 
## Residuals:
##       Min        1Q    Median        3Q       Max 
## -0.034625 -0.004883 -0.000005  0.004159  0.055372 
## 
## Coefficients:
##                                Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                   -0.064917   0.004292 -15.124   <2e-16 ***
## Uninsured.Adults.raw.value     0.024624   0.015490   1.590    0.113    
## Adult.Smoking.raw.value       -0.024330   0.030491  -0.798    0.426    
## Physical.Inactivity.raw.value  0.997175   0.018611  53.579   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.009619 on 250 degrees of freedom
## Multiple R-squared:  0.9674, Adjusted R-squared:  0.967 
## F-statistic:  2474 on 3 and 250 DF,  p-value: < 2.2e-16
library(lmtest)
## Warning: package 'lmtest' was built under R version 4.6.2
## Loading required package: zoo
## 
## Attaching package: 'zoo'
## The following objects are masked from 'package:base':
## 
##     as.Date, as.Date.numeric
library(car)
## Warning: package 'car' was built under R version 4.6.2
## Loading required package: carData
plot(model, which = 1)

raintest(model)
## 
##  Rainbow test
## 
## data:  model
## Rain = 0.73068, df1 = 127, df2 = 123, p-value = 0.9599

When examining the assumption of linearity, I first used a Residuals vs. Fitted plot to visually examine the distribution of the residuals. Although most of the residuals were scattered around the zero line, there was a slight curve in the red trend line, suggesting a potential violation of linearity. To further examine this assumption, I conducted a Rainbow test, which resulted in a p-value of 0.9599. Since the p-value was greater than the significance level of 0.05, I failed to reject the null hypothesis. Based on these findings, I believe my model meets the assumption of lineariy.

Independence of errors (durbin-watson)

dwtest(model, alternative = "two.sided")
## 
##  Durbin-Watson test
## 
## data:  model
## DW = 1.8658, p-value = 0.2803
## alternative hypothesis: true autocorrelation is not 0

so to help examine the assumption of independence of errors, I conducted a Durbin-Watson test to determine whether there was autocorrelation between the residuals in the order of the observations. The results showed a Durbin-Watson statistic of 1.8658 and a p-value of 0.2803. Since the statistic was relatively close to 2 and the p-value was greater than the significance level of 0.05, I failed to reject the null hypothesis. Based on these findings, my model reasonably meets the assumption of independence of errors, although potential geographical dependence between Texas counties cannot be ruled out by this test alone

plot(model, which = 3)

bptest(model)
## 
##  studentized Breusch-Pagan test
## 
## data:  model
## BP = 13.634, df = 3, p-value = 0.003449

examine the assumption of homoscedasticity, I first used a Scale-Location plot to visually examine whether the residuals had a constant variance. When examining the plot, I noticed that the red trend line was not completely horizontal and that the residuals were not consistently distributed across the fitted values. To further examine this assumption, I conducted a Breusch-Pagan test, which resulted in a p-value of 0.003449. Since the p-value was less than the significance level of 0.05, I rejected the null hypothesis. Based on these findings, my regression model violates the assumption of homoscedasticity, indicating that heteroscedasticity is present within the model. :(

Normality of Residuals

plot(model, which = 2)

shapiro.test(residuals(model))
## 
##  Shapiro-Wilk normality test
## 
## data:  residuals(model)
## W = 0.91085, p-value = 3.69e-11

the assumption of normality of residuals, I first used a Q-Q plot to visually examine whether the residuals followed a normal distribution. When examining the plot, I noticed that although most of the observations in the middle followed the diagonal reference line, several observations at both ends deviated from the line. To further examine this assumption, I conducted a Shapiro-Wilk test, which resulted in a p-value of 3.69e-11. Since the p-value was less than the significance level of 0.05, I rejected the null hypothesis. Based on both the visual representation and the statistical test, my regression model violates the assumption of normality of residuals :(

vif(model)
##    Uninsured.Adults.raw.value       Adult.Smoking.raw.value 
##                      1.751465                      1.719119 
## Physical.Inactivity.raw.value 
##                      2.542717
cor(regression_data[, c(
  "Uninsured.Adults.raw.value",
  "Adult.Smoking.raw.value",
  "Physical.Inactivity.raw.value"
)], use = "complete.obs")
##                               Uninsured.Adults.raw.value
## Uninsured.Adults.raw.value                     1.0000000
## Adult.Smoking.raw.value                        0.3913166
## Physical.Inactivity.raw.value                  0.6537844
##                               Adult.Smoking.raw.value
## Uninsured.Adults.raw.value                  0.3913166
## Adult.Smoking.raw.value                     1.0000000
## Physical.Inactivity.raw.value               0.6454930
##                               Physical.Inactivity.raw.value
## Uninsured.Adults.raw.value                        0.6537844
## Adult.Smoking.raw.value                           0.6454930
## Physical.Inactivity.raw.value                     1.0000000

assumption of multicollinearity, I first used the Variance Inflation Factor (VIF) to determine whether there were strong relationships among my independent variables. My results showed VIF values of 1.7515 for uninsured adults, 1.7191 for adult smoking, and 2.5427 for physical inactivity. Since all three values were below 5, there was no indication of excessive multicollinearity. To further examine this assumption, I created a correlation matrix to examine the strength of the relationships between my independent variables. Although there were positive relationships between the variables, none of the correlations exceeded 0.80. Based on both findings, I believe that my regression model reasonably meets the assumption of no excessive multicollinearity.

MY FINDINGS

After examining all five assumptions of multiple linear regression, I found that my regression model reasonably meets three of the five assumptions. My model meets the assumptions of linearity, independence of errors in the observation order, and no excessive multicollinearity. However, based on the findings of the Breusch-Pagan test and the Shapiro-Wilk test, my model violates the assumptions of homoscedasticity and normality of residuals. Although these violations do not necessarily mean that my regression model cannot be used, it is important to consider mitigation techniques that may improve the reliability of my statistical findings.

library(sandwich)
## Warning: package 'sandwich' was built under R version 4.6.2
coeftest(model, vcov. = vcovHC(model, type = "HC3"))
## 
## t test of coefficients:
## 
##                                 Estimate Std. Error t value  Pr(>|t|)    
## (Intercept)                   -0.0649172  0.0083755 -7.7509 2.296e-13 ***
## Uninsured.Adults.raw.value     0.0246242  0.0205254  1.1997    0.2314    
## Adult.Smoking.raw.value       -0.0243297  0.0445200 -0.5465    0.5852    
## Physical.Inactivity.raw.value  0.9971745  0.0172529 57.7976 < 2.2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

To mitigate the violation of homoscedasticity, I used heteroscedasticity-robust standard errors to account for the unequal variance within my regression model. After applying this technique, I noticed that although the regression coefficients remained the same, there were changes in the standard errors and p-values. The p-value for uninsured adults increased from 0.113 to 0.2314, while the p-value for adult smoking increased from 0.426 to 0.5852. However, physical inactivity remained statistically significant. Overall, applying robust standard errors did not change my original conclusions regarding which independent variables were statistically significant, but it helped improve the reliability of my statistical inference in the presence of heteroscedasticit

Mitigation 2: Nonnormality of Residuals

plot(model, which = 4)

cooks_d <- cooks.distance(model)

which(cooks_d > 4 / nobs(model))
## 2586 2588 2610 2622 2629 2650 2662 2687 2694 2702 2709 2710 2730 2806 2819 2824 
##    7    9   31   43   50   71   83  108  115  123  130  131  151  227  240  245 
## 2825 
##  246
influential <- which(cooks_d > 4 / nobs(model))

adjusted_data <- model.frame(model)[-influential, ]

dim(adjusted_data)
## [1] 237   4
adjusted_model <- lm(
  Poor.or.Fair.Health.raw.value ~
    Uninsured.Adults.raw.value +
    Adult.Smoking.raw.value +
    Physical.Inactivity.raw.value,
  data = adjusted_data
)

summary(adjusted_model)
## 
## Call:
## lm(formula = Poor.or.Fair.Health.raw.value ~ Uninsured.Adults.raw.value + 
##     Adult.Smoking.raw.value + Physical.Inactivity.raw.value, 
##     data = adjusted_data)
## 
## Residuals:
##        Min         1Q     Median         3Q        Max 
## -0.0295299 -0.0043674  0.0003021  0.0044331  0.0239578 
## 
## Coefficients:
##                                Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                   -0.063530   0.003542 -17.936   <2e-16 ***
## Uninsured.Adults.raw.value     0.016432   0.012456   1.319    0.188    
## Adult.Smoking.raw.value        0.006021   0.023890   0.252    0.801    
## Physical.Inactivity.raw.value  0.978740   0.013832  70.758   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.006837 on 233 degrees of freedom
## Multiple R-squared:  0.9796, Adjusted R-squared:  0.9793 
## F-statistic:  3722 on 3 and 233 DF,  p-value: < 2.2e-16
plot(adjusted_model, which = 2)

shapiro.test(residuals(adjusted_model))
## 
##  Shapiro-Wilk normality test
## 
## data:  residuals(adjusted_model)
## W = 0.985, p-value = 0.01343

Based on the findings, I identified 17 potentially influential observations and temporarily removed them to conduct a sensitivity analysis. This reduced my dataset from 254 observations to 237 observations. After creating an adjusted regression model, I conducted another Shapiro-Wilk test and created another Q-Q plot to examine whether the normality of the residuals had improved. The Shapiro-Wilk statistic increased from 0.91085 to 0.985, while the p-value increased from 3.69e-11 to 0.01343. Although the p-value remained below the significance level of 0.05, the visual representation showed improvements in the distribution of the residuals. Additionally, temporarily removing these observations did not change which independent variables were statistically significant. Overall, this mitigation technique improved the normality of the residuals but did not completely resolve the violation.

Final Notes: xamining the five assumptions of multiple linear regression, I found that my regression model reasonably met three of the five assumptions while violating the assumptions of homoscedasticity and normality of residuals. To address these violations, I used heteroscedasticity-robust standard errors and conducted a sensitivity analysis by temporarily removing potentially influential observations. Although these techniques helped address unequal variance in statistical inference and improve the distribution of the residuals, they did not completely resolve the violations. However, the overall conclusions regarding which independent variables were statistically significant remained consistent across the analyses. For the purpose of my research, I would retain the original 254 county-level observations and use robust standard errors while acknowledging the limitations of my regression model.