assignment_4

Author

Sam Kuhn

Part 1: Two-period DiD model

## Load data
#| echo: false
#| message: false
library(tidyverse)
── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr     1.1.1     ✔ readr     2.1.4
✔ forcats   1.0.0     ✔ stringr   1.5.0
✔ ggplot2   3.4.2     ✔ tibble    3.2.1
✔ lubridate 1.9.2     ✔ tidyr     1.3.0
✔ purrr     1.0.1     
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag()    masks stats::lag()
ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(haven)
library(gt)
library(modelsummary)
library(fixest)
library(plm)

Attaching package: 'plm'

The following objects are masked from 'package:dplyr':

    between, lag, lead
library(kableExtra)

Attaching package: 'kableExtra'

The following object is masked from 'package:dplyr':

    group_rows
library(sandwich)
library(lmtest)
Loading required package: zoo

Attaching package: 'zoo'

The following objects are masked from 'package:base':

    as.Date, as.Date.numeric
library(tidymodels)
── Attaching packages ────────────────────────────────────── tidymodels 1.0.0 ──
✔ broom        1.0.4     ✔ rsample      1.1.1
✔ dials        1.2.0     ✔ tune         1.1.1
✔ infer        1.0.4     ✔ workflows    1.1.3
✔ modeldata    1.1.0     ✔ workflowsets 1.0.1
✔ parsnip      1.1.0     ✔ yardstick    1.1.0
✔ recipes      1.0.5     
── Conflicts ───────────────────────────────────────── tidymodels_conflicts() ──
✖ plm::between()           masks dplyr::between()
✖ scales::discard()        masks purrr::discard()
✖ dplyr::filter()          masks stats::filter()
✖ recipes::fixed()         masks stringr::fixed()
✖ kableExtra::group_rows() masks dplyr::group_rows()
✖ plm::lag()               masks dplyr::lag(), stats::lag()
✖ plm::lead()              masks dplyr::lead()
✖ yardstick::spec()        masks readr::spec()
✖ recipes::step()          masks stats::step()
• Learn how to get started at https://www.tidymodels.org/start/
card_kreuger_df <- haven::read_dta(here::here("data", "CK1994.dta"))
wolfers_df <- haven::read_dta(here::here("data", "Wolfers2006.dta"))
davis_df <- haven::read_dta(here::here("data", "davis2004.dta"))
  • store = Unique store ID

  • empft = Number of full-time employees

  • state = 1 if New Jersey; = 0 if Pennsylvania

  • time = 0 if first survey (pre-treatment); = 1 if second survey (post-treatment)

1. Replicate table

card_kreuger_df |> 
  group_by(state, time) |> 
  summarise(mean_fte = mean(empft, na.rm = TRUE))
`summarise()` has grouped output by 'state'. You can override using the
`.groups` argument.
# A tibble: 4 × 3
# Groups:   state [2]
  state  time mean_fte
  <dbl> <dbl>    <dbl>
1     0     0    10.2 
2     0     1     7.56
3     1     0     7.72
4     1     1     8.45

2. Estimate model with SE clustered at store level

emp_mod <- fixest::feols(empft ~ state + time + time * state, data = card_kreuger_df)
NOTE: 18 observations removed because of NA values (LHS: 18).
modelsummary(emp_mod, stars = TRUE, vcov = cluster ~ store)
 (1)
(Intercept) 10.205***
(1.216)
state −2.481+
(1.294)
time −2.640+
(1.465)
state × time 3.362*
(1.558)
Num.Obs. 802
R2 0.008
R2 Adj. 0.004
AIC 5670.8
BIC 5689.6
RMSE 8.26
Std.Errors by: cluster
+ p < 0.1, * p < 0.05, ** p < 0.01, *** p < 0.001

6. Replicate figure 3

davis_df <- davis_df |> 
  mutate(
    year = forcats::as_factor(year),
    month = forcats::as_factor(month)
  ) |> 
  filter(year != 1990)
event_study_mod <- lm(
  lnprice ~ churchill * year + churchill + year + month,
  data = davis_df
)
summary(event_study_mod)

Call:
lm(formula = lnprice ~ churchill * year + churchill + year + 
    month, data = davis_df)

Residuals:
    Min      1Q  Median      3Q     Max 
-3.7707 -0.1844 -0.0063  0.2072  2.0352 

Coefficients:
                    Estimate Std. Error t value Pr(>|t|)    
(Intercept)        11.497154   0.027564 417.101  < 2e-16 ***
churchill          -0.046682   0.034748  -1.343   0.1792    
year1992            0.022004   0.031706   0.694   0.4877    
year1993            0.063271   0.030497   2.075   0.0380 *  
year1994            0.120416   0.029975   4.017 5.94e-05 ***
year1995            0.133013   0.029978   4.437 9.22e-06 ***
year1996            0.126841   0.028999   4.374 1.23e-05 ***
year1997            0.141944   0.029105   4.877 1.09e-06 ***
year1998            0.158305   0.028278   5.598 2.23e-08 ***
year1999            0.215051   0.027720   7.758 9.51e-15 ***
year2000            0.186322   0.027665   6.735 1.74e-11 ***
year2001            0.140443   0.026352   5.329 1.01e-07 ***
year2002            0.138837   0.027542   5.041 4.72e-07 ***
month2              0.006060   0.021226   0.286   0.7753    
month3             -0.006921   0.020246  -0.342   0.7325    
month4             -0.010801   0.020405  -0.529   0.5966    
month5              0.040074   0.019759   2.028   0.0426 *  
month6              0.036572   0.019352   1.890   0.0588 .  
month7              0.023666   0.019759   1.198   0.2311    
month8              0.018770   0.019448   0.965   0.3345    
month9              0.020120   0.020518   0.981   0.3268    
month10             0.015930   0.020828   0.765   0.4444    
month11             0.026813   0.020781   1.290   0.1970    
month12             0.023095   0.021394   1.080   0.2804    
churchill:year1992  0.032380   0.047899   0.676   0.4991    
churchill:year1993  0.056114   0.046107   1.217   0.2236    
churchill:year1994 -0.026657   0.044903  -0.594   0.5528    
churchill:year1995  0.021858   0.045725   0.478   0.6326    
churchill:year1996  0.012171   0.044373   0.274   0.7839    
churchill:year1997 -0.069225   0.045365  -1.526   0.1271    
churchill:year1998  0.057219   0.044130   1.297   0.1948    
churchill:year1999 -0.041111   0.043822  -0.938   0.3482    
churchill:year2000 -0.052800   0.044227  -1.194   0.2326    
churchill:year2001 -0.108164   0.043782  -2.470   0.0135 *  
churchill:year2002 -0.062697   0.044907  -1.396   0.1627    
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 0.3835 on 9544 degrees of freedom
Multiple R-squared:  0.029, Adjusted R-squared:  0.02554 
F-statistic: 8.384 on 34 and 9544 DF,  p-value: < 2.2e-16
coefficients <- coef(event_study_mod)
standard_errors <- summary(event_study_mod)$coefficients[, "Std. Error"] 
t.test(coefficients)

    One Sample t-test

