Saturday, June 30, 2018

Some Stata Tricks: State FIPS codes and Asserting Things

Picture this: You are using individual data from one data source (actually, in my case, it was nursing home level data), but you want to merge in state-level data from a different data source. The good news: you have information on state in both data sources. The bad news: in one data set, state abbreviations are used (CT, RI..) and in the other, you have state FIPS codes. Sure, you can google "State FIPS code" and probably pretty quickly get a nice cross-walk, but there's another way. Install the ado file, "statastates" (type "ssc install statastates" into Stata). Then you just write in the type of code you have for Stata and it will add to your data set the other code types. Super easy and convenient! I used it this week. Thank you, William Schpero for sharing that ado file with the world. 

And now a secret. Or maybe a warning. Here it is: You will make coding errors. 

You can make fewer of them by being careful and checking your work, etc. But even then, you will make coding errors. Most of the time, people catch these coding errors eventually, but trust me, your life will be easier if you catch them as soon as possible after you make them. How to do that? Check your data often! I've blogged before about carefully looking at tables of descriptive statistics but here's another nifty trick: whenever possible, use the "assert" command in Stata. Nick Eubank provides a nice description of how to use this effectively

Saturday, June 23, 2018

PSA: Read Stata Help Files Carefully

I would say that the collapse command in Stata is surely one of the commands I use most in my work. This week I remembered one of the classic mistakes I've made within this command, so I thought I'd give all of you Stata beginners a nice little warning. 

What I wanted to do? Create a new variable showing the number of non-missing observations within particular cells (let's say, country of origin-state-year cells). One way to do this: 

bysort country state year: generate N_countrystateyear=_N 

but also easy enough to create this variable within a collapse command. Now, you would be tempted to use the 'count' option since the help file says that this will "count the number of nonmissing observations."  

generate x=1 

collapse (count) N_countrystateyear=x=income, by(country state year) 

This will work perfectly if you are not using weights. However, if you are using weights (pweights in particular), the count option will instead give you the sum of the weights over observations in the group.  Yes, this is explained in the help file but all the way at the bottom. Hence, my warning to read those things carefully. Also, always just look at the variables you create to make sure they make sense. So if you have weights and need them to create summary statistics of your other variables, what to do? Use the 'rawsum' option. For example, 

generate x=1 

collapse (mean) age schooling etc (rawsum) N_countrystateyear=x  [pweight=perwt], by(country state year) 

For more information on the different types of weights you can use in Stata, see here. Short version: Use pweights. Sometimes, Stata will refuse to calculate something using pweights. Ever wonder why? See here

PS
Thank you Kerry Papps and Nikos Theodoropoulos for encouraging me to write this blog post!  

Friday, June 15, 2018

Tips 4 Economists

Masayuki Kudamatsu has put together a gigantic list of bits of advice for economists. The best part: it's not just for graduate students and folks on the tenure track. It contains advice for people becoming department heads, editors of journals, and even deans! 

Saturday, June 9, 2018

Are You Writing a Difs in Difs Paper Exploiting Policy Variation Across U.S. States?

It doesn't matter which policy you're evaluating or what outcome you're considering, referees and seminar participants will always be concerned that states adopting a new policy will by coincidence (or not so much by coincidence) adopt other policies at the same time that may be driving your results. Another possibility is that states adopt new polices in response to changing characteristics of the population---and these changes are driving the variation of your outcomes. It is impossible for researchers to control for all changes in policies and all demographic characteristics, but we can certainly assuage concerns by adding to our models controls for changes in other policies or demographic characteristics. And good news: thanks to the folks at IPPSR, you can find data on many of these things in one easy to use data set! Below is the suggested citation and you can click on the link for more information: 

Suggested Citation:

Jordan, Marty P. and Matt Grossmann. 2017. The Correlates of State Policy Project v.2.0. East Lansing, MI: Institute for Public Policy and Social Research (IPPSR). 

PS
Advanced undergrads and beginner graduate students looking for data and a paper topic for a term paper, I bet that perusing through the data may inspire many great ideas! 

Friday, June 1, 2018

And What About After Tenure?

Yes, this blog is written mostly for graduate students and young assistant professors. This is because I have more advice to give on those matters. But life (and work and goals and dreams) does not end when you get tenure, even if it's at a university you really like. There is still more work to do. The only difference is that people pay less attention to you. People aren't as concerned about protecting you from difficult service assignments. No more course releases. It's not that these things are not available, it's just that now you're responsible for getting them for yourself. And by now, you should be able to. That said, my firm belief is that we're never too old to get some good mentoring. 

This morning, Susan Dynarski tweeted about when associates should go up for full. Thank you for that! Associates, see the full thread here. Full professors, feel free to provide more advice in the comments below...or email/call/message/stop by my office/etc. to share your thoughts with me personally.