TABLE-2
# Calculating Propensity scores for NSW and CPS Samples
# In the paper the propensity scores are measured using a logit model where the
# covariates are Age, Age^2,Age^3 School, School^2, Married, No degree, Married, No degree, Black, Hispanic, RE74, RE75, U74, U75, School*RE74
prop_score_nsw <- glm(treat ~ age+I(age^2)+I(age^3)+education+I(education^2)+married+nodegree+black+hispanic+re74+re75+u74+u75+education*re74,family = binomial(), data = data_nsw)
prsrnsw_df <- data.frame(pr_score = predict(prop_score_nsw, type = "response"),
treat_status = prop_score_nsw$model$treat) #prsrnsw::propensity score for nsw dataset
prop_score_nsw_cps <- glm(treat ~ age+I(age^2)+I(age^3)+education+I(education^2)+married+nodegree+black+hispanic+re74+re75+u74+u75+education*re74,family = binomial(), data = data_nsw_cps)
prsrnswcps_df <- data.frame(pr_score = predict(prop_score_nsw_cps, type = "response"),
treat_status = prop_score_nsw_cps$model$treat) #prsrnsw::propensity score for nsw_cps dataset
x1=mean(prsrnsw_df$pr_score)
x2=mean(prsrnswcps_df$pr_score)
sprintf("The mean propensity score of the NSW Dataset: %f" ,x1 )
## [1] "The mean propensity score of the NSW Dataset: 0.415730"
sprintf("The mean propensity score of the NSW_CPS Dataset: %f" ,x2)
## [1] "The mean propensity score of the NSW_CPS Dataset: 0.011436"
TABLE-3
# Calculating Propensity scores for NSW and PSID Samples
# In the paper the propensity scores are measured using a logit model where the
# covariates are Age, Age^2, School, School^2, Married, No degree, Black, Hisp, RE74, RE74^2, RE75, RE75^2, U74, U75, U74 * Hisp.
prp_score_nsw <- glm(treat ~ age+I(age^2)+education+I(education^2)+married+nodegree+black+hispanic+re74+re75+I(re74^2)+I(re75^2)+u74+u75+u74*hispanic,family = binomial(), data = data_nsw)
prsnsw_df <- data.frame(pr_score = predict(prp_score_nsw, type = "response"),
treat_status = prp_score_nsw$model$treat) #prsnsw::propensity score for nsw dataset
prp_score_nsw_psid <- glm(treat ~ age+I(age^2)+education+I(education^2)+married+nodegree+black+hispanic+re74+re75+I(re74^2)+I(re75^2)+u74+u75+u74*hispanic,family = binomial(), data = data_nsw_psid)
prsnswpsid_df <- data.frame(pr_score = predict(prp_score_nsw_psid, type = "response"),
treat_status = prp_score_nsw_psid$model$treat) #prsnswpsid::propensity score for nsw_psid dataset
x3=mean(prsnsw_df$pr_score)
x4=mean(prsnswpsid_df$pr_score)
sprintf("The mean propensity score of the NSW Dataset: %f" ,x3 )
## [1] "The mean propensity score of the NSW Dataset: 0.415730"
sprintf("The mean propensity score of the NSW_PSID Dataset: %f" ,x4)
## [1] "The mean propensity score of the NSW_PSID Dataset: 0.069159"
Matching Algorithm
library(MatchIt)
## Warning: package 'MatchIt' was built under R version 4.1.3
reg1 <- matchit(treat ~ age +education+ black+hispanic + married + nodegree + re74 + re75+u74+u75, data = data_nsw, method = "nearest", distance = "glm",estimand = "ATT")
reg2 <- matchit(treat ~ age +education+ black+hispanic + married + nodegree + re74 + re75+u74+u75, data = data_nsw_cps, method = "nearest", distance = "glm",estimand = "ATT")
reg3 <- matchit(treat ~ age +education+ black+hispanic + married + nodegree + re74 + re75+u74+u75, data = data_nsw_psid, method = "nearest", distance = "glm",estimand = "ATT")
# Create a data frame of Matched Data
dataframeNSW<- match.data(reg1,group="all",distance = "prop.score",data = data_nsw)
dataframeNSWCPS<- match.data(reg2,group="all",distance = "prop.score",data = data_nsw_cps)
dataframeNSWPSID<- match.data(reg3,group="all",distance = "prop.score",data = data_nsw_psid)
Regression Treatment Effects
treat_reg_1 <- lm(re78~treat+age +education+ black+hispanic + married + nodegree + re74 + re75+u74+u75,data = dataframeNSW)
treat_reg_2 <- lm(re78~treat+age +education+ black+hispanic + married + nodegree + re74 + re75+u74+u75,data = dataframeNSWCPS)
treat_reg_3 <- lm(re78~treat+age +education+ black+hispanic + married + nodegree + re74 + re75+u74+u75,data = dataframeNSWPSID)
library(sjmisc)
## Warning: package 'sjmisc' was built under R version 4.1.3
##
## Attaching package: 'sjmisc'
## The following object is masked from 'package:purrr':
##
## is_empty
## The following object is masked from 'package:tidyr':
##
## replace_na
## The following object is masked from 'package:tibble':
##
## add_case
library(sjlabelled)
## Warning: package 'sjlabelled' was built under R version 4.1.3
##
## Attaching package: 'sjlabelled'
## The following object is masked from 'package:forcats':
##
## as_factor
## The following object is masked from 'package:ggplot2':
##
## as_label
## The following object is masked from 'package:dplyr':
##
## as_label
## The following objects are masked from 'package:haven':
##
## as_factor, read_sas, read_spss, read_stata, write_sas, zap_labels
library(sjPlot)
## Warning: package 'sjPlot' was built under R version 4.1.3
## Learn more about sjPlot with 'browseVignettes("sjPlot")'.
tab_model(treat_reg_1,treat_reg_2,treat_reg_3,terms = c("treat"),show.ci = FALSE,show.se = TRUE,auto.label = TRUE,dv.labels = c("NSW","NSW_CPS","NSW_PSID"))
|
|
NSW
|
NSW_CPS
|
NSW_PSID
|
|
Predictors
|
Estimates
|
std. Error
|
p
|
Estimates
|
std. Error
|
p
|
Estimates
|
std. Error
|
p
|
|
treat
|
1617.03
|
700.62
|
0.022
|
2090.76
|
686.15
|
0.002
|
169.92
|
1152.44
|
0.883
|
|
Observations
|
370
|
370
|
370
|
|
R2 / R2 adjusted
|
0.065 / 0.036
|
0.153 / 0.127
|
0.130 / 0.103
|