data:  coefficients
t = 1.126, df = 34, p-value = 0.268
alternative hypothesis: true mean is not equal to 0
95 percent confidence interval:
 -0.2968455  1.0345245
sample estimates:
mean of x 
0.3688395 
plot(coefficients)

Part 2: Multi-period DiD

div_rate = Divorces per 1,000 people unilateral = Dummy for indicating the existence of a unilateral law in Friedberg time = Year since 1968 (matches Friedberg’s trends)

1. Replicate Friedberg results

friedberg_df <- wolfers_df |> 
  filter(year >= 1968) |> 
  mutate(year = as.factor(year))
friedberg_mod <- lm(
  div_rate ~ unilateral + st + year + divx1 + divx1 + divx2 + divx3 + divx4 + divx5 + divx6 +
    divx7 + divx8 + divx9 + divx10 + divx11 + divx12 +
    divx13 + divx14 + divx15 + divx16 + divx17,
  data = friedberg_df,
  weights = stpop
)
summary(friedberg_mod)

Call:
lm(formula = div_rate ~ unilateral + st + year + divx1 + divx1 + 
    divx2 + divx3 + divx4 + divx5 + divx6 + divx7 + divx8 + divx9 + 
    divx10 + divx11 + divx12 + divx13 + divx14 + divx15 + divx16 + 
    divx17, data = friedberg_df, weights = stpop)

Weighted Residuals:
    Min      1Q  Median      3Q     Max 
-7115.2  -374.1   -32.3   403.9  7784.5 

Coefficients:
            Estimate Std. Error t value Pr(>|t|)    
