paulgp / bartik-weight Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
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.
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:
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:
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
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!
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.
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.
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
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
Hence I have two issues:
I think I know how to fix these issue and implement the code but I would be glad if you could confirm it.
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
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.
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
Consider expanding the documentation of bartik.weight::bw() to highlight that the sorting of the data frames (master, local, global) need to match.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.