library(pacman)
p_load(wooldridge, multiwayvcov, causalweight, lmtest, did, usmap,
sandwich, AER, ivmodel, haven, estimatr, tidyverse, lubridate,
gridExtra, stringr, readxl, reshape2, scales, broom,
ggplot2, fixest, lfe, stargazer, foreign, ggthemes, ggforce,
ggridges, latex2exp, viridis, extrafont, kableExtra, snakecase,
janitor, tableone, causaldata, multcomp, etable)

Problem 1

data(kielmc)
attach(kielmc)
as.data.frame(table(nearinc, y81))
##   nearinc y81 Freq
## 1       0   0  123
## 2       1   0   56
## 3       0   1  102
## 4       1   1   40
summary(rprice)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   26000   59000   82000   83721  100230  300000
length(unique(cbd))
## [1] 34
?kielmc

i. DID without covariates

kielmc <- kielmc %>%
  mutate(post = ifelse(y81 == 1, 1, 0),
         treat = ifelse(nearinc == 1, 1, 0),
         interaction = post * treat)

model1 <- lm(rprice ~ post + treat + interaction, data = kielmc)
cluster_se1 <- cluster.vcov(model1, kielmc$cbd)

stargazer(model1, type = "text", se = list(sqrt(diag(cluster_se1))), 
          title = "Difference-in-Differences Estimation (With Covariates)", 
          dep.var.labels = "House Prices", 
          covariate.labels = c("Post", "Treat", "Interaction"),
          out = "table1.txt")
## 
## Difference-in-Differences Estimation (With Covariates)
## ===============================================
##                         Dependent variable:    
##                     ---------------------------
##                            House Prices        
## -----------------------------------------------
## Post                       18,790.290***       
##                             (5,154.864)        
##                                                
## Treat                      -18,824.370**       
##                             (7,796.294)        
##                                                
## Interaction                -11,863.900*        
##                             (6,621.818)        
##                                                
## Constant                   82,517.230***       
##                             (3,221.924)        
##                                                
## -----------------------------------------------
## Observations                    321            
## R2                             0.174           
## Adjusted R2                    0.166           
## Residual Std. Error    30,242.900 (df = 317)   
## F Statistic           22.251*** (df = 3; 317)  
## ===============================================
## Note:               *p<0.1; **p<0.05; ***p<0.01

The intercept tells us that during the pre-treatment period, houses that located farther away from the incinerators have a 82517.2 higher real housing price. The coefficient of post implies that the real housing price increase by 18790.3 after the installation of incinerator for all observations on average. The coefficient of treat says that houses that located near the incinerators have a 18824.4 lower real prices on average. All of these coefficients are statistically significant at 5%. The coefficient of interaction term shows that after the incinerators were installed, houses that located near the incinerators have real prices that are 11863.9 lower than those located farther away on average. However, this estimate is only statistically significant at 10%.

ii. DID with covariates

library(ipw)

# DID 
model2 <- lm(rprice ~ post + treat + interaction + rooms + baths + age + agesq + larea + lland, data = kielmc)
cluster_se2 <- cluster.vcov(model2, kielmc$cbd)

stargazer(model2, type = "text", se = list(sqrt(diag(cluster_se2))), 
          title = "Difference-in-Differences Estimation (With Covariates)", 
          dep.var.labels = "House Prices", 
          covariate.labels = c("Post", "Treat", "Interaction", "Rooms", "Baths", "Age", "Age Squared", "Log Area", "Log Land"),
          out = "table2.txt")
## 
## Difference-in-Differences Estimation (With Covariates)
## ===============================================
##                         Dependent variable:    
##                     ---------------------------
##                            House Prices        
## -----------------------------------------------
## Post                       16,672.710***       
##                             (3,714.861)        
##                                                
## Treat                       15,554.710         
##                            (10,224.750)        
##                                                
## Interaction               -17,545.700***       
##                             (5,821.574)        
##                                                
## Rooms                       2,978.963**        
##                             (1,401.381)        
##                                                
## Baths                      7,458.220***        
##                             (2,595.273)        
##                                                
## Age                         -616.245***        
##                              (128.447)         
##                                                
## Age Squared                  3.053***          
##                               (0.776)          
##                                                
## Log Area                   32,815.340***       
##                             (8,487.841)        
##                                                
## Log Land                     7,194.257         
##                             (4,660.224)        
##                                                
## Constant                  -279,726.300***      
##                            (93,485.450)        
##                                                
## -----------------------------------------------
## Observations                    321            
## R2                             0.637           
## Adjusted R2                    0.627           
## Residual Std. Error    20,235.080 (df = 311)   
## F Statistic           60.690*** (df = 9; 311)  
## ===============================================
## Note:               *p<0.1; **p<0.05; ***p<0.01
model3 <- lm(rprice ~ post + treat + interaction + rooms + baths + age + agesq + area + land, data = kielmc)
cluster_se3 <- cluster.vcov(model3, kielmc$cbd)

stargazer(model3, type = "text", se = list(sqrt(diag(cluster_se3))), 
          title = "Difference-in-Differences Estimation (With Covariates)", 
          dep.var.labels = "House Prices", 
          covariate.labels = c("Post", "Treat", "Interaction", "Rooms", "Baths", "Age", "Age Squared", "Area", "Land"),
          out = "table3.txt")
## 
## Difference-in-Differences Estimation (With Covariates)
## ===============================================
##                         Dependent variable:    
##                     ---------------------------
##                            House Prices        
## -----------------------------------------------
## Post                       15,210.440***       
##                             (3,859.677)        
##                                                
## Treat                        9,964.965         
##                             (7,484.951)        
##                                                
## Interaction               -15,020.680***       
##                             (5,297.257)        
##                                                
## Rooms                       3,280.511**        
##                             (1,440.462)        
##                                                
## Baths                      7,489.358***        
##                             (2,725.948)        
##                                                
## Age                         -657.159***        
##                              (136.595)         
##                                                
## Age Squared                  3.083***          
##                               (0.725)          
##                                                
## Area                         17.830***         
##                               (5.325)          
##                                                
## Land                           0.116           
##                               (0.105)          
##                                                
## Constant                     2,189.075         
##                             (9,333.944)        
##                                                
## -----------------------------------------------
## Observations                    321            
## R2                             0.652           
## Adjusted R2                    0.642           
## Residual Std. Error    19,823.800 (df = 311)   
## F Statistic           64.683*** (df = 9; 311)  
## ===============================================
## Note:               *p<0.1; **p<0.05; ***p<0.01
# DID using IPW with cluster bootstrap
covariates_model4 <- c("rooms", "baths", "age", "agesq", "larea", "lland")

model4 <- didweight(kielmc$rprice,    
                     kielmc$nearinc,   
                     kielmc$y81,        
                     x = as.matrix(kielmc[, covariates_model4]),  
                     boot = 1000,           
                     cluster = kielmc$cbd) 