(Intercept)  5.06707    0.26780  18.921  < 2e-16 ***
unilateral  -0.11083    0.06573  -1.686 0.091993 .  
stAL        -0.62475    0.27124  -2.303 0.021411 *  
stAR        -0.04201    0.29571  -0.142 0.887039    
stAZ        -0.05257    0.27755  -0.189 0.849798    
stCA        -1.24315    0.26099  -4.763 2.11e-06 ***
stCO        -0.89256    0.27818  -3.209 0.001365 ** 
stCT        -3.21048    0.27531 -11.661  < 2e-16 ***
stDC        -2.29403    0.34824  -6.587 6.36e-11 ***
stDE        -2.26882    0.34455  -6.585 6.47e-11 ***
stFL        -0.18315    0.26194  -0.699 0.484523    
stGA        -1.20206    0.26652  -4.510 7.03e-06 ***
stHI        -2.19079    0.31052  -7.055 2.73e-12 ***
stIA        -3.04551    0.27647 -11.016  < 2e-16 ***
stID        -0.51227    0.31296  -1.637 0.101885    
stIL        -2.72905    0.26947 -10.128  < 2e-16 ***
stIN        -0.60311    0.41364  -1.458 0.145059    
stKS        -1.71220    0.28002  -6.115 1.26e-09 ***
stKY        -1.61270    0.27731  -5.816 7.51e-09 ***
stLA        -3.50989    0.31365 -11.191  < 2e-16 ***
stMA        -3.88082    0.26667 -14.553  < 2e-16 ***
stMD        -3.29400    0.27712 -11.887  < 2e-16 ***
stME        -1.94786    0.30582  -6.369 2.59e-10 ***
stMI        -2.38360    0.26307  -9.061  < 2e-16 ***
stMN        -3.29109    0.27047 -12.168  < 2e-16 ***
stMO        -1.79481    0.27568  -6.510 1.05e-10 ***
stMS        -1.76740    0.28969  -6.101 1.37e-09 ***
stMT        -1.34165    0.32326  -4.150 3.52e-05 ***
stNC        -2.21377    0.27372  -8.088 1.33e-15 ***
stND        -3.59721    0.33592 -10.709  < 2e-16 ***
stNE        -2.93066    0.29187 -10.041  < 2e-16 ***
stNH        -1.93805    0.31224  -6.207 7.14e-10 ***
stNJ        -3.64448    0.27213 -13.393  < 2e-16 ***
stNM         0.07052    0.32933   0.214 0.830467    
stNV         7.45922    0.32218  23.152  < 2e-16 ***
stNY        -3.65570    0.26748 -13.667  < 2e-16 ***
stOH        -2.04537    0.27047  -7.562 7.22e-14 ***
stOK         0.49306    0.27850   1.770 0.076874 .  
stOR        -1.00196    0.27821  -3.601 0.000328 ***
stPA        -3.68336    0.26911 -13.687  < 2e-16 ***
stRI        -3.42723    0.31203 -10.984  < 2e-16 ***
stSC        -2.92654    0.28192 -10.381  < 2e-16 ***
stSD        -3.21231    0.33285  -9.651  < 2e-16 ***
stTN        -0.67895    0.27663  -2.454 0.014237 *  
stTX        -0.91611    0.26066  -3.515 0.000455 ***
stUT        -1.89858    0.29998  -6.329 3.34e-10 ***
stVA        -2.63024    0.27454  -9.581  < 2e-16 ***
stVT        -2.58268    0.35862  -7.202 9.78e-13 ***
stWA        -0.65364    0.26992  -2.422 0.015580 *  
stWI        -3.50215    0.27623 -12.678  < 2e-16 ***
stWV        -2.00097    0.29384  -6.810 1.46e-11 ***
stWY         0.27079    0.36821   0.735 0.462211    
year1969     0.23780    0.09657   2.462 0.013921 *  
year1970     0.57334    0.09751   5.880 5.15e-09 ***
year1971     0.79920    0.09731   8.213 4.95e-16 ***
year1972     1.12252    0.09779  11.478  < 2e-16 ***
year1973     1.41298    0.09918  14.246  < 2e-16 ***
year1974     1.67120    0.09991  16.727  < 2e-16 ***
year1975     1.90566    0.10060  18.944  < 2e-16 ***
year1976     2.03901    0.09992  20.407  < 2e-16 ***
year1977     1.99036    0.09997  19.910  < 2e-16 ***
year1978     2.12707    0.09923  21.436  < 2e-16 ***
year1979     2.29303    0.09911  23.135  < 2e-16 ***
year1980     2.27209    0.09889  22.976  < 2e-16 ***
year1981     2.29419    0.09941  23.078  < 2e-16 ***
year1982     2.05477    0.09891  20.775  < 2e-16 ***
year1983     1.95787    0.09861  19.854  < 2e-16 ***
year1984     1.98117    0.09998  19.816  < 2e-16 ***
year1985     1.97939    0.09985  19.823  < 2e-16 ***
year1986     1.88831    0.09923  19.029  < 2e-16 ***
year1987     1.76571    0.09834  17.955  < 2e-16 ***
year1988     1.79496    0.10095  17.781  < 2e-16 ***
year1989     1.74997    0.09932  17.619  < 2e-16 ***
year1990     1.66805    0.09760  17.090  < 2e-16 ***
year1991     1.88744    0.10337  18.259  < 2e-16 ***
year1992     1.83963    0.10036  18.331  < 2e-16 ***
year1993     1.64780    0.10000  16.478  < 2e-16 ***
year1994     1.61526    0.09992  16.166  < 2e-16 ***
year1995     1.47180    0.09994  14.727  < 2e-16 ***
year1996     1.40306    0.10176  13.788  < 2e-16 ***
year1997     1.36227    0.09958  13.681  < 2e-16 ***
divx1       -1.06699    0.21787  -4.897 1.09e-06 ***
divx2       -0.25144    0.36689  -0.685 0.493252    
divx3        0.01802    0.27665   0.065 0.948076    
divx4       -1.41094    0.97294  -1.450 0.147239    
divx5        1.49751    0.60391   2.480 0.013269 *  
divx6       -0.36588    0.12449  -2.939 0.003347 ** 
divx7       -0.03512    0.14639  -0.240 0.810444    
divx8        0.22881    0.32964   0.694 0.487726    
divx9       -0.30660    0.28116  -1.090 0.275689    
divx10       0.51908    0.28605   1.815 0.069796 .  
divx11       1.39960    0.33843   4.136 3.76e-05 ***
divx12       0.63911    0.43572   1.467 0.142662    
divx13      -0.06761    0.32708  -0.207 0.836281    
divx14      -0.80150    0.87965  -0.911 0.362369    
divx15      -0.49463    0.61014  -0.811 0.417687    
divx16      -0.89571    0.49645  -1.804 0.071415 .  
divx17      -0.93591    0.14349  -6.522 9.71e-11 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 955.2 on 1369 degrees of freedom
  (114 observations deleted due to missingness)
Multiple R-squared:  0.9166,    Adjusted R-squared:  0.9107 
F-statistic: 155.1 on 97 and 1369 DF,  p-value: < 2.2e-16

2. State time-trend

friedberg_time_trend_mod <- lm(
  div_rate ~ unilateral + st + year + st*time + divx1 + divx1 + divx2 + divx3 + divx4 + divx5 + divx6 +
    divx7 + divx8 + divx9 + divx10 + divx11 + divx12 +
    divx13 + divx14 + divx15 + divx16 + divx17,
  data = friedberg_df,
  weights = stpop
)
summary(friedberg_time_trend_mod)

Call:
lm(formula = div_rate ~ unilateral + st + year + st * time + 
    divx1 + divx1 + divx2 + divx3 + divx4 + divx5 + divx6 + divx7 + 
    divx8 + divx9 + divx10 + divx11 + divx12 + divx13 + divx14 + 
    divx15 + divx16 + divx17, data = friedberg_df, weights = stpop)

Weighted Residuals:
    Min      1Q  Median      3Q     Max 
-2347.5  -255.6   -18.9   245.3  3283.7 

Coefficients: (1 not defined because of singularities)
            Estimate Std. Error t value Pr(>|t|)    
