2024-06-05

Introduction

This presentation explores the state.x77 dataset provided in the R Datasets Package, version 4.5.0. This presentation showcases the demographic and socioeconomic statistics for 50 US states in the 1970’s.

Using various statisical tools, we will study the relationships between following variables:

  1. Income
  2. Illiteracy
  3. Life Expectancy
  4. Percentage of high-school graduates

HS Graduation Rate vs. Illiteracy (ggplot)

If we were to plot the two variables ‘HS Grad’ and ‘Illiteracy’ against each other, we get the following ggplot. The data suggests that there is a negative relationship between illiteracy rate and high school graduation ration. (Higher illiteracy rates tend to have lower high school graduation rates.)

What else is there? Another approach to determine the the relationship (or lack thereof) between variables is to find the R-Squared value–a number between 0-1, with 1 meaning a strong relationship–which indicates the proportion of the variance in the dependent variable that is predictable from the independent variable(s) in a linear regression model.

\[ R^2 = 1 - \frac{\sum(y_i - \hat{y}_i)^2}{\sum(y_i - \bar{y})^2} \]

Applied to our data, we get that our R-squared value is 0.4318969, which indicates that, still, about 43% of the variation in high school graduation rate can be explained by the illiteracy rate, suggesting that addressing illiteracy rates may be an important step in improving high school graduation rates.

Average Income pt.1

We could also make simpler graphs if we’d simply like to get a brief overview of the some of the data. For example, what if we wanted to know an estimate of in what range, on average, were most people’s income?

ggplot(as.data.frame(state.x77), aes(x = Income)) + 
  geom_histogram(bins = 20) + 
  labs(x = "Income", y = "Frequency") + 
  ggtitle("Average Income")

Average Income pt.2

\[ \bar{I} = \frac{\sum_{i=1}^{n} I_i}{n} \]

Now, we can also keep it really simple. What if I simply wanted to know the average income in the US in the 1970’s? We can use the formula (as seen above) to find the average. Or, we can keep it simpler and utilize the functions given to us in the R library!

data <- as.data.frame(state.x77)
avg_income <- mean(data$Income)
cat("Average income:", avg_income)

Average income: 4435.8

Confidence Interval Testing (plotly)

What else can we tell from our data? We can do a confidence interval test to compare the mean life expectancy of the 50 states to a known mean value of 70.8786 years. Here are our findings from a sample size of 17 random states:

  • The sample mean is close to the population mean, but slightly higher.
  • The confidence interval suggests that the true population mean life expectancy of all 50 states is likely to be between 70.6 and 71.4 years.
  • The t-statistic and p-value indicate that the sample mean is not significantly different from the population mean at the 5% significance level. This means that we cannot reject the null hypothesis that the true population mean life expectancy is 70.8786 years.

Overall, we find that that the sample of 17 states is representative of the population of all 50 states, and that the mean life expectancy of the sample is not significantly different from the known population mean.

Relationship between Life Exp. and Income. (plotly)

Life Exp. v. Income Findings

Using point estimation, we find that the correlation coefficient between Income and Life Expectancy: r = 0.3402553

  • Positive correlation: The correlation coefficient (r) is positive, which as can be shown on the graph indicates that there is a positive linear relationship between Income and LifeExp. As Income increases, LifeExp also tends to increase.
  • Moderate strength: The absolute value of r (0.3402553) indicating that the relationship between Income and LifeExp is not extremely strong, but it’s not weak either.

Our conclusions suggest that as Income increases, Life Expectancy also tends to increase; states with higher incomes tend to have higher life expectancies, and vice versa. However, the moderate strength of the correlation implies that there may be other factors at play that influence Life Expectancy, and that Income is not the sole determining factor.