Running examples in ‘etwfe-Ex.R’ failed
The error most likely occurred in:

> base::assign(".ptime", proc.time(), pos = "CheckExEnv")
> ### Name: etwfe
> ### Title: Extended two-way fixed effects
> ### Aliases: etwfe
> 
> ### ** Examples
> 
> # We’ll use the mpdta dataset from the did package (which you’ll need to 
> # install separately).
> 
> # install.packages("did")
> data("mpdta", package = "did")
> 
> #
> # Basic example
> #
> 
> # The basic ETWFE workflow involves two steps:
> 
> # 1) Estimate the main regression model with etwfe().
> 
> mod = etwfe(
+     fml  = lemp ~ lpop, # outcome ~ controls (use 0 or 1 if none)
+     tvar = year,        # time variable
+     gvar = first.treat, # group variable
+     data = mpdta,       # dataset
+     vcov = ~countyreal  # vcov adjustment (here: clustered by county)
+     )
> mod
OLS estimation, Dep. Var.: lemp
Observations: 2,500 
Fixed-effects: first.treat: 4,  year: 5
Varying slopes: lpop (first.treat: 4),  lpop (year: 5)
Standard-errors: Clustered (countyreal) 
                                              Estimate Std. Error   t value
.Dtreat:first.treat::2004:year::2004         -0.021248   0.021728 -0.977890
.Dtreat:first.treat::2004:year::2005         -0.081850   0.027375 -2.989963
.Dtreat:first.treat::2004:year::2006         -0.137870   0.030795 -4.477097
.Dtreat:first.treat::2004:year::2007         -0.109539   0.032322 -3.389024
.Dtreat:first.treat::2006:year::2006          0.002537   0.018883  0.134344
.Dtreat:first.treat::2006:year::2007         -0.045093   0.021987 -2.050907
.Dtreat:first.treat::2007:year::2007         -0.045955   0.017975 -2.556568
.Dtreat:first.treat::2004:year::2004:lpop_dm  0.004628   0.017584  0.263184
.Dtreat:first.treat::2004:year::2005:lpop_dm  0.025113   0.017904  1.402661
.Dtreat:first.treat::2004:year::2006:lpop_dm  0.050735   0.021070  2.407884
.Dtreat:first.treat::2004:year::2007:lpop_dm  0.011250   0.026617  0.422648
.Dtreat:first.treat::2006:year::2006:lpop_dm  0.038935   0.016472  2.363731
.Dtreat:first.treat::2006:year::2007:lpop_dm  0.038060   0.022477  1.693276
.Dtreat:first.treat::2007:year::2007:lpop_dm -0.019835   0.016198 -1.224528
                                               Pr(>|t|)    
.Dtreat:first.treat::2004:year::2004         3.2860e-01    
.Dtreat:first.treat::2004:year::2005         2.9279e-03 ** 
.Dtreat:first.treat::2004:year::2006         9.3851e-06 ***
.Dtreat:first.treat::2004:year::2007         7.5694e-04 ***
.Dtreat:first.treat::2006:year::2006         8.9318e-01    
.Dtreat:first.treat::2006:year::2007         4.0798e-02 *  
.Dtreat:first.treat::2007:year::2007         1.0866e-02 *  
.Dtreat:first.treat::2004:year::2004:lpop_dm 7.9252e-01    
.Dtreat:first.treat::2004:year::2005:lpop_dm 1.6134e-01    
.Dtreat:first.treat::2004:year::2006:lpop_dm 1.6407e-02 *  
.Dtreat:first.treat::2004:year::2007:lpop_dm 6.7273e-01    
.Dtreat:first.treat::2006:year::2006:lpop_dm 1.8474e-02 *  
.Dtreat:first.treat::2006:year::2007:lpop_dm 9.1027e-02 .  
.Dtreat:first.treat::2007:year::2007:lpop_dm 2.2133e-01    
... 10 variables were removed because of collinearity (.Dtreat:first.treat::2006:year::2004, .Dtreat:first.treat::2006:year::2005 and 8 others [full set in $collin.var])
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
RMSE: 0.537131     Adj. R2: 0.87167 
                 Within R2: 8.449e-4
> 
> # 2) Recover the treatment effects of interest with emfx().
> 
> emfx(mod)                 # simple average treatment effect (default)

    Term                 Contrast .Dtreat Estimate Std. Error     z Pr(>|z|)
 .Dtreat mean(TRUE) - mean(FALSE)    TRUE  -0.0506     0.0125 -4.05   <0.001
   2.5 %  97.5 %
 -0.0751 -0.0261

Prediction type:  response 
Columns: type, term, contrast, .Dtreat, estimate, std.error, statistic, p.value, conf.low, conf.high, predicted, predicted_hi, predicted_lo 

> emfx(mod, type = "event") # dynamic treatment effect a la an event study

    Term                 Contrast event Estimate Std. Error     z Pr(>|z|)
 .Dtreat mean(TRUE) - mean(FALSE)     0  -0.0332     0.0134 -2.48    0.013
 .Dtreat mean(TRUE) - mean(FALSE)     1  -0.0573     0.0172 -3.34   <0.001
 .Dtreat mean(TRUE) - mean(FALSE)     2  -0.1379     0.0308 -4.48   <0.001
 .Dtreat mean(TRUE) - mean(FALSE)     3  -0.1095     0.0323 -3.39   <0.001
   2.5 %   97.5 %
 -0.0594 -0.00701
 -0.0910 -0.02373
 -0.1982 -0.07751
 -0.1729 -0.04619

Prediction type:  response 
Columns: type, term, contrast, event, estimate, std.error, statistic, p.value, conf.low, conf.high, predicted, predicted_hi, predicted_lo 

> # Etc. Other aggregation types are "group" and "calendar"
> 
> 
> #
> # Heterogeneous treatment effects
> #
> 
> # Example where we estimate heterogeneous treatment effects for counties 
> # within the 8 US Great Lake states (versus all other counties). 
> 
> gls = c("IL" = 17, "IN" = 18, "MI" = 26, "MN" = 27,
+         "NY" = 36, "OH" = 39, "PA" = 42, "WI" = 55)
> 
> mpdta$gls = substr(mpdta$countyreal, 1, 2) %in% gls
> 
> hmod = etwfe(
+    lemp ~ lpop, tvar = year, gvar = first.treat, data = mpdta, 
+    vcov = ~countyreal,
+    xvar = gls           ## <= het. TEs by gls
+    )
> 
> # Heterogeneous ATEs (could also specify "event", etc.) 
> 
> emfx(hmod)
malloc(): unsorted double linked list corrupted
Aborted