(Intercept)  6.13484    0.33243  18.454  < 2e-16 ***
unilateral   0.35995    0.04710   7.642 4.09e-14 ***
stAL        -2.21819    0.34465  -6.436 1.71e-10 ***
stAR        -1.21064    0.36345  -3.331 0.000890 ***
stAZ        -0.61984    0.37138  -1.669 0.095354 .  
stCA        -1.73461    0.33276  -5.213 2.16e-07 ***
stCO        -1.80192    0.35413  -5.088 4.13e-07 ***
stCT        -4.43994    0.34818 -12.752  < 2e-16 ***
stDC        -2.79523    0.40727  -6.863 1.03e-11 ***
stDE        -3.55875    0.42056  -8.462  < 2e-16 ***
stFL        -0.72298    0.33587  -2.153 0.031536 *  
stGA        -2.51095    0.34081  -7.368 3.05e-13 ***
stHI        -3.21549    0.39181  -8.207 5.35e-16 ***
stIA        -4.55194    0.34876 -13.052  < 2e-16 ***
stID        -1.83925    0.39461  -4.661 3.47e-06 ***
stIL        -3.24559    0.33683  -9.636  < 2e-16 ***
stIN        -1.58009    0.43190  -3.658 0.000264 ***
stKS        -2.98295    0.35329  -8.443  < 2e-16 ***
stKY        -3.98761    0.34863 -11.438  < 2e-16 ***
stLA        -4.57418    0.41963 -10.900  < 2e-16 ***
stMA        -4.77615    0.34030 -14.035  < 2e-16 ***
stMD        -4.10916    0.34561 -11.890  < 2e-16 ***
stME        -2.90108    0.38233  -7.588 6.11e-14 ***
stMI        -3.43964    0.33558 -10.250  < 2e-16 ***
stMN        -4.68562    0.34441 -13.605  < 2e-16 ***
stMO        -2.76674    0.34366  -8.051 1.82e-15 ***
stMS        -3.06931    0.35633  -8.614  < 2e-16 ***
stMT        -2.12167    0.40179  -5.280 1.51e-07 ***
stNC        -4.09257    0.34220 -11.960  < 2e-16 ***
stND        -5.45053    0.41163 -13.241  < 2e-16 ***
stNE        -4.49961    0.36570 -12.304  < 2e-16 ***
stNH        -3.09846    0.39412  -7.862 7.82e-15 ***
stNJ        -4.98961    0.33960 -14.692  < 2e-16 ***
stNM        -0.26663    0.43861  -0.608 0.543359    
stNV        13.32212    0.41255  32.292  < 2e-16 ***
stNY        -5.10003    0.33486 -15.230  < 2e-16 ***
stOH        -2.85980    0.33726  -8.480  < 2e-16 ***
stOK        -0.50579    0.36239  -1.396 0.163042    
stOR        -1.59473    0.35393  -4.506 7.20e-06 ***
stPA        -4.93340    0.33655 -14.659  < 2e-16 ***
stRI        -5.03652    0.38735 -13.003  < 2e-16 ***
stSC        -4.55700    0.35170 -12.957  < 2e-16 ***
stSD        -4.69414    0.41031 -11.440  < 2e-16 ***
stTN        -2.27711    0.34528  -6.595 6.14e-11 ***
stTX        -1.86135    0.33451  -5.564 3.18e-08 ***
stUT        -2.84604    0.37607  -7.568 7.09e-14 ***
stVA        -4.21512    0.34318 -12.283  < 2e-16 ***
stVT        -4.39395    0.43805 -10.031  < 2e-16 ***
stWA        -1.10614    0.34491  -3.207 0.001373 ** 
stWI        -4.85411    0.34428 -14.099  < 2e-16 ***
stWV        -3.63577    0.36257 -10.028  < 2e-16 ***
stWY        -0.64536    0.46144  -1.399 0.162178    
year1969     0.15354    0.05866   2.617 0.008962 ** 
year1970     0.36073    0.06684   5.397 8.02e-08 ***
year1971     0.47297    0.07776   6.083 1.55e-09 ***
year1972     0.68519    0.09106   7.525 9.74e-14 ***
year1973     0.84885    0.10600   8.008 2.53e-15 ***
year1974     0.98606    0.12155   8.113 1.12e-15 ***
year1975     1.12508    0.13754   8.180 6.62e-16 ***
year1976     1.18008    0.15359   7.683 3.01e-14 ***
year1977     1.05378    0.17014   6.194 7.84e-10 ***
year1978     1.10898    0.18673   5.939 3.67e-09 ***
year1979     1.19799    0.20364   5.883 5.11e-09 ***
year1980     1.10131    0.22068   4.991 6.82e-07 ***
year1981     1.05076    0.23791   4.417 1.08e-05 ***
year1982     0.73549    0.25511   2.883 0.004003 ** 
year1983     0.56351    0.27239   2.069 0.038764 *  
year1984     0.43894    0.28983   1.514 0.130141    
year1985     0.36477    0.30721   1.187 0.235287    
year1986     0.20339    0.32456   0.627 0.530986    
year1987     0.08846    0.34202   0.259 0.795952    
year1988    -0.07860    0.35963  -0.219 0.827018    
year1989    -0.19009    0.37700  -0.504 0.614181    
year1990    -0.21879    0.39453  -0.555 0.579295    
year1991    -0.24775    0.41235  -0.601 0.548060    
year1992    -0.36951    0.42970  -0.860 0.389986    
year1993    -0.62213    0.44724  -1.391 0.164452    
year1994    -0.76156    0.46482  -1.638 0.101581    
year1995    -0.96388    0.48242  -1.998 0.045922 *  
year1996    -1.13842    0.50013  -2.276 0.022992 *  
year1997    -1.23215    0.51763  -2.380 0.017436 *  
time              NA         NA      NA       NA    
divx1       -0.94947    0.12722  -7.463 1.52e-13 ***
divx2       -0.20470    0.21240  -0.964 0.335361    
divx3        0.09459    0.16283   0.581 0.561418    
divx4       -1.98683    0.61119  -3.251 0.001180 ** 
divx5        1.39710    0.35086   3.982 7.21e-05 ***
divx6        0.32442    0.07996   4.057 5.26e-05 ***
divx7       -0.01164    0.08482  -0.137 0.890876    
divx8        0.19034    0.19895   0.957 0.338890    
divx9       -0.46047    0.17831  -2.582 0.009917 ** 
divx10       0.18022    0.19708   0.914 0.360625    
divx11       1.03614    0.24410   4.245 2.34e-05 ***
divx12       0.74295    0.26031   2.854 0.004383 ** 
divx13       0.02253    0.19054   0.118 0.905881    
divx14      -0.58089    0.51970  -1.118 0.263875    
divx15      -0.57405    0.35533  -1.616 0.106439    
divx16      -0.80496    0.28945  -2.781 0.005497 ** 
divx17       0.07169    0.09751   0.735 0.462321    
stAL:time    0.10022    0.01875   5.346 1.06e-07 ***
stAR:time    0.09930    0.01947   5.099 3.91e-07 ***
stAZ:time    0.04070    0.01978   2.058 0.039781 *  
stCA:time   -0.00719    0.01837  -0.391 0.695549    
stCO:time    0.05277    0.01957   2.696 0.007098 ** 
stCT:time    0.07799    0.01902   4.101 4.36e-05 ***
stDC:time    0.05066    0.02352   2.154 0.031430 *  
stDE:time    0.10827    0.02307   4.693 2.98e-06 ***
stFL:time    0.03473    0.01816   1.913 0.055940 .  
stGA:time    0.08291    0.01845   4.493 7.63e-06 ***
stHI:time    0.06474    0.02140   3.025 0.002536 ** 
stIA:time    0.09402    0.01907   4.929 9.31e-07 ***
stID:time    0.08236    0.02154   3.823 0.000138 ***
stIL:time    0.05569    0.01811   3.076 0.002143 ** 
stIN:time    0.05804    0.02182   2.661 0.007897 ** 
stKS:time    0.07688    0.01929   3.984 7.14e-05 ***
stKY:time    0.15173    0.01885   8.048 1.86e-15 ***
stLA:time    0.09836    0.03001   3.277 0.001076 ** 
stMA:time    0.05748    0.01847   3.112 0.001900 ** 
stMD:time    0.07713    0.01861   4.145 3.61e-05 ***
stME:time    0.05893    0.02120   2.780 0.005518 ** 
stMI:time    0.06505    0.01820   3.573 0.000366 ***
stMN:time    0.08995    0.01871   4.808 1.70e-06 ***
stMO:time    0.08744    0.01852   4.722 2.58e-06 ***
stMS:time    0.10936    0.01927   5.675 1.71e-08 ***
stMT:time    0.05001    0.02219   2.253 0.024398 *  
stNC:time    0.14600    0.01838   7.942 4.24e-15 ***
stND:time    0.11875    0.02303   5.156 2.91e-07 ***
stNE:time    0.10005    0.02009   4.980 7.19e-07 ***
stNH:time    0.07182    0.02151   3.339 0.000863 ***
stNJ:time    0.11307    0.01828   6.185 8.26e-10 ***
stNM:time    0.02894    0.02276   1.272 0.203740    
stNV:time   -0.35004    0.02225 -15.736  < 2e-16 ***
stNY:time    0.12000    0.01797   6.676 3.60e-11 ***
stOH:time    0.07640    0.01811   4.218 2.64e-05 ***
stOK:time    0.06152    0.01954   3.148 0.001681 ** 
stOR:time    0.03706    0.01923   1.927 0.054143 .  
stPA:time    0.10657    0.01808   5.893 4.80e-09 ***
stRI:time    0.10718    0.02142   5.004 6.39e-07 ***
stSC:time    0.12994    0.01895   6.858 1.07e-11 ***
stSD:time    0.10794    0.02272   4.752 2.24e-06 ***
stTN:time    0.12844    0.01858   6.911 7.46e-12 ***
stTX:time    0.06008    0.01810   3.319 0.000928 ***
stUT:time    0.08593    0.02022   4.249 2.29e-05 ***
stVA:time    0.12690    0.01844   6.882 9.09e-12 ***
stVT:time    0.14236    0.02412   5.903 4.54e-09 ***
stWA:time    0.02908    0.01868   1.557 0.119709    
stWI:time    0.11292    0.01855   6.087 1.51e-09 ***
stWV:time    0.13313    0.01978   6.732 2.49e-11 ***
stWY:time    0.06081    0.02558   2.377 0.017605 *  
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 553 on 1319 degrees of freedom
  (114 observations deleted due to missingness)
