library(tidyverse)
library(pastecs)
texas_data <- read.csv("health_data.csv")
texas_data <- texas_data %>%
rename(poor_fair_health = v002_rawvalue) %>%
filter(!is.na(poor_fair_health))
nrow(texas_data)
## [1] 254
summary(texas_data$poor_fair_health)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.1240 0.2050 0.2280 0.2355 0.2605 0.4650
Descriptive Statistics
pastecs::stat.desc(
texas_data$poor_fair_health,
basic = TRUE,
norm = TRUE
)
## nbr.val nbr.null nbr.na min max range
## 2.540000e+02 0.000000e+00 0.000000e+00 1.240000e-01 4.650000e-01 3.410000e-01
## sum median mean SE.mean CI.mean.0.95 var
## 5.982400e+01 2.280000e-01 2.355276e-01 3.323644e-03 6.545534e-03 2.805839e-03
## std.dev coef.var skewness skew.2SE kurtosis kurt.2SE
## 5.297017e-02 2.249001e-01 1.046050e+00 3.422999e+00 1.900678e+00 3.121685e+00
## normtest.W normtest.p
## 9.418762e-01 1.726970e-08
The descriptive statistics show that the average percentage of adults reporting poor or fair health across the 254 Texas counties is approximately 23.55%, with a median of 22.80%. The percentages range from 12.40% to 46.50%. The standard deviation is approximately 5.30 percentage points. The skewness value of 1.046 indicates that the distribution is positively skewed, meaning some counties have much higher percentages than others. These findings suggest that poor or fair health is not distributed evenly across Texas counties.
ggplot(texas_data, aes(x = poor_fair_health)) +
geom_histogram(
bins = 20,
fill = "steelblue",
color = "black"
) +
labs(
title = "Distribution of Poor or Fair Health Across Texas Counties",
x = "Proportion Reporting Poor or Fair Health",
y = "Number of Counties"
) +
theme_minimal()
texas_data <- texas_data %>%
mutate(sqrt_poor_fair_health = sqrt(poor_fair_health))
pastecs::stat.desc(
texas_data$sqrt_poor_fair_health,
basic = TRUE,
norm = TRUE
)
## nbr.val nbr.null nbr.na min max range
## 2.540000e+02 0.000000e+00 0.000000e+00 3.521363e-01 6.819091e-01 3.297727e-01
## sum median mean SE.mean CI.mean.0.95 var
## 1.225385e+02 4.774935e-01 4.824349e-01 3.317271e-03 6.532983e-03 2.795088e-03
## std.dev coef.var skewness skew.2SE kurtosis kurt.2SE
## 5.286860e-02 1.095870e-01 6.297117e-01 2.060611e+00 9.761837e-01 1.603290e+00
## normtest.W normtest.p
## 9.728749e-01 9.121332e-05
ggplot(texas_data, aes(x = sqrt_poor_fair_health)) +
geom_histogram(
bins = 20,
fill = "mediumpurple",
color = "black"
) +
labs(
title = "Square Root Transformation of Poor or Fair Health",
x = "Square Root of Poor or Fair Health Proportion",
y = "Number of Counties"
) +
theme_minimal()