treatment_effect_model4 <- as.numeric(model4$effect)
standard_error_model4 <- as.numeric(model4$se)
p_value_model4 <- as.numeric(model4$pvalue)

results_model4 <- data.frame(
  Coefficient = c("Treatment Effect", "Standard Error", "P-value"),
  Value = c(treatment_effect_model4, standard_error_model4, p_value_model4)
)
stargazer(results_model4, type = "text", summary = FALSE, 
          title = "Difference-in-Differences Estimation with IPW and Cluster Bootstrap", 
          out = "table4")
## 
## Difference-in-Differences Estimation with IPW and Cluster Bootstrap
## ==============================
##     Coefficient       Value   
## ------------------------------
## 1 Treatment Effect -18,380.370
## 2  Standard Error  23,264.120 
## 3     P-value         0.429   
## ------------------------------
covariates_model5 <- c("rooms", "baths", "age", "agesq", "area", "land")

model5 <- didweight(kielmc$rprice,    
                     kielmc$nearinc,   
                     kielmc$y81,        
                     x = as.matrix(kielmc[, covariates_model5]),  
                     boot = 1000,           
                     cluster = kielmc$cbd) 

treatment_effect_model5 <- as.numeric(model5$effect)
standard_error_model5 <- as.numeric(model5$se)
p_value_model5 <- as.numeric(model5$pvalue)

results_model5 <- data.frame(
  Coefficient = c("Treatment Effect", "Standard Error", "P-value"),
  Value = c(treatment_effect_model5, standard_error_model5, p_value_model5)
)
stargazer(results_model5, type = "text", summary = FALSE, 
          title = "Difference-in-Differences Estimation with IPW and Cluster Bootstrap", 
          out = "table5")
## 
## Difference-in-Differences Estimation with IPW and Cluster Bootstrap
## =============================
##     Coefficient      Value   
## -----------------------------
## 1 Treatment Effect -5,896.836
## 2  Standard Error  10,622.170
## 3     P-value        0.579   
## -----------------------------

The sign of the treatment effect is consistent among all models and the negative sign intuitively makes sense. But the magnitudes and statistical significance of the treatment effects vary across models. Including covariates greatly increases the explanatory power of the model, but using larea&lland instead of area&land does not help much with capturing variations in rprice. Using IPW with cluster bootstrapping, the model is more robust against bias caused by comparability of treatment groups and gives more precise standard errors. So technically, I prefer the IPW model with area&land even though with a loss of statistical significance. But I’m not sure why the treatment effect in the model is much smaller compared to others.

iii. TWFE

As we see heterogeneous treatment effects across treated observations, approach 2 suits better for this analysis because approach assumes constant treatment effects within treated units.

library(modelsummary)

# Friend's data
i <- c(1, 1, 2, 2, 3, 3, 4, 4)
t <- c(1, 2, 1, 2, 1, 2, 1, 2)
P_t <- c(0, 1, 0, 1, 0, 1, 0, 1)
D_it <- c(0, 0, 0, 0, 0, 1, 0, 1)
D_i <- c(0, 0, 0, 0, 1, 1, 1, 1)
Y_it <- c(6, 7, 10, 9, 8, 14, 8, 12)
df <- data.frame(i=i, t=t, P_t=P_t, D_it=D_it, D_i=D_i, Y_it=Y_it)
rm(i, t, P_t, D_it, D_i, Y_it)
df <- df %>%
  mutate(interaction = D_i * P_t)

# approach 1
model6 <- feols(Y_it ~ D_it + i + t, data = df)
summary(model6)
## OLS estimation, Dep. Var.: Y_it
## Observations: 8
## Standard-errors: IID 
##             Estimate Std. Error  t value Pr(>|t|)    
## (Intercept) 6.833333   3.167763 2.157148 0.097199 .  
## D_it        4.333333   2.173067 1.994109 0.116900    
## i           0.333333   0.687184 0.485071 0.652994    
## t           0.333333   1.611590 0.206835 0.846241    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## RMSE: 1.19024   Adj. R2: 0.599327
# approach 2
model7 <- feols(Y_it ~ D_i + P_t + interaction, data = df)
summary(model7)
## OLS estimation, Dep. Var.: Y_it
## Observations: 8
## Standard-errors: IID 
##             Estimate Std. Error      t value  Pr(>|t|)    
## (Intercept) 8.00e+00    1.22474 6.531973e+00 0.0028378 ** 
## D_i         3.55e-15    1.73205 2.050000e-15 1.0000000    
## P_t         3.55e-15    1.73205 2.050000e-15 1.0000000    
## interaction 5.00e+00    2.44949 2.041241e+00 0.1107872    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## RMSE: 1.22474   Adj. R2: 0.575758
# approach 3
model8 <- feols(Y_it ~ interaction + i + t, data = df)
summary(model8)
## OLS estimation, Dep. Var.: Y_it
## Observations: 8
## Standard-errors: IID 
##             Estimate Std. Error  t value Pr(>|t|)    
## (Intercept) 6.833333   3.167763 2.157148 0.097199 .  
## interaction 4.333333   2.173067 1.994109 0.116900    
## i           0.333333   0.687184 0.485071 0.652994    
## t           0.333333   1.611590 0.206835 0.846241    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## RMSE: 1.19024   Adj. R2: 0.599327
models <- list("Approach 1" = model6, "Approach 2" = model7, "Approach 3" = model8)
modelsummary(models, stars = TRUE)
Approach 1 Approach 2 Approach 3
+ p < 0.1, * p < 0.05, ** p < 0.01, *** p < 0.001
(Intercept) 6.833+ 8.000** 6.833+
(3.168) (1.225) (3.168)
D_it 4.333
(2.173)
i 0.333 0.333
(0.687) (0.687)
t 0.333 0.333
(1.612) (1.612)
D_i 0.000
(1.732)
P_t 0.000
(1.732)
interaction 5.000 4.333
(2.449) (2.173)
Num.Obs. 8 8 8
R2 0.771 0.758 0.771
R2 Adj. 0.599 0.576 0.599
AIC 33.5 33.9 33.5
BIC 33.8 34.3 33.8
RMSE 1.19 1.22 1.19
Std.Errors IID IID IID

Approach 3 is preferred for this analysis because approach 3 has the same fit as approach 1 while including an interaction term that captures the heterogeneity in treatment effects.

Problem 2

library(did)
data(mpdta)

i. Descriptive county-level maps

library(dplyr)
library(viridis)

mpdta <- mpdta %>% rename(fips = countyreal)
mpdta <- mpdta %>% mutate(treat = factor(treat, levels = c(0, 1), labels = c("Untreated", "Treated")))
mpdta <- mpdta %>% mutate(first.treat = factor(first.treat, levels = c(2004, 2006, 2007)))

plot_treat <- plot_usmap(data = mpdta, values = "treat", regions = "counties") +
  scale_fill_manual(values = c("pink", "purple"), name = "Treatment") +
  labs(title = "Minimum Wage Treatment Status by County") +
  theme_minimal()