Multiple R-squared:  0.9731,    Adjusted R-squared:  0.9701 
F-statistic: 324.2 on 147 and 1319 DF,  p-value: < 2.2e-16

3. State time-trend quadatric term

friedberg_time_trend_qd_mod <- lm(
  div_rate ~ unilateral + st + year + time + st*time + divx1 + divx1 + divx2 + divx3 + divx4 + divx5 + divx6 +
    divx7 + divx8 + divx9 + divx10 + divx11 + divx12 +
    divx13 + divx14 + divx15 + divx16 + divx17,
  data = friedberg_df,
  weights = stpop
)
summary(friedberg_time_trend_qd_mod)

Call:
lm(formula = div_rate ~ unilateral + st + year + time + st * 
    time + divx1 + divx1 + divx2 + divx3 + divx4 + divx5 + divx6 + 
    divx7 + divx8 + divx9 + divx10 + divx11 + divx12 + divx13 + 
    divx14 + divx15 + divx16 + divx17, data = friedberg_df, weights = stpop)

Weighted Residuals:
    Min      1Q  Median      3Q     Max 
-2347.5  -255.6   -18.9   245.3  3283.7 

Coefficients: (1 not defined because of singularities)
            Estimate Std. Error t value Pr(>|t|)    
(Intercept)  6.13484    0.33243  18.454  < 2e-16 ***
unilateral   0.35995    0.04710   7.642 4.09e-14 ***
stAL        -2.21819    0.34465  -6.436 1.71e-10 ***
stAR        -1.21064    0.36345  -3.331 0.000890 ***
stAZ        -0.61984    0.37138  -1.669 0.095354 .  
stCA        -1.73461    0.33276  -5.213 2.16e-07 ***
stCO        -1.80192    0.35413  -5.088 4.13e-07 ***
stCT        -4.43994    0.34818 -12.752  < 2e-16 ***
stDC        -2.79523    0.40727  -6.863 1.03e-11 ***
stDE        -3.55875    0.42056  -8.462  < 2e-16 ***
stFL        -0.72298    0.33587  -2.153 0.031536 *  
stGA        -2.51095    0.34081  -7.368 3.05e-13 ***
stHI        -3.21549    0.39181  -8.207 5.35e-16 ***
stIA        -4.55194    0.34876 -13.052  < 2e-16 ***
stID        -1.83925    0.39461  -4.661 3.47e-06 ***
stIL        -3.24559    0.33683  -9.636  < 2e-16 ***
stIN        -1.58009    0.43190  -3.658 0.000264 ***
stKS        -2.98295    0.35329  -8.443  < 2e-16 ***
stKY        -3.98761    0.34863 -11.438  < 2e-16 ***
stLA        -4.57418    0.41963 -10.900  < 2e-16 ***
stMA        -4.77615    0.34030 -14.035  < 2e-16 ***
stMD        -4.10916    0.34561 -11.890  < 2e-16 ***
stME        -2.90108    0.38233  -7.588 6.11e-14 ***
stMI        -3.43964    0.33558 -10.250  < 2e-16 ***
stMN        -4.68562    0.34441 -13.605  < 2e-16 ***
stMO        -2.76674    0.34366  -8.051 1.82e-15 ***
stMS        -3.06931    0.35633  -8.614  < 2e-16 ***
stMT        -2.12167    0.40179  -5.280 1.51e-07 ***
stNC        -4.09257    0.34220 -11.960  < 2e-16 ***
stND        -5.45053    0.41163 -13.241  < 2e-16 ***
stNE        -4.49961    0.36570 -12.304  < 2e-16 ***
stNH        -3.09846    0.39412  -7.862 7.82e-15 ***
stNJ        -4.98961    0.33960 -14.692  < 2e-16 ***
stNM        -0.26663    0.43861  -0.608 0.543359    
stNV        13.32212    0.41255  32.292  < 2e-16 ***
stNY        -5.10003    0.33486 -15.230  < 2e-16 ***
stOH        -2.85980    0.33726  -8.480  < 2e-16 ***
stOK        -0.50579    0.36239  -1.396 0.163042    
stOR        -1.59473    0.35393  -4.506 7.20e-06 ***
stPA        -4.93340    0.33655 -14.659  < 2e-16 ***
stRI        -5.03652    0.38735 -13.003  < 2e-16 ***
stSC        -4.55700    0.35170 -12.957  < 2e-16 ***
stSD        -4.69414    0.41031 -11.440  < 2e-16 ***
stTN        -2.27711    0.34528  -6.595 6.14e-11 ***
stTX        -1.86135    0.33451  -5.564 3.18e-08 ***
stUT        -2.84604    0.37607  -7.568 7.09e-14 ***
stVA        -4.21512    0.34318 -12.283  < 2e-16 ***
stVT        -4.39395    0.43805 -10.031  < 2e-16 ***
stWA        -1.10614    0.34491  -3.207 0.001373 ** 
stWI        -4.85411    0.34428 -14.099  < 2e-16 ***
stWV        -3.63577    0.36257 -10.028  < 2e-16 ***
stWY        -0.64536    0.46144  -1.399 0.162178    
year1969     0.15354    0.05866   2.617 0.008962 ** 
year1970     0.36073    0.06684   5.397 8.02e-08 ***
year1971     0.47297    0.07776   6.083 1.55e-09 ***
year1972     0.68519    0.09106   7.525 9.74e-14 ***
year1973     0.84885    0.10600   8.008 2.53e-15 ***
year1974     0.98606    0.12155   8.113 1.12e-15 ***
year1975     1.12508    0.13754   8.180 6.62e-16 ***
year1976     1.18008    0.15359   7.683 3.01e-14 ***
year1977     1.05378    0.17014   6.194 7.84e-10 ***
year1978     1.10898    0.18673   5.939 3.67e-09 ***
year1979     1.19799    0.20364   5.883 5.11e-09 ***
year1980     1.10131    0.22068   4.991 6.82e-07 ***
year1981     1.05076    0.23791   4.417 1.08e-05 ***
year1982     0.73549    0.25511   2.883 0.004003 ** 
year1983     0.56351    0.27239   2.069 0.038764 *  
year1984     0.43894    0.28983   1.514 0.130141    
year1985     0.36477    0.30721   1.187 0.235287    
year1986     0.20339    0.32456   0.627 0.530986    
year1987     0.08846    0.34202   0.259 0.795952    
year1988    -0.07860    0.35963  -0.219 0.827018    
year1989    -0.19009    0.37700  -0.504 0.614181    
year1990    -0.21879    0.39453  -0.555 0.579295    
year1991    -0.24775    0.41235  -0.601 0.548060    
year1992    -0.36951    0.42970  -0.860 0.389986    
year1993    -0.62213    0.44724  -1.391 0.164452    
year1994    -0.76156    0.46482  -1.638 0.101581    
year1995    -0.96388    0.48242  -1.998 0.045922 *  
year1996    -1.13842    0.50013  -2.276 0.022992 *  
year1997    -1.23215    0.51763  -2.380 0.017436 *  
time              NA         NA      NA       NA    
divx1       -0.94947    0.12722  -7.463 1.52e-13 ***
divx2       -0.20470    0.21240  -0.964 0.335361    
divx3        0.09459    0.16283   0.581 0.561418    
divx4       -1.98683    0.61119  -3.251 0.001180 ** 
divx5        1.39710    0.35086   3.982 7.21e-05 ***
divx6        0.32442    0.07996   4.057 5.26e-05 ***
divx7       -0.01164    0.08482  -0.137 0.890876    
divx8        0.19034    0.19895   0.957 0.338890    
divx9       -0.46047    0.17831  -2.582 0.009917 ** 
divx10       0.18022    0.19708   0.914 0.360625    
divx11       1.03614    0.24410   4.245 2.34e-05 ***
divx12       0.74295    0.26031   2.854 0.004383 ** 
divx13       0.02253    0.19054   0.118 0.905881    
divx14      -0.58089    0.51970  -1.118 0.263875    
divx15      -0.57405    0.35533  -1.616 0.106439    
divx16      -0.80496    0.28945  -2.781 0.005497 ** 
divx17       0.07169    0.09751   0.735 0.462321    
stAL:time    0.10022    0.01875   5.346 1.06e-07 ***
stAR:time    0.09930    0.01947   5.099 3.91e-07 ***
stAZ:time    0.04070    0.01978   2.058 0.039781 *  
stCA:time   -0.00719    0.01837  -0.391 0.695549    
stCO:time    0.05277    0.01957   2.696 0.007098 ** 
stCT:time    0.07799    0.01902   4.101 4.36e-05 ***
stDC:time    0.05066    0.02352   2.154 0.031430 *  
stDE:time    0.10827    0.02307   4.693 2.98e-06 ***
stFL:time    0.03473    0.01816   1.913 0.055940 .  
stGA:time    0.08291    0.01845   4.493 7.63e-06 ***
stHI:time    0.06474    0.02140   3.025 0.002536 ** 
stIA:time    0.09402    0.01907   4.929 9.31e-07 ***
stID:time    0.08236    0.02154   3.823 0.000138 ***
stIL:time    0.05569    0.01811   3.076 0.002143 ** 
stIN:time    0.05804    0.02182   2.661 0.007897 ** 
stKS:time    0.07688    0.01929   3.984 7.14e-05 ***
stKY:time    0.15173    0.01885   8.048 1.86e-15 ***
stLA:time    0.09836    0.03001   3.277 0.001076 ** 
stMA:time    0.05748    0.01847   3.112 0.001900 ** 
stMD:time    0.07713    0.01861   4.145 3.61e-05 ***
stME:time    0.05893    0.02120   2.780 0.005518 ** 
stMI:time    0.06505    0.01820   3.573 0.000366 ***
stMN:time    0.08995    0.01871   4.808 1.70e-06 ***
stMO:time    0.08744    0.01852   4.722 2.58e-06 ***
stMS:time    0.10936    0.01927   5.675 1.71e-08 ***
stMT:time    0.05001    0.02219   2.253 0.024398 *  
stNC:time    0.14600    0.01838   7.942 4.24e-15 ***
stND:time    0.11875    0.02303   5.156 2.91e-07 ***
stNE:time    0.10005    0.02009   4.980 7.19e-07 ***
stNH:time    0.07182    0.02151   3.339 0.000863 ***
stNJ:time    0.11307    0.01828   6.185 8.26e-10 ***
stNM:time    0.02894    0.02276   1.272 0.203740    
stNV:time   -0.35004    0.02225 -15.736  < 2e-16 ***
stNY:time    0.12000    0.01797   6.676 3.60e-11 ***
stOH:time    0.07640    0.01811   4.218 2.64e-05 ***
stOK:time    0.06152    0.01954   3.148 0.001681 ** 
stOR:time    0.03706    0.01923   1.927 0.054143 .  
stPA:time    0.10657    0.01808   5.893 4.80e-09 ***
stRI:time    0.10718    0.02142   5.004 6.39e-07 ***
stSC:time    0.12994    0.01895   6.858 1.07e-11 ***
stSD:time    0.10794    0.02272   4.752 2.24e-06 ***
stTN:time    0.12844    0.01858   6.911 7.46e-12 ***
stTX:time    0.06008    0.01810   3.319 0.000928 ***
stUT:time    0.08593    0.02022   4.249 2.29e-05 ***
stVA:time    0.12690    0.01844   6.882 9.09e-12 ***
stVT:time    0.14236    0.02412   5.903 4.54e-09 ***
stWA:time    0.02908    0.01868   1.557 0.119709    
stWI:time    0.11292    0.01855   6.087 1.51e-09 ***
stWV:time    0.13313    0.01978   6.732 2.49e-11 ***
stWY:time    0.06081    0.02558   2.377 0.017605 *  
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 553 on 1319 degrees of freedom
  (114 observations deleted due to missingness)
