use census_api_key(key = "yourkeyhere", install = T)
one time to install your key for use in tidycensus
library(tidycensus)
census_api_key(key ="f67be5a86e696eebf0c84a5a20d85f2c04f7e9ef", overwrite= T )
## To install your API key for use in future sessions, run this function with `install = TRUE`.
options(tigris_use_cache = TRUE)
library(haven)
library(car)
## Loading required package: carData
library(lme4)
## Loading required package: Matrix
library(sjstats)
library(lmerTest)
##
## Attaching package: 'lmerTest'
## The following object is masked from 'package:lme4':
##
## lmer
## The following object is masked from 'package:stats':
##
## step
library(MuMIn)
library(tidyverse); library(sf)
## -- Attaching packages ---------------------------------------------------------- tidyverse 1.2.1 --
## v ggplot2 3.0.0 v purrr 0.2.5
## v tibble 1.4.2 v dplyr 0.7.6
## v tidyr 0.8.1 v stringr 1.3.1
## v readr 1.1.1 v forcats 0.3.0
## -- Conflicts ------------------------------------------------------------- tidyverse_conflicts() --
## x tidyr::expand() masks Matrix::expand()
## x dplyr::filter() masks stats::filter()
## x dplyr::lag() masks stats::lag()
## x dplyr::recode() masks car::recode()
## x purrr::some() masks car::some()
## Linking to GEOS 3.6.1, GDAL 2.2.3, proj.4 4.9.3
v10_Profile <- load_variables(2010, "acs5/profile", cache = TRUE) #demographic profile tables
v10_tables <- load_variables(2010 , "acs5", cache = TRUE) #all tables
#v10_sf1_tables <- load_variables(2010 , "sf1", cache = TRUE) #all tables for 2010 SF1
View(v10_Profile)
#Search for variables by
v10_Profile[grep(x = v10_Profile$label, "owner"), c("name", "label")]
## # A tibble: 4 x 2
## name label
## <chr> <chr>
## 1 DP04_0004 Estimate!!HOUSING OCCUPANCY!!Homeowner vacancy rate
## 2 DP04_0004P Percent!!HOUSING OCCUPANCY!!Homeowner vacancy rate
## 3 DP04_0047 Estimate!!HOUSING TENURE!!Average household size of owner-oc~
## 4 DP04_0047P Percent!!HOUSING TENURE!!Average household size of owner-occ~
v10_Profile[grep(x = v10_Profile$label, "value"), c("name", "label")]
## # A tibble: 0 x 2
## # ... with 2 variables: name <chr>, label <chr>
tx_acs<-get_acs(geography = "tract", state="TX", year = 2010,
variables=c( "DP04_0089PE", "DP04_0080PE", "DP03_0002PE", "DP02_0061PE", "DP02_0003PE", "DP03_0119PE"), geometry = T, output = "wide")
## Getting data from the 2006-2010 5-year ACS
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
## Getting data from the 2006-2010 5-year ACS
## Using the ACS Data Profile
names(tx_acs)
## [1] "GEOID" "NAME" "DP04_0089PE" "DP04_0089PM" "DP04_0080PE"
## [6] "DP04_0080PM" "DP03_0002PE" "DP03_0002PM" "DP02_0061PE" "DP02_0061PM"
## [11] "DP02_0003PE" "DP02_0003PM" "DP03_0119PE" "DP03_0119PM" "geometry"
#create a county FIPS code - 5 digit
tx_acs$county<-substr(tx_acs$GEOID, 1, 5)
#rename variables and filter missing cases
tx_acs2<-tx_acs%>%
mutate(owner= DP04_0089PE, homevalue=DP04_0080PE, laborforce=DP03_0002PE, hsgrad=DP02_0061PE, hhchild= DP02_0003PE, poverty= DP03_0119PE) %>%
# st_transform(crs = 102740)%>%
filter(complete.cases(owner, homevalue, laborforce, hsgrad, hhchild, poverty))
class(tx_acs2)
## [1] "sf" "tbl_df" "tbl" "data.frame"
tx_acs2$ownerz<-scale(tx_acs2$owner, center = T, scale = T)
fit1<-lmer(ownerz~homevalue+laborforce+hsgrad+hhchild+poverty+(1|county), data=tx_acs2)
summary(fit1)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: ownerz ~ homevalue + laborforce + hsgrad + hhchild + poverty +
## (1 | county)
## Data: tx_acs2
##
## REML criterion at convergence: 12967.2
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -3.8511 -0.6348 -0.1029 0.5155 8.6860
##
## Random effects:
## Groups Name Variance Std.Dev.
## county (Intercept) 0.08004 0.2829
## Residual 0.69456 0.8334
## Number of obs: 5150, groups: county, 254
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 2.352e-01 1.119e-01 4.727e+03 2.102 0.0356 *
## homevalue -4.990e-03 9.377e-04 4.700e+03 -5.322 1.08e-07 ***
## laborforce -6.519e-03 1.440e-03 5.087e+03 -4.527 6.12e-06 ***
## hsgrad 1.314e-03 1.465e-03 4.854e+03 0.897 0.3698
## hhchild 2.328e-02 1.040e-03 5.142e+03 22.382 < 2e-16 ***
## poverty -3.446e-02 1.282e-03 4.931e+03 -26.883 < 2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) homevl lbrfrc hsgrad hhchld
## homevalue -0.230
## laborforce -0.844 0.200
## hsgrad -0.436 -0.182 0.127
## hhchild -0.103 0.001 -0.198 -0.053
## poverty -0.132 -0.431 0.186 -0.112 -0.106
fit2<-lmer(ownerz~homevalue+laborforce+hsgrad+hhchild+poverty+(1+poverty|county), data=tx_acs2)
## Warning in checkConv(attr(opt, "derivs"), opt$par, ctrl = control
## $checkConv, : Model failed to converge with max|grad| = 0.0026507 (tol =
## 0.002, component 1)
## Warning in checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, : Model is nearly unidentifiable: very large eigenvalue
## - Rescale variables?
summary(fit2)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: ownerz ~ homevalue + laborforce + hsgrad + hhchild + poverty +
## (1 + poverty | county)
## Data: tx_acs2
##
## REML criterion at convergence: 12919.1
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -3.6895 -0.6329 -0.1090 0.5037 8.5427
##
## Random effects:
## Groups Name Variance Std.Dev. Corr
## county (Intercept) 0.180437 0.42478
## poverty 0.000211 0.01453 -0.88
## Residual 0.682132 0.82591
## Number of obs: 5150, groups: county, 254
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 1.071e-01 1.168e-01 2.759e+03 0.916 0.3595
## homevalue -4.975e-03 9.348e-04 3.596e+03 -5.323 1.08e-07 ***
## laborforce -6.386e-03 1.433e-03 4.961e+03 -4.455 8.57e-06 ***
## hsgrad 3.429e-03 1.501e-03 4.786e+03 2.285 0.0223 *
## hhchild 2.332e-02 1.041e-03 5.033e+03 22.409 < 2e-16 ***
## poverty -3.267e-02 2.226e-03 6.851e+01 -14.676 < 2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) homevl lbrfrc hsgrad hhchld
## homevalue -0.200
## laborforce -0.797 0.204
## hsgrad -0.455 -0.208 0.122
## hhchild -0.096 0.007 -0.188 -0.061
## poverty -0.320 -0.277 0.060 0.070 -0.084
## convergence code: 0
## Model failed to converge with max|grad| = 0.0026507 (tol = 0.002, component 1)
## Model is nearly unidentifiable: very large eigenvalue
## - Rescale variables?
rancoefs2<-ranef(fit2)
head(rancoefs2$county, n=10)
## (Intercept) poverty
## 48001 0.04261351 -0.0002266399
## 48003 -0.08180576 0.0024882730
## 48005 0.22207782 -0.0033557627
## 48007 0.27695567 -0.0055026340
## 48009 -0.18467004 0.0052570097
## 48011 -0.19071761 0.0054377329
## 48013 0.29926730 -0.0056330997
## 48015 0.05264104 -0.0007660562
## 48017 0.18480124 -0.0048168332
## 48019 0.19873915 -0.0036257534
par(mfrow=c(1,1))
plot(rancoefs2$county[, "(Intercept)"], rancoefs2$county[, "poverty"], main="Random effects for each census tract", xlab="Intercept", ylab="Poverty slope")