West Coast Living?

In West Coast metropolitans, how important is environmental quality to quality of life and cost of living?

library(dplyr)
## Warning: package 'dplyr' was built under R version 3.5.3
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
library(httr)
## Warning: package 'httr' was built under R version 3.5.3
library(jsonlite)
## Warning: package 'jsonlite' was built under R version 3.5.3

Data Cleaning

phx <- t(fromJSON(rawToChar(GET("https://api.teleport.org/api/urban_areas/slug:phoenix/scores/")$content))$categories[c('name','score_out_of_10')])
colnames(phx) <- phx[1,]
phx <- phx[-1,]

lax <- t(fromJSON(rawToChar(GET("https://api.teleport.org/api/urban_areas/slug:los-angeles/scores/")$content))$categories[c('name','score_out_of_10')])
colnames(lax) <- lax[1,]
lax <- lax[-1,]

sfo <- t(fromJSON(rawToChar(GET("https://api.teleport.org/api/urban_areas/slug:san-francisco-bay-area/scores/")$content))$categories[c('name','score_out_of_10')])
colnames(sfo) <- sfo[1,]
sfo <- sfo[-1,]

sea <- t(fromJSON(rawToChar(GET("https://api.teleport.org/api/urban_areas/slug:seattle/scores/")$content))$categories[c('name','score_out_of_10')])
colnames(sea) <- sea[1,]
sea <- sea[-1,]

slc <- t(fromJSON(rawToChar(GET("https://api.teleport.org/api/urban_areas/slug:salt-lake-city/scores/")$content))$categories[c('name','score_out_of_10')])
colnames(slc) <- slc[1,]
slc <- slc[-1,]

lv <- t(fromJSON(rawToChar(GET("https://api.teleport.org/api/urban_areas/slug:las-vegas/scores/")$content))$categories[c('name','score_out_of_10')])
colnames(lv) <- lv[1,]
lv <- lv[-1,]

sd <- t(fromJSON(rawToChar(GET("https://api.teleport.org/api/urban_areas/slug:san-diego/scores/")$content))$categories[c('name','score_out_of_10')])
colnames(sd) <- sd[1,]
sd <- sd[-1,]

den <- t(fromJSON(rawToChar(GET("https://api.teleport.org/api/urban_areas/slug:denver/scores/")$content))$categories[c('name','score_out_of_10')])
colnames(den) <- den[1,]
den <- den[-1,]
west_coast <- as.data.frame(rbind(den,lax,lv,phx,sd,sfo,slc,sea)) %>% mutate_all(function(x) as.numeric(as.character(x)))

Regressions

I tried a bunch of regressions to see what effects quality of life on the West Coast

summary(lm(`Cost of Living` ~ Startups + `Commute` + Taxation + `Environmental Quality`+ Safety,data=west_coast))
## 
## Call:
## lm(formula = `Cost of Living` ~ Startups + Commute + Taxation + 
##     `Environmental Quality` + Safety, data = west_coast)
## 
## Residuals:
##        1        2        3        4        5        6        7        8 
##  0.02533 -0.05395  0.39683 -0.12977  0.71106 -0.16113 -0.22865 -0.55972 
## 
## Coefficients:
##                         Estimate Std. Error t value Pr(>|t|)
## (Intercept)             24.29756   17.19670   1.413    0.293
## Startups                -0.87429    0.34567  -2.529    0.127
## Commute                 -1.89803    1.92914  -0.984    0.429
## Taxation                -0.52667    2.58048  -0.204    0.857
## `Environmental Quality` -0.03323    0.60966  -0.055    0.961
## Safety                  -0.22745    0.62574  -0.363    0.751
## 
## Residual standard error: 0.7331 on 2 degrees of freedom
## Multiple R-squared:  0.8998, Adjusted R-squared:  0.6493 
## F-statistic: 3.592 on 5 and 2 DF,  p-value: 0.232

When I try a bunch of different variables at once in the model it doesnโ€™t have any significant values. However, when I only make the model one variable, one variable becomes significant.

summary(lm(`Cost of Living` ~ Startups,data=west_coast))
## 
## Call:
## lm(formula = `Cost of Living` ~ Startups, data = west_coast)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -0.93971 -0.30294  0.03967  0.39606  1.05137 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  11.0067     1.6104   6.835 0.000482 ***
## Startups     -0.7502     0.1960  -3.828 0.008683 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.7208 on 6 degrees of freedom
## Multiple R-squared:  0.7095, Adjusted R-squared:  0.661 
## F-statistic: 14.65 on 1 and 6 DF,  p-value: 0.008683

Maybe working for a start up makes people happier? Could be because they are able to manage their time differently.