Multiple R-squared:  0.9731,    Adjusted R-squared:  0.9701 
F-statistic: 324.2 on 147 and 1319 DF,  p-value: < 2.2e-16

5.

wolfers_df$years_unilateral <- as.factor(wolfers_df$years_unilateral)
wolfers_df$year <- as.factor(wolfers_df$year)
wolfers_mod <- 
  lm(div_rate ~ years_unilateral + st + year, 
     data = wolfers_df,
     subset = years_unilateral != -99,
     weights = stpop)
summary(wolfers_mod)

Call:
lm(formula = div_rate ~ years_unilateral + st + year, data = wolfers_df, 
    subset = years_unilateral != -99, weights = stpop)

Weighted Residuals:
    Min      1Q  Median      3Q     Max 
-5482.4  -393.2    -6.3   411.0  5504.9 

Coefficients:
                   Estimate Std. Error t value Pr(>|t|)    
(Intercept)         4.48199    0.64358   6.964 7.41e-12 ***
years_unilateral3   0.22628    0.10597   2.135 0.033066 *  
years_unilateral5   0.35389    0.12196   2.902 0.003824 ** 
years_unilateral7   0.51268    0.13973   3.669 0.000261 ***
years_unilateral9   0.37686    0.15391   2.449 0.014577 *  
years_unilateral11  0.24264    0.16624   1.460 0.144848    
years_unilateral13  0.19090    0.17750   1.076 0.282506    
years_unilateral15  0.22420    0.18883   1.187 0.235474    
stAL               -0.37775    0.25344  -1.490 0.136531    
stAZ                0.15207    0.26111   0.582 0.560476    
stCA               -1.38927    0.23854  -5.824 8.62e-09 ***
stCO               -0.76419    0.26156  -2.922 0.003590 ** 
stCT               -2.95653    0.26289 -11.246  < 2e-16 ***
stFL               -0.02908    0.24309  -0.120 0.904819    
stGA               -0.93870    0.25191  -3.726 0.000209 ***
stHI               -2.00171    0.30100  -6.650 5.76e-11 ***
stIA               -2.96149    0.25744 -11.504  < 2e-16 ***
stID               -0.33818    0.29753  -1.137 0.256065    
stIN               -0.26199    0.26378  -0.993 0.320934    
stKS               -1.61629    0.25953  -6.228 8.01e-10 ***
stKY               -1.57497    0.25684  -6.132 1.42e-09 ***
stMA               -3.68961    0.25781 -14.311  < 2e-16 ***
stME               -1.76270    0.29730  -5.929 4.71e-09 ***
stMI               -2.22281    0.24610  -9.032  < 2e-16 ***
stMN               -3.02449    0.25934 -11.662  < 2e-16 ***
stMT               -1.16406    0.32491  -3.583 0.000363 ***
stND               -3.39933    0.32406 -10.490  < 2e-16 ***
stNE               -2.70813    0.27886  -9.711  < 2e-16 ***
stNH               -1.66908    0.29693  -5.621 2.71e-08 ***
stNM                0.21633    0.29481   0.734 0.463303    
stNV                6.48367    0.30989  20.923  < 2e-16 ***
stOK                0.69402    0.24146   2.874 0.004168 ** 
stOR               -0.81950    0.26517  -3.090 0.002075 ** 
stRI               -2.95949    0.31793  -9.309  < 2e-16 ***
stSD               -2.49750    0.41670  -5.994 3.23e-09 ***
stTX               -0.72986    0.24763  -2.947 0.003308 ** 
stWA               -0.50263    0.25570  -1.966 0.049713 *  
stWY                0.55521    0.38521   1.441 0.149922    
year1957           -0.32995    0.84625  -0.390 0.696727    
year1958           -0.22560    0.84810  -0.266 0.790307    
year1959           -0.14179    0.84800  -0.167 0.867254    
year1960           -1.09919    0.84377  -1.303 0.193087    
year1961           -0.84863    0.84174  -1.008 0.313699    
year1962           -0.94858    0.83759  -1.133 0.257792    
year1963           -0.64597    0.83786  -0.771 0.440973    
year1964           -0.45628    0.83684  -0.545 0.585757    
year1965           -0.56084    0.83853  -0.669 0.503807    
year1966           -0.48077    0.83752  -0.574 0.566125    
year1967           -0.31087    0.83642  -0.372 0.710251    
year1968            0.27873    0.83497   0.334 0.738616    
year1969            0.62640    0.73951   0.847 0.397242    
year1970            2.16805    0.63654   3.406 0.000695 ***
year1971            1.67375    0.62699   2.669 0.007767 ** 
year1972            1.76200    0.61857   2.849 0.004516 ** 
year1973            1.94735    0.61506   3.166 0.001610 ** 
year1974            2.10866    0.61426   3.433 0.000631 ***
year1975            2.26488    0.61434   3.687 0.000244 ***
year1976            2.26066    0.61454   3.679 0.000252 ***
year1977            2.11784    0.61712   3.432 0.000634 ***
year1978            2.19018    0.61979   3.534 0.000436 ***
year1979            2.31333    0.62227   3.718 0.000217 ***
year1980            2.33392    0.62445   3.738 0.000200 ***
year1981            2.34800    0.62691   3.745 0.000194 ***
year1982            2.05869    0.62919   3.272 0.001118 ** 
year1983            1.95340    0.63159   3.093 0.002059 ** 
year1984            2.01731    0.63443   3.180 0.001537 ** 
year1985            2.02866    0.63712   3.184 0.001514 ** 
year1986            1.91750    0.63922   3.000 0.002795 ** 
year1987            1.79335    0.64158   2.795 0.005324 ** 
year1988            1.66227    0.64334   2.584 0.009965 ** 
year1989            1.62320    0.64396   2.521 0.011928 *  
year1990            1.62377    0.64398   2.521 0.011900 *  
year1991            1.90992    0.64705   2.952 0.003262 ** 
year1992            1.79700    0.64680   2.778 0.005605 ** 
year1993            1.52256    0.64670   2.354 0.018821 *  
year1994            1.53688    0.64669   2.377 0.017734 *  
year1995            1.37549    0.64692   2.126 0.033822 *  
year1996            1.18113    0.64747   1.824 0.068528 .  
year1997            1.15883    0.64682   1.792 0.073617 .  
year1998            0.93896    0.64675   1.452 0.146991    
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 941.5 on 726 degrees of freedom
  (34 observations deleted due to missingness)
Multiple R-squared:  0.896, Adjusted R-squared:  0.8847 
F-statistic: 79.17 on 79 and 726 DF,  p-value: < 2.2e-16