Variables that I will use to determine a state’s life quality are: life expectancy, education rank, temperature, and other weather related such as amount of rain and snow.

Life expectancy will look at the average age of a person in each state. Determining if a person does live longer, will they be happier or do it have no effect?

Temperature of each state, specifically the average yearly temperature in Fahrenheit. Does a average warm/hot temperature contribute to better life quality or will it not effect it?

Education rank of each state, does there to be a big difference between the 51st ranked vs 1st ranked?

Finally I choose another weather related data, covering multiple variables but I focused on amount of snow fall and rain fall. Do states that snow more have better life quality? Do states with more rain have better life quality? Or are both variables actually a negative factor to life quality?

Before starting I had to put all the variables that I wanted into one data set. And note that I tried to use yearly wage but were ‘characters’, even though they’re literately numbers.

Sdata <- read.csv(file="StatesDatav2.csv", header=TRUE, sep=",")
summary(Sdata)
##     State              Rainfall        Snowfall      ExtremeWeatherOccurences
##  Length:51          Min.   : 9.54   Min.   : 0.000   Min.   : 0.00           
##  Class :character   1st Qu.:24.58   1st Qu.: 5.242   1st Qu.: 9.25           
##  Mode  :character   Median :41.81   Median :22.335   Median :13.50           
##                     Mean   :37.15   Mean   :26.957   Mean   :15.78           
##                     3rd Qu.:47.95   3rd Qu.:38.600   3rd Qu.:22.00           
##                     Max.   :63.70   Max.   :89.250   Max.   :48.00           
##                     NA's   :1       NA's   :1        NA's   :1               
##  Life.Expectancy    Edu.Rank      Fahrenheit    Yearly.Wage       
##  Min.   :70.90   Min.   : 1.0   Min.   :26.60   Length:51         
##  1st Qu.:74.55   1st Qu.:13.5   1st Qu.:45.25   Class :character  
##  Median :76.30   Median :26.0   Median :51.20   Mode  :character  
##  Mean   :75.98   Mean   :26.0   Mean   :51.94                     
##  3rd Qu.:77.80   3rd Qu.:38.5   3rd Qu.:58.65                     
##  Max.   :79.90   Max.   :51.0   Max.   :70.70                     
##                                 NA's   :1
Lifexp <- Sdata$Life.Expectancy
Wage <- Sdata$Yearly.Wage
Temp <- Sdata$Fahrenheit
Edu <- Sdata$Edu.Rank
Snow <- Sdata$Snowfall
Rain <- Sdata$Rainfall

predState <- lm(Edu ~ Lifexp + Temp+Rain+Snow, data = Sdata)
summary(predState)
## 
## Call:
## lm(formula = Edu ~ Lifexp + Temp + Rain + Snow, data = Sdata)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -18.816  -8.249  -1.593   8.190  27.356 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 323.9527    54.0491   5.994 3.19e-07 ***
## Lifexp       -4.2239     0.6652  -6.350 9.42e-08 ***
## Temp          0.4976     0.3962   1.256    0.216    
## Rain         -0.2151     0.1348  -1.596    0.118    
## Snow          0.2048     0.1331   1.539    0.131    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 11.11 on 45 degrees of freedom
##   (1 observation deleted due to missingness)
## Multiple R-squared:  0.4864, Adjusted R-squared:  0.4407 
## F-statistic: 10.65 on 4 and 45 DF,  p-value: 3.688e-06

Based on the p-values, Edu was 0, Temp was 0, Snow and Rain were both very close to .16 so they seem not to have a strong correlation.

When I remove Snow and Rain from the model, Temp increases to .43, so does the temperature have a correlation or not? Edu is still at 0, education rank must be strong factor in the state’s quality.

I switched the outcome to Edu ~ Lifexp, the results were the same. Life expectancy was 0 and temperature was .41. Adding back Snow and Rain to the model had the same results. Temp was .21, Rain was .11 and Snow was .13.

In conclusion, life expectancy and education have a good correlation when finding a state’s quality of life. Snow, Rain and Temp have a smaller contribution.