Read libraries
Read in NYTD data
Organize NYTD data (drop missing)
Covariates
Create needed covariates
nytd_all$foodIns = nytd_all$Food.Insecure / 100 # mean 0.133106
nytd_all$unempRt = nytd_all$unemp/(nytd_all$unemp + nytd_all$emp) # 0.05514365
nytd_all$singPar = nytd_all$kidsSingPar/nytd_all$child # 0.3282801
nytd_all$chpovRt = nytd_all$childpov/nytd_all$child # 0.1967591
nytd_all$povRt = nytd_all$pov/nytd_all$pop # 0.1392956
nytd_all$gspPc = (nytd_all$Gross.State.Product*1000000) / nytd_all$pop # 57150.41
nytd_all$crimeRt = ((nytd_all$violent_crime + nytd_all$property_crime) / nytd_all$pop)*1000 # 28.5098
nytd_all$pctBlk = nytd_all$blkpop / nytd_all$pop # 0.1036744
nytd_all$pctHis = nytd_all$hispop / nytd_all$pop # 0.1171681
nytd_all$mediPpl = nytd_all$Medicaid.beneficiaries / nytd_all$pov # 1.599911
nytd_all$snapPpl= nytd_all$Food.Stamp.SNAP.Recipients / nytd_all$pov # 0.9826695
nytd_all$tanfPpl = nytd_all$AFDC.TANF.Recipients / nytd_all$childpov # 0.2354464
nytd_all$welfarePc = (nytd_all$swTot / nytd_all$pop)*1000 # 1.594769
nytd_all$incarRt = (nytd_all$incarTot / nytd_all$adult)*1000 # 5.005433
nytd_all$deathRt = (nytd_all$deathSen / nytd_all$newIncar)*1000 # 0.05661189
nytd_all$policePc = (nytd_all$policeTot / nytd_all$pop)*1000 # 2.72597
nytd_all$wicPpl = nytd_all$WIC.participation / nytd_all$childpov # 0.496694
nytd_all$fc_homeRt = (nytd_all$homeless / nytd_all$basepop)*100 # 12.22256
nytd_all$fc_subRt = (nytd_all$subabuse / nytd_all$basepop)*100 # 11.06124
nytd_all$fc_incarRt = (nytd_all$incarc / nytd_all$basepop)*100 # 14.34807
Create sample
nytd_sample <- subset(nytd_all, select = c("state","wave","homeless","subabuse","incarc","basepop",
"fc_homeRt","fc_subRt","fc_incarRt","LessHS","foodIns",
"unempRt","singPar","chpovRt","gspPc","policy_updated",
"crimeRt","pctBlk","pctHis","tanf3fam","mediPpl","snapPpl",
"tanfPpl","welfarePc","incarRt","deathRt","policePc"))
nytd_scaled <- scale(nytd_sample[c(10:27)])
nytd_sampSc <- cbind(nytd_sample[c(1:9)],nytd_scaled)
obsN=1:nrow(nytd_sampSc)
nytd_sampSc$wave_c <- nytd_sampSc$wave - 1
# separate waves
nytd_sampSc_1 <- subset(nytd_sampSc,wave==1)
obsN_1=1:nrow(nytd_sampSc_1)
nytd_sampSc_2 <- subset(nytd_sampSc,wave==2)
obsN_2=1:nrow(nytd_sampSc_2)
nytd_sampSc_3 <- subset(nytd_sampSc,wave==3)
obsN_3=1:nrow(nytd_sampSc_3)
Models
Start testing outcomes
# wave 2: prevalence of homelessness
home_lm_w2 <- lm(fc_homeRt ~ unempRt + singPar + foodIns + chpovRt + LessHS + gspPc + policy_updated + crimeRt + pctBlk + tanf3fam + snapPpl + mediPpl + tanfPpl*welfarePc + incarRt + deathRt + policePc, data=nytd_sampSc_2)
summary(home_lm_w2)
##
## Call:
## lm(formula = fc_homeRt ~ unempRt + singPar + foodIns + chpovRt +
## LessHS + gspPc + policy_updated + crimeRt + pctBlk + tanf3fam +
## snapPpl + mediPpl + tanfPpl * welfarePc + incarRt + deathRt +
## policePc, data = nytd_sampSc_2)
##
## Residuals:
## Min 1Q Median 3Q Max
## -10.6681 -2.6141 0.1958 1.3819 14.1350
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 10.5903 1.1861 8.929 4.46e-10 ***
## unempRt 0.8887 2.0411 0.435 0.6663
## singPar 0.1764 1.1735 0.150 0.8815
## foodIns -0.3719 1.4524 -0.256 0.7996
## chpovRt -2.1976 2.3176 -0.948 0.3504
## LessHS 0.3390 2.0199 0.168 0.8678
## gspPc -4.7971 1.8342 -2.615 0.0136 *
## policy_updated -1.0081 2.5407 -0.397 0.6942
## crimeRt -0.2670 1.2300 -0.217 0.8296
## pctBlk -1.3836 1.5440 -0.896 0.3771
## tanf3fam 3.6164 1.9732 1.833 0.0765 .
## snapPpl 0.3447 1.5382 0.224 0.8242
## mediPpl -1.6295 1.8148 -0.898 0.3762
## tanfPpl 1.0588 1.7200 0.616 0.5427
## welfarePc 0.5396 1.2626 0.427 0.6721
## incarRt 2.4906 1.3061 1.907 0.0658 .
## deathRt -1.3574 1.8098 -0.750 0.4589
## policePc -0.7330 1.1375 -0.644 0.5241
## tanfPpl:welfarePc -2.3775 1.1056 -2.150 0.0394 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 6.217 on 31 degrees of freedom
## Multiple R-squared: 0.5239, Adjusted R-squared: 0.2475
## F-statistic: 1.895 on 18 and 31 DF, p-value: 0.0573