plot_treat

plot_first_treat <- plot_usmap(data = mpdta, values = "first.treat", regions = "counties") +
  scale_fill_manual(values = c("orange", "purple", "pink"), name = "First Treatment Year") +
  labs(title = "Year of Minimum Wage Implementation") +
  theme_minimal()
plot_first_treat

lemp_summary <- mpdta %>%
  filter(!is.na(first.treat)) %>%
  group_by(fips, year, first.treat) %>%
  summarise(mean_lemp = mean(lemp, na.rm = TRUE), .groups = "drop") %>%
  mutate(fips = as.character(fips))  
plot_lemp <- function(treat_year) {
  cohort_data <- lemp_summary %>% filter(first.treat == treat_year)
  cohort_data <- cohort_data %>% mutate(year = as.factor(year))  
  plot_usmap(data = cohort_data, values = "mean_lemp", regions = "counties", include = cohort_data$fips) +
    scale_fill_viridis_c(option = "magma", name = "Avg. log(Teen Employment)", na.value = "gray80") +
    facet_wrap(~"year", nrow = 2) +
    labs(title = paste("Treatment Group:", treat_year)) +
    theme_minimal()
}
map_0 <- plot_lemp(0)   
map_2004 <- plot_lemp(2004)
map_2006 <- plot_lemp(2006)
map_2007 <- plot_lemp(2007)
map_0

map_2004

map_2006

map_2007

The treated counties distribute all over the US while the most concentrated part is in the midwest. Among those treated, most counties are treated in 2007 while the very few were treated in 2004.

From the map, I can’t really observe any changes of lemp over time for each group. It’s either too subtle or no changes.

ii. Cohort-year-specific average treatment effects on the treated

mpdta$first.treat <- as.numeric(as.character(mpdta$first.treat))
mpdta$first.treat[is.na(mpdta$first.treat)] <- 0
att1 <- att_gt(
  yname = "lemp",  
  tname = "year", 
  idname = "fips",  
  gname = "first.treat", 
  xformla = ~lpop, 
  control_group = "nevertreated",  
  clustervars = "fips",
  data = mpdta,
  est_method = "reg"
)
summary(att1)
## 
## Call:
## att_gt(yname = "lemp", tname = "year", idname = "fips", gname = "first.treat", 
##     xformla = ~lpop, data = mpdta, control_group = "nevertreated", 
##     clustervars = "fips", est_method = "reg")
## 
## Reference: Callaway, Brantly and Pedro H.C. Sant'Anna.  "Difference-in-Differences with Multiple Time Periods." Journal of Econometrics, Vol. 225, No. 2, pp. 200-230, 2021. <https://doi.org/10.1016/j.jeconom.2020.12.001>, <https://arxiv.org/abs/1803.09015> 
## 
## Group-Time Average Treatment Effects:
##  Group Time ATT(g,t) Std. Error [95% Simult.  Conf. Band]  
##   2004 2004  -0.0149     0.0224       -0.0742      0.0443  
##   2004 2005  -0.0770     0.0309       -0.1587      0.0047  
##   2004 2006  -0.1411     0.0360       -0.2361     -0.0460 *
##   2004 2007  -0.1075     0.0345       -0.1987     -0.0164 *
##   2006 2004  -0.0021     0.0224       -0.0612      0.0571  
##   2006 2005  -0.0070     0.0196       -0.0587      0.0447  
##   2006 2006   0.0008     0.0192       -0.0499      0.0514  
##   2006 2007  -0.0415     0.0202       -0.0949      0.0118  
##   2007 2004   0.0264     0.0145       -0.0120      0.0647  
##   2007 2005  -0.0048     0.0153       -0.0453      0.0358  
##   2007 2006  -0.0285     0.0179       -0.0759      0.0189  
##   2007 2007  -0.0288     0.0168       -0.0733      0.0157  
## ---
## Signif. codes: `*' confidence band does not cover 0
## 
## P-value for pre-test of parallel trends assumption:  0.23116
## Control Group:  Never Treated,  Anticipation Periods:  0
## Estimation Method:  Outcome Regression

For the 2006 and 2007 groups, the att are not statistically significant in all time periods. For the 2004 group, the att is negative and statistically significant in 2005, 2006, and 2007.

att2 <- att_gt(
  yname = "lemp",  
  tname = "year", 
  idname = "fips",  
  gname = "first.treat", 
  xformla = ~lpop, 
  control_group = "nevertreated",  
  clustervars = "fips",
  data = mpdta,
  est_method = "ipw"
)
summary(att2)
## 
## Call:
## att_gt(yname = "lemp", tname = "year", idname = "fips", gname = "first.treat", 
##     xformla = ~lpop, data = mpdta, control_group = "nevertreated", 
##     clustervars = "fips", est_method = "ipw")
## 
## Reference: Callaway, Brantly and Pedro H.C. Sant'Anna.  "Difference-in-Differences with Multiple Time Periods." Journal of Econometrics, Vol. 225, No. 2, pp. 200-230, 2021. <https://doi.org/10.1016/j.jeconom.2020.12.001>, <https://arxiv.org/abs/1803.09015> 
## 
## Group-Time Average Treatment Effects:
##  Group Time ATT(g,t) Std. Error [95% Simult.  Conf. Band]  
##   2004 2004  -0.0145     0.0240       -0.0775      0.0484  
##   2004 2005  -0.0764     0.0305       -0.1563      0.0034  
##   2004 2006  -0.1405     0.0388       -0.2420     -0.0389 *
##   2004 2007  -0.1069     0.0337       -0.1953     -0.0186 *
##   2006 2004  -0.0009     0.0216       -0.0574      0.0557  
##   2006 2005  -0.0064     0.0188       -0.0557      0.0429  
##   2006 2006   0.0012     0.0192       -0.0492      0.0516  
##   2006 2007  -0.0413     0.0192       -0.0916      0.0090  
##   2007 2004   0.0266     0.0141       -0.0105      0.0636  
##   2007 2005  -0.0047     0.0168       -0.0488      0.0394  
##   2007 2006  -0.0283     0.0193       -0.0789      0.0223  
##   2007 2007  -0.0289     0.0178       -0.0755      0.0177  
## ---
## Signif. codes: `*' confidence band does not cover 0
## 
## P-value for pre-test of parallel trends assumption:  0.23604
## Control Group:  Never Treated,  Anticipation Periods:  0
## Estimation Method:  Inverse Probability Weighting

Here the 2004 group is not getting significant att in 2005. Everything else stays pretty much similar to the last estimation.

