Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question about manipulation of the local data matrix in the BAR example #4

Open
jagman88 opened this issue Sep 5, 2018 · 1 comment

Comments

@jagman88
Copy link

jagman88 commented Sep 5, 2018

Hi Paul,

Thanks so much for making this code available! I'm working with the R version of your code, but I have a question about the way you manipulate the "local" data matrix, as in the code block from your example below:

BAR_local %>%
    select(-sh_ind_) %>%
    mutate(ind = str_glue("t{year}_init_sh_ind_{ind}")) %>%
    spread(ind, init_sh_ind_, fill = 0) %>%
    print() -> BAR_local2

Why do you fill the init_sh_ind_ variable with zeros for the non-initial year entries? So your initial shares come from the year 1980, but you rework the data matrix so that the initial share is set equal to zero in all non-1980 years. Why are the shares not set equal to the initial shares in all years? Afterall, this is how the original data matrix is constructed.

Thanks for the help, and thanks again for the code! Very helpful!

@jjchern
Copy link
Contributor

jjchern commented Sep 5, 2018

Maybe I will let Paul expound on the design decision later, but the effect of the code is to generate the interactions between year dummies and the initial industry shares. For example, if I limit to industry no. 100, the code produces the following:

library(bartik.weight)

BAR_local %>%
    arrange(czone, ind, year) %>% 
    select(-sh_ind_) %>%
    mutate(ind = str_glue("t{year}_init_sh_ind_{ind}")) %>%
    spread(ind, init_sh_ind_, fill = 0) %>%
    select(czone, year, contains("ind_100"))

#> # A tibble: 2,166 x 5
#> czone year      t1980_init_sh_ind_100 t1990_init_sh_ind_100 t2000_init_sh_ind_100
#> <dbl> <dbl+lbl>                 <dbl>                 <dbl>                 <dbl>
#> 1  100. 1980                    0.00276               0.                    0.     
#> 2  100. 1990                    0.                    0.00276               0.     
#> 3  100. 2000                    0.                    0.                    0.00276
#> 4  200. 1980                    0.00290               0.                    0.     
#> 5  200. 1990                    0.                    0.00290               0.     
#> 6  200. 2000                    0.                    0.                    0.00290
#> 7  301. 1980                    0.00111               0.                    0.     
#> 8  301. 1990                    0.                    0.00111               0.     
#> 9  301. 2000                    0.                    0.                    0.00111
#> 10  302. 1980                    0.00388               0.                    0.     
#> # ... with 2,156 more rows

The corresponding Stata code is about here: https://github.com/paulgp/bartik-weight/blob/master/code/example_BAR.do#L25-L62.

These variables are being used later as a vector of IVs (https://github.com/paulgp/bartik-weight/blob/master/code/example_BAR.do#L85):

bartik_weight, z(t*_`ind_stub'*)    weightstub(nat1980_empl_ind_*) x(`x') y(`y')  controls(`controls') weight_var(`weight')  absorb(czone) by(year)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants