GithubHelp home page GithubHelp logo

bartik-weight's People

Contributors

jjchern avatar paulgp avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

bartik-weight's Issues

Issues with downloading the package

Having an issue with downloading the bartik-weight package.

Have tried the homebrew solutions here velocyto-team/velocyto.R#2 but have had no luck.
I don't know much about this, but from my cursory glance, it might be an issue with Mac OS (which is what I'm running this on)?
Pasting the error message below.

screen shot 2018-08-17 at 11 35 45 am

Help file displaying incorrectly

Not sure if it's just me but the help file doesn't seem to display properly (the curly braced content is still displayed rather than being formatted). Apparently it might be because SMCL doesn't like long lines of text (https://www.statalist.org/forums/forum/general-stata-discussion/general/1418403-stata-help-file-not-displayed-correctly).

Incorrect Display:

incorrect_display

I've modified the Stata help file so that it displays correctly on my machine but I don't want to do a PR if it's only an issue on my end! Happy to put mine up if it's not just me though.

Corrected Display:

corrected_display
.

Command in Stata reporting missing betas and alphas

Dear @paulgp,

Thank you very much for providing this wonderful resource. I have already implemented in a cross-section setting and everything worked pretty fine.

But I am having some trouble using the bartik_weight command in Stata with a panel dataset.

The structure of the data is very similar to the one of the BAR (canonical Bartik) example, I am only make the necessary adaptations in the replication code.

The issue is that the command is giving me missing betas and alphas. The code is not running into any error, but the resulting summary table does not have anything for the columns beta, alpha, gamma and pi.

Do you have any ideas on what might be causing this problem? Please let me know if you need more information/clarification.

Also, why the 'by(time_var)' option is not used in the BAR replication, since it is a panel? I also tried with it, but I get a conformability error.

Best,
Wagner Oliveira
PhD Candidate in Economics
FGV EPGE

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

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!

Weighting matrix is often too large; use sparse weights instead?

I am using the R version of the code, and I am finding that for moderately large datasets (e.g. >100,000 observations), the creation of the weighting matrix in the function bw produces non-sparse matrices that are much, much larger than memory allows.

Could these weights matrices be created as sparse matrices? For example, when no weights are given the function calls:

  if (is.null(weight)) {
    weight = diag(n)
  }

but the weight line could be replaced with weight = .sparseDiagonal(n) or weight = sparseMatrix(1:n, 1:n), both from the Matrix package. Since sparse matrices can be operated on in the same way as non-sparse matrices, this shouldn't cause any further issues, I think.

R package

Thanks for putting together the Stata command; it's quite helpful for understanding the paper as well.

I just reimplemented the code in R: https://github.com/jjchern/bartik.weight. If you're interested, I can submit an RP and put the package in the current repo (maybe in an R-package folder).

Also, I think there's a typo on page 9 of the paper. The residual projection matrix should be M_D = I - D(D'D)^{-1}D'. The last transpose is missing in the paper.

Codes for the Bartik-Weights in the Card Paper

Dear Paul Goldsmith-Pinkham & co-authors,

Thank you for your relevant work, and also for sharing with us codes and data to properly implement your methodology. I'm contacting you since I was particularly interested in the application related to the Immigration Enclave (example 3 in your "read me" document), however I was not able to find the suggested do-files in the "code" folder (namely, the make_rotemberg_summary_CARD_hs.do and make_rotemberg_summary_CARD_college.do). It would be possible to have access to them? That would be extremely helpful!

Thank you again
Best regards
Riccardo Turati

[PR] Individual data and shift matrix with multiple periods

Thank you @paulgp for this article and this package and thank you @jjchern for the R implementation.

I currently work on a migration project with indivual data. I want to implement a Bartik instrument similar to the one you present from Card (2009), so with a share matrix Z with $1$ period, $L$ localities and $K$ origins. However, I want to use it with shocks on multiple periods, so a shift matrix G with $K$ groups as before, but also $T$ periods instead of one as in Card (2009).

Hence I have two issues:

  1. The matrice Z with $L * 1$ rows does not match the main data with $N$ rows. This is linked to the issue #12 where the R documentation is not clear about the dimension of the matrices.
  2. The R implementation (and probably the stata one too) is done such that the matrix G has only one column.

I think I know how to fix these issue and implement the code but I would be glad if you could confirm it.

  1. Regarding the first issue, I just need to duplicate the rows in Z, such that they match with the rows in $Y$ and $X$. This should work technically but I am not sure if it creates issues with the instrument.
  2. If I modify the shape of $G$ of $K \times 1$ to $K \times T$, this should only affect the computation of the Rotemberg weights, $\alpha_k$, but it should not affect $\beta_k$, Gamma and pi.
    • Given $\alpha_k = \frac{g_k Z_k' X^\bot}{\sum_k g_k Z_k' X^\bot}$, if $g_k$ is of dimension $T \times K$ instead of $1 \times K$, $\alpha_k$ should be of dimension $T \times 1$ instead of $1$.
    • The stata and R implementations use the diagonalisation of the column matrix G to compute the weights for each group $k$. However, this does not work anymore if the matrix G has multiple columns.
    • This issue can be avoided by computing the weights independently for each period, using one column at a time, similar to computing a Bartik instrument for each period.
    • Hence, we would have the same results as before, with one coefficient $\beta_k$ by group $k$, but with $T$ coefficients $\alpha_k$ for each group, emphasizing a different importance of the groups depending on the period.

I am implementing the changes in the R code, so if you can confirm that I did not make any mistakes theoratically, I can submit a PR soon (https://github.com/MaelAstruc/bartik-weight).

Best regards,
Mael Astruc--Le Souder

Consider adding CI tests

While the package hasn't been updated in a while, it surely may be in the future. You might consider running some automated in-the-cloud tests.

  • see this workflow for an example on how to do that
  • you can post IPUMS extracts if they accompany a paper, which in this case is fine. Of course, you might want to explicitly subsample the data anyway to allow for smaller/faster tests for illustration only.

Installing Issue

Hi Paul,

I tried devtools::install_github("paulgp/bartik-weight/R-code/pkg") but had the following error. Could you help me figure out what is wrong?

Error: Failed to install 'bartik.weight' from GitHub:
  (converted from warning) installation of package ‘/var/folders/sq/8c5rcbd1197g_169brd3c6p80000gn/T//RtmpbG1f5I/file7342583b840/bartik.weight_0.1.0.tar.gz’ had non-zero exit status

My environment is as follows. Thank you!

> R.version
               _                           
platform       x86_64-apple-darwin17.0     
arch           x86_64                      
os             darwin17.0                  
system         x86_64, darwin17.0          
status                                     
major          4                           
minor          0.3                         
year           2020                        
month          10                          
day            10                          
svn rev        79318                       
language       R                           
version.string R version 4.0.3 (2020-10-10)
nickname       Bunny-Wunnies Freak Out

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.