att3 <- att_gt(
  yname = "lemp",  
  tname = "year", 
  idname = "fips",  
  gname = "first.treat", 
  xformla = ~lpop, 
  control_group = "nevertreated",  
  clustervars = "fips",
  data = mpdta,
  est_method = "dr"
)
summary(att3)
## 
## Call:
## att_gt(yname = "lemp", tname = "year", idname = "fips", gname = "first.treat", 
##     xformla = ~lpop, data = mpdta, control_group = "nevertreated", 
##     clustervars = "fips", est_method = "dr")
## 
## Reference: Callaway, Brantly and Pedro H.C. Sant'Anna.  "Difference-in-Differences with Multiple Time Periods." Journal of Econometrics, Vol. 225, No. 2, pp. 200-230, 2021. <https://doi.org/10.1016/j.jeconom.2020.12.001>, <https://arxiv.org/abs/1803.09015> 
## 
## Group-Time Average Treatment Effects:
##  Group Time ATT(g,t) Std. Error [95% Simult.  Conf. Band]  
##   2004 2004  -0.0145     0.0228       -0.0744      0.0453  
##   2004 2005  -0.0764     0.0291       -0.1527     -0.0001 *
##   2004 2006  -0.1404     0.0376       -0.2390     -0.0419 *
##   2004 2007  -0.1069     0.0361       -0.2015     -0.0123 *
##   2006 2004  -0.0005     0.0236       -0.0623      0.0614  
##   2006 2005  -0.0062     0.0198       -0.0582      0.0458  
##   2006 2006   0.0010     0.0198       -0.0509      0.0528  
##   2006 2007  -0.0413     0.0202       -0.0944      0.0118  
##   2007 2004   0.0267     0.0143       -0.0109      0.0643  
##   2007 2005  -0.0046     0.0158       -0.0459      0.0367  
##   2007 2006  -0.0284     0.0190       -0.0784      0.0215  
##   2007 2007  -0.0288     0.0165       -0.0721      0.0146  
## ---
## Signif. codes: `*' confidence band does not cover 0
## 
## P-value for pre-test of parallel trends assumption:  0.23267
## Control Group:  Never Treated,  Anticipation Periods:  0
## Estimation Method:  Doubly Robust

This one still produces similar results.

ggdid(att3)

I think the results are consistent with the maps. The effects are mostly insignificant.

iii. Cohort-specific and aggregate average treatment effects on the treated

aggte <- aggte(att3, type = "group")
summary(aggte)
## 
## Call:
## aggte(MP = att3, type = "group")
## 
## Reference: Callaway, Brantly and Pedro H.C. Sant'Anna.  "Difference-in-Differences with Multiple Time Periods." Journal of Econometrics, Vol. 225, No. 2, pp. 200-230, 2021. <https://doi.org/10.1016/j.jeconom.2020.12.001>, <https://arxiv.org/abs/1803.09015> 
## 
## 
## Overall summary of ATT's based on group/cohort aggregation:  
##      ATT    Std. Error     [ 95%  Conf. Int.]  
##  -0.0328        0.0124    -0.0572     -0.0085 *
## 
## 
## Group Effects:
##  Group Estimate Std. Error [95% Simult.  Conf. Band]  
##   2004  -0.0846     0.0266       -0.1415     -0.0276 *
##   2006  -0.0202     0.0178       -0.0581      0.0178  
##   2007  -0.0288     0.0167       -0.0645      0.0069  
## ---
## Signif. codes: `*' confidence band does not cover 0
## 
## Control Group:  Never Treated,  Anticipation Periods:  0
## Estimation Method:  Doubly Robust

Here we are still seeing that only the 2004 group experienced significant effects over time after the treatment. Having the minimum wage policy decreased the employment rate of the 2004 group by about 8.5%.

# 1
library(twang)

mpdta$treat <- ifelse(mpdta$treat == 2, 1, mpdta$treat)
mpdta$treat <- ifelse(mpdta$treat == 1, 0, mpdta$treat)
mpdta$treat <- ifelse(mpdta$treat == 2, 1, mpdta$treat)
mpdta$treat <- as.numeric(mpdta$treat)
ps <- ps(treat ~ year + lpop + treat, data = mpdta, stop.method = "es.mean")
## Fitting boosted model
## Iter   TrainDeviance   ValidDeviance   StepSize   Improve
##      1        1.3102             nan     0.0100       nan
##      2        1.2907             nan     0.0100       nan
##      3        1.2717             nan     0.0100       nan
##      4        1.2530             nan     0.0100       nan
##      5        1.2348             nan     0.0100       nan
##      6        1.2170             nan     0.0100       nan
##      7        1.1995             nan     0.0100       nan
##      8        1.1824             nan     0.0100       nan
##      9        1.1656             nan     0.0100       nan
##     10        1.1491             nan     0.0100       nan
##     20        1.0010             nan     0.0100       nan
##     40        0.7727             nan     0.0100       nan
##     60        0.6058             nan     0.0100       nan
##     80        0.4800             nan     0.0100       nan
##    100        0.3831             nan     0.0100       nan
##    120        0.3075             nan     0.0100       nan
##    140        0.2478             nan     0.0100       nan
##    160        0.2004             nan     0.0100       nan
##    180        0.1624             nan     0.0100       nan
##    200        0.1319             nan     0.0100       nan
##    220        0.1073             nan     0.0100       nan
##    240        0.0874             nan     0.0100       nan
##    260        0.0712             nan     0.0100       nan
##    280        0.0581             nan     0.0100       nan
##    300        0.0474             nan     0.0100       nan
##    320        0.0388             nan     0.0100       nan
##    340        0.0317             nan     0.0100       nan
##    360        0.0259             nan     0.0100       nan
##    380        0.0212             nan     0.0100       nan
##    400        0.0173             nan     0.0100       nan
##    420        0.0142             nan     0.0100       nan
##    440        0.0116             nan     0.0100       nan
##    460        0.0095             nan     0.0100       nan
##    480        0.0078             nan     0.0100       nan
##    500        0.0064             nan     0.0100       nan
##    520        0.0052             nan     0.0100       nan
##    540        0.0043             nan     0.0100       nan
##    560        0.0035             nan     0.0100       nan
##    580        0.0029             nan     0.0100       nan
##    600        0.0023             nan     0.0100       nan
##    620        0.0019             nan     0.0100       nan
##    640        0.0016             nan     0.0100       nan
##    660        0.0013             nan     0.0100       nan
##    680        0.0010             nan     0.0100       nan
##    700        0.0009             nan     0.0100       nan
##    720        0.0007             nan     0.0100       nan
##    740        0.0006             nan     0.0100       nan
##    760        0.0005             nan     0.0100       nan
##    780        0.0004             nan     0.0100       nan
##    800        0.0003             nan     0.0100       nan
##    820        0.0003             nan     0.0100       nan
##    840        0.0002             nan     0.0100       nan
##    860        0.0002             nan     0.0100       nan
##    880        0.0001             nan     0.0100       nan
##    900        0.0001             nan     0.0100       nan
##    920        0.0001             nan     0.0100       nan
##    940        0.0001             nan     0.0100       nan
##    960        0.0001             nan     0.0100       nan
##    980        0.0001             nan     0.0100       nan
##   1000        0.0000             nan     0.0100       nan
##   1020        0.0000             nan     0.0100       nan
##   1040        0.0000             nan     0.0100       nan
##   1060        0.0000             nan     0.0100       nan
##   1080        0.0000             nan     0.0100       nan
##   1100        0.0000             nan     0.0100       nan
##   1120        0.0000             nan     0.0100       nan
##   1140        0.0000             nan     0.0100       nan
##   1160        0.0000             nan     0.0100       nan
##   1180        0.0000             nan     0.0100       nan
##   1200        0.0000             nan     0.0100       nan
##   1220        0.0000             nan     0.0100       nan
##   1240        0.0000             nan     0.0100       nan
##   1260        0.0000             nan     0.0100       nan
##   1280        0.0000             nan     0.0100       nan
##   1300        0.0000             nan     0.0100       nan
##   1320        0.0000             nan     0.0100       nan
##   1340        0.0000             nan     0.0100       nan
##   1360        0.0000             nan     0.0100       nan
##   1380        0.0000             nan     0.0100       nan
##   1400        0.0000             nan     0.0100       nan
##   1420        0.0000             nan     0.0100       nan
##   1440        0.0000             nan     0.0100       nan
##   1460        0.0000             nan     0.0100       nan
##   1480        0.0000             nan     0.0100       nan
##   1500        0.0000             nan     0.0100       nan
##   1520        0.0000             nan     0.0100       nan
##   1540        0.0000             nan     0.0100       nan
##   1560        0.0000             nan     0.0100       nan
##   1580        0.0000             nan     0.0100       nan
##   1600        0.0000             nan     0.0100       nan
##   1620        0.0000             nan     0.0100       nan
##   1640        0.0000             nan     0.0100       nan
##   1660        0.0000             nan     0.0100       nan
##   1680        0.0000             nan     0.0100       nan
##   1700        0.0000             nan     0.0100       nan
##   1720        0.0000             nan     0.0100       nan
##   1740        0.0000             nan     0.0100       nan
##   1760        0.0000             nan     0.0100       nan
##   1780        0.0000             nan     0.0100       nan
##   1800        0.0000             nan     0.0100       nan
##   1820        0.0000             nan     0.0100       nan
##   1840        0.0000             nan     0.0100       nan
##   1860        0.0000             nan     0.0100       nan
##   1880        0.0000             nan     0.0100       nan
##   1900        0.0000             nan     0.0100       nan
##   1920        0.0000             nan     0.0100       nan
##   1940        0.0000             nan     0.0100       nan
##   1960        0.0000             nan     0.0100       nan
##   1980        0.0000             nan     0.0100       nan
##   2000        0.0000             nan     0.0100       nan
##   2020        0.0000             nan     0.0100       nan
##   2040        0.0000             nan     0.0100       nan
##   2060        0.0000             nan     0.0100       nan
##   2080        0.0000             nan     0.0100       nan
##   2100        0.0000             nan     0.0100       nan
##   2120        0.0000             nan     0.0100       nan
##   2140        0.0000             nan     0.0100       nan
##   2160        0.0000             nan     0.0100       nan
##   2180        0.0000             nan     0.0100       nan
##   2200        0.0000             nan     0.0100       nan
##   2220        0.0000             nan     0.0100       nan
##   2240        0.0000             nan     0.0100       nan
##   2260        0.0000             nan     0.0100       nan
##   2280        0.0000             nan     0.0100       nan
##   2300        0.0000             nan     0.0100       nan
##   2320        0.0000             nan     0.0100       nan
##   2340        0.0000             nan     0.0100       nan
##   2360        0.0000             nan     0.0100       nan
##   2380        0.0000             nan     0.0100       nan
##   2400        0.0000             nan     0.0100       nan
##   2420        0.0000             nan     0.0100       nan
##   2440        0.0000             nan     0.0100       nan
##   2460        0.0000             nan     0.0100       nan
##   2480        0.0000             nan     0.0100       nan
##   2500        0.0000             nan     0.0100       nan
##   2520        0.0000             nan     0.0100       nan
##   2540        0.0000             nan     0.0100       nan
##   2560        0.0000             nan     0.0100       nan
##   2580        0.0000             nan     0.0100       nan
##   2600        0.0000             nan     0.0100       nan
##   2620        0.0000             nan     0.0100       nan
##   2640        0.0000             nan     0.0100       nan
##   2660        0.0000             nan     0.0100       nan
##   2680        0.0000             nan     0.0100       nan
##   2700        0.0000             nan     0.0100       nan
##   2720        0.0000             nan     0.0100       nan
##   2740        0.0000             nan     0.0100       nan
##   2760        0.0000             nan     0.0100       nan
##   2780        0.0000             nan     0.0100       nan
##   2800        0.0000             nan     0.0100       nan
##   2820        0.0000             nan     0.0100       nan
##   2840        0.0000             nan     0.0100       nan
##   2860        0.0000             nan     0.0100       nan
##   2880        0.0000             nan     0.0100       nan
##   2900        0.0000             nan     0.0100       nan
##   2920        0.0000             nan     0.0100       nan
##   2940        0.0000             nan     0.0100       nan
##   2960        0.0000             nan     0.0100       nan
##   2980        0.0000             nan     0.0100       nan
##   3000        0.0000             nan     0.0100       nan
##   3020        0.0000             nan     0.0100       nan
##   3040        0.0000             nan     0.0100       nan
##   3060        0.0000             nan     0.0100       nan
##   3080        0.0000             nan     0.0100       nan
##   3100        0.0000             nan     0.0100       nan
##   3120        0.0000             nan     0.0100       nan
##   3140        0.0000             nan     0.0100       nan
##   3160        0.0000             nan     0.0100       nan
##   3180        0.0000             nan     0.0100       nan
##   3200        0.0000             nan     0.0100       nan
##   3220        0.0000             nan     0.0100       nan
##   3240        0.0000             nan     0.0100       nan
##   3260        0.0000             nan     0.0100       nan
##   3280        0.0000             nan     0.0100       nan
##   3300        0.0000             nan     0.0100       nan
##   3320        0.0000             nan     0.0100       nan
##   3340        0.0000             nan     0.0100       nan
##   3360        0.0000             nan     0.0100       nan
##   3380        0.0000             nan     0.0100       nan
##   3400        0.0000             nan     0.0100       nan
##   3420        0.0000             nan     0.0100       nan
##   3440        0.0000             nan     0.0100       nan
##   3460        0.0000             nan     0.0100       nan
##   3480        0.0000             nan     0.0100       nan
##   3500        0.0000             nan     0.0100       nan
##   3520        0.0000             nan     0.0100       nan
##   3540        0.0000             nan     0.0100       nan
##   3560        0.0000             nan     0.0100       nan
##   3580        0.0000             nan     0.0100       nan
##   3600        0.0000             nan     0.0100       nan
##   3620        0.0000             nan     0.0100       nan
##   3640        0.0000             nan     0.0100       nan
##   3660        0.0000             nan     0.0100       nan
##   3680        0.0000             nan     0.0100       nan
##   3700        0.0000             nan     0.0100       nan
##   3720        0.0000             nan     0.0100       nan
##   3740        0.0000             nan     0.0100       nan
##   3760        0.0000             nan     0.0100       nan
##   3780        0.0000             nan     0.0100       nan
##   3800        0.0000             nan     0.0100       nan
##   3820        0.0000             nan     0.0100       nan
##   3840        0.0000             nan     0.0100       nan
##   3860        0.0000             nan     0.0100       nan
##   3880        0.0000             nan     0.0100       nan
##   3900        0.0000             nan     0.0100       nan
##   3920        0.0000             nan     0.0100       nan
##   3940        0.0000             nan     0.0100       nan
##   3960        0.0000             nan     0.0100       nan
##   3980        0.0000             nan     0.0100       nan
##   4000        0.0000             nan     0.0100       nan
##   4020        0.0000             nan     0.0100       nan
##   4040        0.0000             nan     0.0100       nan
##   4060        0.0000             nan     0.0100       nan
##   4080        0.0000             nan     0.0100       nan
##   4100        0.0000             nan     0.0100       nan
##   4120        0.0000             nan     0.0100       nan
##   4140        0.0000             nan     0.0100       nan
##   4160        0.0000             nan     0.0100       nan
##   4180        0.0000             nan     0.0100       nan
##   4200        0.0000             nan     0.0100       nan
##   4220        0.0000             nan     0.0100       nan
##   4240        0.0000             nan     0.0100       nan
##   4260        0.0000             nan     0.0100       nan
##   4280        0.0000             nan     0.0100       nan
##   4300        0.0000             nan     0.0100       nan
##   4320        0.0000             nan     0.0100       nan
##   4340        0.0000             nan     0.0100       nan
##   4360        0.0000             nan     0.0100       nan
##   4380        0.0000             nan     0.0100       nan
##   4400        0.0000             nan     0.0100       nan
##   4420        0.0000             nan     0.0100       nan
##   4440        0.0000             nan     0.0100       nan
##   4460        0.0000             nan     0.0100       nan
##   4480        0.0000             nan     0.0100       nan
##   4500        0.0000             nan     0.0100       nan
##   4520        0.0000             nan     0.0100       nan
##   4540        0.0000             nan     0.0100       nan
##   4560        0.0000             nan     0.0100       nan
##   4580        0.0000             nan     0.0100       nan
##   4600        0.0000             nan     0.0100       nan
##   4620        0.0000             nan     0.0100       nan
##   4640        0.0000             nan     0.0100       nan
##   4660        0.0000             nan     0.0100       nan
##   4680        0.0000             nan     0.0100       nan
##   4700        0.0000             nan     0.0100       nan
##   4720        0.0000             nan     0.0100       nan
##   4740        0.0000             nan     0.0100       nan
##   4760        0.0000             nan     0.0100       nan
##   4780        0.0000             nan     0.0100       nan
##   4800        0.0000             nan     0.0100       nan
##   4820        0.0000             nan     0.0100       nan
##   4840        0.0000             nan     0.0100       nan
##   4860        0.0000             nan     0.0100       nan
##   4880        0.0000             nan     0.0100       nan
##   4900        0.0000             nan     0.0100       nan
##   4920        0.0000             nan     0.0100       nan
##   4940        0.0000             nan     0.0100       nan
##   4960        0.0000             nan     0.0100       nan
##   4980        0.0000             nan     0.0100       nan
##   5000        0.0000             nan     0.0100       nan
##   5020        0.0000             nan     0.0100       nan
##   5040        0.0000             nan     0.0100       nan
##   5060        0.0000             nan     0.0100       nan
##   5080        0.0000             nan     0.0100       nan
##   5100        0.0000             nan     0.0100       nan
##   5120        0.0000             nan     0.0100       nan
##   5140        0.0000             nan     0.0100       nan
##   5160        0.0000             nan     0.0100       nan
##   5180        0.0000             nan     0.0100       nan
##   5200        0.0000             nan     0.0100       nan
##   5220        0.0000             nan     0.0100       nan
##   5240        0.0000             nan     0.0100       nan
##   5260        0.0000             nan     0.0100       nan
##   5280        0.0000             nan     0.0100       nan
##   5300        0.0000             nan     0.0100       nan
##   5320        0.0000             nan     0.0100       nan
##   5340        0.0000             nan     0.0100       nan
##   5360        0.0000             nan     0.0100       nan
##   5380        0.0000             nan     0.0100       nan
##   5400        0.0000             nan     0.0100       nan
##   5420        0.0000             nan     0.0100       nan
##   5440        0.0000             nan     0.0100       nan
##   5460        0.0000             nan     0.0100       nan
##   5480        0.0000             nan     0.0100       nan
##   5500        0.0000             nan     0.0100       nan
##   5520        0.0000             nan     0.0100       nan
##   5540        0.0000             nan     0.0100       nan
##   5560        0.0000             nan     0.0100       nan
##   5580        0.0000             nan     0.0100       nan
##   5600        0.0000             nan     0.0100       nan
##   5620        0.0000             nan     0.0100       nan
##   5640        0.0000             nan     0.0100       nan
##   5660        0.0000             nan     0.0100       nan
##   5680        0.0000             nan     0.0100       nan
##   5700        0.0000             nan     0.0100       nan
##   5720        0.0000             nan     0.0100       nan
##   5740        0.0000             nan     0.0100       nan
##   5760        0.0000             nan     0.0100       nan
##   5780        0.0000             nan     0.0100       nan
##   5800        0.0000             nan     0.0100       nan
##   5820        0.0000             nan     0.0100       nan
##   5840        0.0000             nan     0.0100       nan
##   5860        0.0000             nan     0.0100       nan
##   5880        0.0000             nan     0.0100       nan
##   5900        0.0000             nan     0.0100       nan
##   5920        0.0000             nan     0.0100       nan
##   5940        0.0000             nan     0.0100       nan
##   5960        0.0000             nan     0.0100       nan
##   5980        0.0000             nan     0.0100       nan
##   6000        0.0000             nan     0.0100       nan
##   6020        0.0000             nan     0.0100       nan
##   6040        0.0000             nan     0.0100       nan
##   6060        0.0000             nan     0.0100       nan
##   6080        0.0000             nan     0.0100       nan
##   6100        0.0000             nan     0.0100       nan
##   6120        0.0000             nan     0.0100       nan
##   6140        0.0000             nan     0.0100       nan
##   6160        0.0000             nan     0.0100       nan
##   6180        0.0000             nan     0.0100       nan
##   6200        0.0000             nan     0.0100       nan
##   6220        0.0000             nan     0.0100       nan
##   6240        0.0000             nan     0.0100       nan
##   6260        0.0000             nan     0.0100       nan
##   6280        0.0000             nan     0.0100       nan
##   6300        0.0000             nan     0.0100       nan
##   6320        0.0000             nan     0.0100       nan
##   6340        0.0000             nan     0.0100       nan
##   6360        0.0000             nan     0.0100       nan
##   6380        0.0000             nan     0.0100       nan
##   6400        0.0000             nan     0.0100       nan
##   6420        0.0000             nan     0.0100       nan
##   6440        0.0000             nan     0.0100       nan
##   6460        0.0000             nan     0.0100       nan
##   6480        0.0000             nan     0.0100       nan
##   6500        0.0000             nan     0.0100       nan
##   6520        0.0000             nan     0.0100       nan
##   6540        0.0000             nan     0.0100       nan
##   6560        0.0000             nan     0.0100       nan
##   6580        0.0000             nan     0.0100       nan
##   6600        0.0000             nan     0.0100       nan
##   6620        0.0000             nan     0.0100       nan
##   6640        0.0000             nan     0.0100       nan
##   6660        0.0000             nan     0.0100       nan
##   6680        0.0000             nan     0.0100       nan
##   6700        0.0000             nan     0.0100       nan
##   6720        0.0000             nan     0.0100       nan
##   6740        0.0000             nan     0.0100       nan
##   6760        0.0000             nan     0.0100       nan
##   6780        0.0000             nan     0.0100       nan
##   6800        0.0000             nan     0.0100       nan
##   6820        0.0000             nan     0.0100       nan
##   6840        0.0000             nan     0.0100       nan
##   6860        0.0000             nan     0.0100       nan
##   6880        0.0000             nan     0.0100       nan
##   6900        0.0000             nan     0.0100       nan
##   6920        0.0000             nan     0.0100       nan
##   6940        0.0000             nan     0.0100       nan
##   6960        0.0000             nan     0.0100       nan
##   6980        0.0000             nan     0.0100       nan
##   7000        0.0000             nan     0.0100       nan
##   7020        0.0000             nan     0.0100       nan
##   7040        0.0000             nan     0.0100       nan
##   7060        0.0000             nan     0.0100       nan
##   7080        0.0000             nan     0.0100       nan
##   7100        0.0000             nan     0.0100       nan
##   7120        0.0000             nan     0.0100       nan
##   7140        0.0000             nan     0.0100       nan
##   7160        0.0000             nan     0.0100       nan
##   7180        0.0000             nan     0.0100       nan
##   7200        0.0000             nan     0.0100       nan
##   7220        0.0000             nan     0.0100       nan
##   7240        0.0000             nan     0.0100       nan
##   7260        0.0000             nan     0.0100       nan
##   7280        0.0000             nan     0.0100       nan
##   7300        0.0000             nan     0.0100       nan
##   7320        0.0000             nan     0.0100       nan
##   7340        0.0000             nan     0.0100       nan
##   7360        0.0000             nan     0.0100       nan
##   7380        0.0000             nan     0.0100       nan
##   7400        0.0000             nan     0.0100       nan
##   7420        0.0000             nan     0.0100       nan
##   7440        0.0000             nan     0.0100       nan
##   7460        0.0000             nan     0.0100       nan
##   7480        0.0000             nan     0.0100       nan
##   7500        0.0000             nan     0.0100       nan
##   7520        0.0000             nan     0.0100       nan
##   7540        0.0000             nan     0.0100       nan
##   7560        0.0000             nan     0.0100       nan
##   7580        0.0000             nan     0.0100       nan
##   7600        0.0000             nan     0.0100       nan
##   7620        0.0000             nan     0.0100       nan
##   7640        0.0000             nan     0.0100       nan
##   7660        0.0000             nan     0.0100       nan
##   7680        0.0000             nan     0.0100       nan
##   7700        0.0000             nan     0.0100       nan
##   7720        0.0000             nan     0.0100       nan
##   7740        0.0000             nan     0.0100       nan
##   7760        0.0000             nan     0.0100       nan
##   7780        0.0000             nan     0.0100       nan
##   7800        0.0000             nan     0.0100       nan
##   7820        0.0000             nan     0.0100       nan
##   7840        0.0000             nan     0.0100       nan
##   7860        0.0000             nan     0.0100       nan
##   7880        0.0000             nan     0.0100       nan
##   7900        0.0000             nan     0.0100       nan
##   7920        0.0000             nan     0.0100       nan
##   7940        0.0000             nan     0.0100       nan
##   7960        0.0000             nan     0.0100       nan
##   7980        0.0000             nan     0.0100       nan
##   8000        0.0000             nan     0.0100       nan
##   8020        0.0000             nan     0.0100       nan
##   8040        0.0000             nan     0.0100       nan
##   8060        0.0000             nan     0.0100       nan
##   8080        0.0000             nan     0.0100       nan
##   8100        0.0000             nan     0.0100       nan
##   8120        0.0000             nan     0.0100       nan
##   8140        0.0000             nan     0.0100       nan
##   8160        0.0000             nan     0.0100       nan
##   8180        0.0000             nan     0.0100       nan
##   8200        0.0000             nan     0.0100       nan
##   8220        0.0000             nan     0.0100       nan
##   8240        0.0000             nan     0.0100       nan
##   8260        0.0000             nan     0.0100       nan
##   8280        0.0000             nan     0.0100       nan
##   8300        0.0000             nan     0.0100       nan
##   8320        0.0000             nan     0.0100       nan
##   8340        0.0000             nan     0.0100       nan
##   8360        0.0000             nan     0.0100       nan
##   8380        0.0000             nan     0.0100       nan
##   8400        0.0000             nan     0.0100       nan
##   8420        0.0000             nan     0.0100       nan
##   8440        0.0000             nan     0.0100       nan
##   8460        0.0000             nan     0.0100       nan
##   8480        0.0000             nan     0.0100       nan
##   8500        0.0000             nan     0.0100       nan
##   8520        0.0000             nan     0.0100       nan
##   8540        0.0000             nan     0.0100       nan
##   8560        0.0000             nan     0.0100       nan
##   8580        0.0000             nan     0.0100       nan
##   8600        0.0000             nan     0.0100       nan
##   8620        0.0000             nan     0.0100       nan
##   8640        0.0000             nan     0.0100       nan
##   8660        0.0000             nan     0.0100       nan
##   8680        0.0000             nan     0.0100       nan
##   8700        0.0000             nan     0.0100       nan
##   8720        0.0000             nan     0.0100       nan
##   8740        0.0000             nan     0.0100       nan
##   8760        0.0000             nan     0.0100       nan
##   8780        0.0000             nan     0.0100       nan
##   8800        0.0000             nan     0.0100       nan
##   8820        0.0000             nan     0.0100       nan
##   8840        0.0000             nan     0.0100       nan
##   8860        0.0000             nan     0.0100       nan
##   8880        0.0000             nan     0.0100       nan
##   8900        0.0000             nan     0.0100       nan
##   8920        0.0000             nan     0.0100       nan
##   8940        0.0000             nan     0.0100       nan
##   8960        0.0000             nan     0.0100       nan
##   8980        0.0000             nan     0.0100       nan
##   9000        0.0000             nan     0.0100       nan
##   9020        0.0000             nan     0.0100       nan
##   9040        0.0000             nan     0.0100       nan
##   9060        0.0000             nan     0.0100       nan
##   9080        0.0000             nan     0.0100       nan
##   9100        0.0000             nan     0.0100       nan
##   9120        0.0000             nan     0.0100       nan
##   9140        0.0000             nan     0.0100       nan
##   9160        0.0000             nan     0.0100       nan
##   9180        0.0000             nan     0.0100       nan
##   9200        0.0000             nan     0.0100       nan
##   9220        0.0000             nan     0.0100       nan
##   9240        0.0000             nan     0.0100       nan
##   9260        0.0000             nan     0.0100       nan
##   9280        0.0000             nan     0.0100       nan
##   9300        0.0000             nan     0.0100       nan
##   9320        0.0000             nan     0.0100       nan
##   9340        0.0000             nan     0.0100       nan
##   9360        0.0000             nan     0.0100       nan
##   9380        0.0000             nan     0.0100       nan
##   9400        0.0000             nan     0.0100       nan
##   9420        0.0000             nan     0.0100       nan
##   9440        0.0000             nan     0.0100       nan
##   9460        0.0000             nan     0.0100       nan
##   9480        0.0000             nan     0.0100       nan
##   9500        0.0000             nan     0.0100       nan
##   9520        0.0000             nan     0.0100       nan
##   9540        0.0000             nan     0.0100       nan
##   9560        0.0000             nan     0.0100       nan
##   9580        0.0000             nan     0.0100       nan
##   9600        0.0000             nan     0.0100       nan
##   9620        0.0000             nan     0.0100       nan
##   9640        0.0000             nan     0.0100       nan
##   9660        0.0000             nan     0.0100       nan
##   9680        0.0000             nan     0.0100       nan
##   9700        0.0000             nan     0.0100       nan
##   9720        0.0000             nan     0.0100       nan
##   9740        0.0000             nan     0.0100       nan
##   9760        0.0000             nan     0.0100       nan
##   9780        0.0000             nan     0.0100       nan
##   9800        0.0000             nan     0.0100       nan
##   9820        0.0000             nan     0.0100       nan
##   9840        0.0000             nan     0.0100       nan
##   9860        0.0000             nan     0.0100       nan
##   9880        0.0000             nan     0.0100       nan
##   9900        0.0000             nan     0.0100       nan
##   9920        0.0000             nan     0.0100       nan
##   9940        0.0000             nan     0.0100       nan
##   9960        0.0000             nan     0.0100       nan
##   9980        0.0000             nan     0.0100       nan
##  10000        0.0000             nan     0.0100       nan
## 
## Diagnosis of unweighted analysis
## Calculating standardized differences
## Optimizing with es.mean.ATE stopping rule
##    Optimized at 2999 
## Diagnosis of es.mean.ATE weights
att4 <- att_gt(yname = "lemp", tname = "year", idname = "fips", 
                   gname = "first.treat", xformla = ~lpop, 
                   control_group = "nevertreated", clustervars = "fips", 
                   data = mpdta, est_method = "dr", 
                   weights = ps$weights)
summary(att4)
## 
## Call:
## att_gt(yname = "lemp", tname = "year", idname = "fips", gname = "first.treat", 
##     xformla = ~lpop, data = mpdta, control_group = "nevertreated", 
##     weightsname = ps$weights, clustervars = "fips", est_method = "dr")
## 
## Reference: Callaway, Brantly and Pedro H.C. Sant'Anna.  "Difference-in-Differences with Multiple Time Periods." Journal of Econometrics, Vol. 225, No. 2, pp. 200-230, 2021. <https://doi.org/10.1016/j.jeconom.2020.12.001>, <https://arxiv.org/abs/1803.09015> 
## 
## Group-Time Average Treatment Effects:
##  Group Time ATT(g,t) Std. Error [95% Simult.  Conf. Band]  
##   2004 2004  -0.0145     0.0223       -0.0730      0.0439  
##   2004 2005  -0.0764     0.0285       -0.1514     -0.0015 *
##   2004 2006  -0.1404     0.0366       -0.2365     -0.0444 *
##   2004 2007  -0.1069     0.0324       -0.1919     -0.0219 *
##   2006 2004  -0.0005     0.0233       -0.0618      0.0609  
##   2006 2005  -0.0062     0.0188       -0.0557      0.0433  
##   2006 2006   0.0010     0.0188       -0.0485      0.0504  
##   2006 2007  -0.0413     0.0204       -0.0948      0.0122  
##   2007 2004   0.0267     0.0148       -0.0122      0.0657  
##   2007 2005  -0.0046     0.0161       -0.0470      0.0378  
##   2007 2006  -0.0284     0.0191       -0.0785      0.0216  
##   2007 2007  -0.0288     0.0171       -0.0736      0.0160  
## ---
## Signif. codes: `*' confidence band does not cover 0
## 
## P-value for pre-test of parallel trends assumption:  0.23267
## Control Group:  Never Treated,  Anticipation Periods:  0
## Estimation Method:  Doubly Robust
# 2
library(fixest)

mpdta$treat_year <- ifelse(mpdta$first.treat == 0, NA, mpdta$first.treat)
att5 <- feols(lemp ~ i(year, treat_year, ref = 2003) + lpop | fips + year, 
                    data = mpdta)
summary(att5)
## OLS estimation, Dep. Var.: lemp
## Observations: 955
## Fixed-effects: fips: 191,  year: 5
## Standard-errors: Clustered (fips) 
##                       Estimate Std. Error t value  Pr(>|t|)    
## year::2004:treat_year 0.014843   0.008215 1.80685 0.0723672 .  
## year::2005:treat_year 0.031743   0.011551 2.74813 0.0065711 ** 
## year::2006:treat_year 0.039293   0.013366 2.93982 0.0036915 ** 
## year::2007:treat_year 0.022030   0.013474 1.63494 0.1037170    
## ... 1 variable was removed because of collinearity (lpop)
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## RMSE: 0.111216     Adj. R2: 0.993005
##                  Within R2: 0.013004
# 3
library(did2s)

att6 <- did2s(
  data = mpdta,
  yname = "lemp",
  first_stage = ~ lpop + fips + year,
  second_stage = "treat",
  treatment = "treat",
  cluster_var = "fips"
)
summary(att6)
## OLS estimation, Dep. Var.: lemp
## Observations: 2,500
## Standard-errors: Custom 
##        Estimate Std. Error   t value Pr(>|t|) 
## treat -0.005309   0.045442 -0.116838    0.907 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## RMSE: 0.545008   Adj. R2: -3.778e-4