Photo credit: Stephen M. Scott
 +   -  text size:


Custom Homework Class in LaTeX

Tuesday, Jan. 24th, 2017 11:34a.m.

I have been using the exam class by Philip Hirschhorn in LaTeX to write out homework and tests for my class, The Epidemiology of Everyday Life. It allows me to write out problems with the ease of mathematical notation in LaTeX, provide solutions that can be turned on and off with a single line of code, and to easily tally points on various pages. If you haven't used it and teach a stats-based course, I would definitely recommend checking it out.

I ran into a problem, however, because I am a procrastinating perfectionist. I have had a desired to have all of my teaching handouts to have a similar look. I created a custom syllabus class to do that, and I really liked it. I wanted the homework to have the same look. And what better way to procrastinate than to try to figure out the arcane rules of LaTeX!?

  tags: LaTeX, teaching category: Programming

workflow directory structure that plays nicely with LaTeX

Monday, Jan. 2nd, 2017 10:51a.m.

I really like using LaTeX for writing, both articles and for teaching. I find that it eliminates many of the hassles of using Word. I started trying to figure out how to write my own packages this past year and ran into many problems. One of those problems was figuring out a way to keep the .sty packages in a directory that I could easily access and that would be convenient for my workflow rather than what the LaTeX directory structure enforced.

The LaTeX search path includes two environment variables: TEXMFHOME and TEXMFLOCAL that determine where you would store .sty files to be recognized by LaTeX. If you follow the excellent instructions [here][texmf], you can use the Linux program kpsewhich to find where those paths are. For me they were at /Users/<USERNAME>/Library/texmf and /Users/<USERNAME>/Library/texmf-local, respectively.

  tags: LaTeX, linux, texmf category: Programming

want a diverse neighborhood? move to the suburbs

Monday, May 16th, 2016 12:53p.m.

I hope that you will forgive the shameless self-promotion, but I recently published a paper in [Sociological Science][socsci] (yay open access!) that examined neighborhood racial change in New York, Los Angeles, Chicago, and Houston metropolitan neighborhoods with an amazingly talented colleague, Siri Warkentien.

  tags: d3, neighborhood-change, research, shameless-self-promotion category: Neighborhoods

Stay on Message

Thursday, Jan. 22nd, 2015 11:23a.m.

Have a message. State it. Write nothing else.

Those are the first instructions to Demographic Research authors on their submission pages. I've heard variations on this theme before, but nothing as clearly stated as this. You might say that the Demographic Research editors had a message, stated it clearly, and wrote nothing else.

I started using this advice to reframe several papers that I have hanging around. What I have found in my first week using this advice is that the organization of papers has become easier. My writing becomes crisper. My papers are shorter. And I find them to be more compelling.

  tag: writing category: Academe

beckieball, or selecting on skill

Tuesday, Jan. 6th, 2015 2:35p.m.

Over the weekend, jeremy posted about beckieball, a "new sport sweeping the country." The purpose was to show how selection on characteristics affects the correlation between characteristics upon selection. This, as commenter Stuart Buck pointed out, is an example of Berkson's Paradox, though it relates to jeremy's post about height and nba.

Although he left several other exercises to the reader, I thought I would do a simpler one: recreate the code that he used to make his example. I did this a) because it was a semi-useful way to shake the cobwebs from egg nog and yuletides, and b) because I think that it will come in handy teaching someday.

  tags: Stata, statistics categories: Programming & Statistics

Importing Text Files with Variable Names to R

Wednesday, Nov. 26th, 2014 10:47a.m.

I am attempting to learn R. This is either a great thing or a terrible, terrible mistake while on the tenure clock. But, all the cool kids are doing -- so even though they might also jump off a bridge, I'm going to jump into R.

The hardest part so far is doing things that now come as second nature to me in Stata. Although R's tools are much better in the long-run, learning what types of objects different functions return and such ends up being a very high learning curve.

A while back (all posts are a while back now), I wrote a post describing how to import data with variable labels in Stata. The idea was that I could keep the variable labels with the data in an text file so that I could always figure out what the variables were. It doesn't require an extra codebook or additional files that could be lost.

I have now replicated that script for R, and it is below:

  tags: data-management, R, stata-to-R category: Programming

Making the Amazing Apportionment Machine

Wednesday, Aug. 21st, 2013 2:05p.m.

I was born in Northern Colorado and now live just outside the District of Columbia. I can attest from personal experience that these two places do not share much. Except, that is, for their desire to become states.

I was curious what would happen if both became states as a modern-day [Missouri Compromise]. I wrote the following script to make the Amazing Apportionment Machine to reapportion seats and looked at two scenarios: the current distribution of congressional districts and the distribution if "Northern Colorado" and the "State of Columbia" were added as states.

  tags: congress, tips-n-tricks

Two New Papers on Residential Preferences and Consequences of Racial Segregation

Friday, Oct. 14th, 2011 10:34p.m.

In the commotion of moving and starting my new job, I neglected to post about two articles that came out last month that I worked on for quite a while. The first, Reassessing Residential Preferences for Redevelopment, was published in City & Community last month in a special issue on gentrification. My paper argues that much of our public policy and debate regarding changing residential preferences for gentrification occurs without actually measuring preferences in the population. Using the 2004-5 Chicago Area Study, I do just that to show that preferences break down along groups defined by home ownership. Home owners in the city of Chicago, regardless of race, are much more likely than their suburban counterparts to consider a redeveloped neighborhood. Meanwhile, race tends to unify preferences among renters in that blacks -- regardless of whether they live in Chicago or suburban Cook County -- would consider redeveloped neighborhood much more than their white renting counterparts, with Latino renters in between. I also find that traditional reasons middle-class people prefer redeveloped neighborhoods touted by gentrification and creative class proponents only really apply among whites while black home owners prefer access to city services and Latinos prioritize access to employment.

To the extent that cities hold developers accountable to mixed-income plans, these results suggest that redevelopment might help integrate communities economically and racially. Of course, this means actually holding developers accountable, which is sometimes difficult to do. Overall, the debate regarding who would prefer to live in redeveloped neighborhoods needs to be more nuanced and not based on where people do live.

  tags: gentrification, neighborhoods, public-health, residential-mobility, segregation, urban-policy categories: Neighborhoods , Public Health & Urban

Residentially Mobilizing Myself

Sunday, Aug. 7th, 2011 10:08a.m.

American University Logo

I am moving with my family this week so that I can start my new position at American University in the Department of Sociology and Center on Health, Risk and Society. I am very excited to be starting this new position being with great new colleagues, being in a wonderful academic and policy environment, and moving back to the area where my wife and I grew up. In addition to a much needed, if only possibly well deserved, vacation last week posts have necessarily been a little slow.

As a scholar of residential mobility, it is very strange to be going through a move myself. Throughout the process, I attempted to remain as reflexive as possible to learn from my own experience and how that might help inform my work. Although nothing I did would constitute "real" research that could be written up and published in a journal, I felt that I was a true participant-observer in the process. The process certainly informed my understanding of the ways that the housing search is an intensely sociological as well as economic process given the bounded rationality of deciding what we could afford, the importance of social networks in overcoming information externalities, and the cultural component of purchasing a home that is often neglected. I have no doubt that these insights will inform my work on the topic, particularly as it highlights the need to understand the social and cultural context of the housing search in addition to traditional economic models.

  tags: personal, residential-mobility category: Academe

Basic Tips for Writing Statistical Scripts

Sunday, July 17th, 2011 6:14p.m.

While writing scripts is one of the most important skills for reproducible quantitative sociology, the typical convention is to pick up the skills through more experienced colleagues in graduate school or at the workplace. Below are a few tips that I have learned from others, picked up on my own, or otherwise accumulated in my arsenal of tricks that I thought that I would pass along. There are great resources out there, but I thought it would be helpful to pass along what I think are the most important and helpful tips.

  tags: Stata, tips-n-tricks, workflow category: Programming

Form or Function?

Wednesday, July 6th, 2011 4:07p.m.

Rolf Pendall posted a short, interesting piece on the suburbanization of poverty at the Urban Institute's new Metro Trends Blog. In it, he questions the basis of determining cities from suburbs in the service of understanding the "suburbanization of poverty."

His criticism stems from the ambiguity of defining suburbs and cities based on their urban design and physical infrastructure. He demonstrates this ambiguity through examples of Houson, Texas (a city with extensive sprawl); Fremont, California (a suburb with its own employment base and denser development than Houston); and Silver Spring, Maryland (an inner-ring suburb with all of the accoutrements of urban living).

His question is valid and one we face often in our work on New York: how relevant is work on New York City for the rest of the country. Just to provide an example of my own, the picture below that looks much like the Silver Spring neighborhood my family is preparing to move into is actually in New York City.

View Larger Map

  tags: built-environment, cities, suburbs, urban-policy categories: Neighborhoods & Urban

Whole Foods Habitus

Saturday, June 18th, 2011 11:33a.m.

I believe firmly in the importance of research to inform policy based on observed facts. But, sometimes art expresses truth better than research ever could. I present the following as evidence of art capturing the essence of the Whole Foods habitus.

The video is of course meant to parody the cultural conventions of Whole Foods; but, I think that it really speaks to larger truths about culture, food, and inequality. While the video pokes fun at the Whole Foods consumer, I think that it accurately reflects how out of touch a vast swath of relatively privileged Americans are regarding the real struggles of poorer and many minority residents face when attempting to eat a healthy diet. Forget the fact that kombucha isn't on the shelves, many can't find produce or unspoiled meat as Dan Rose, my friend from graduate school documents in this piece Detroit neighborhoods where they are even lucky if they have grocery stores.

  tags: inequality, nutrition, obesity, whole-foods categories: Neighborhoods & Public Health

Chicago Neighborhood Data Website -- CCAHS

Friday, June 10th, 2011 11:37p.m.

After much hard work on the part of very talented people, the website for the Chicago Community Adult Health Study launched this week! For those who do not know about the project, it is an excellent dataset to examine influences of neighborhood environments on health outcomes among adults. The sample comes from all 343 Neighborhood Clusters in the city of Chicago, which allows a wide range of analyses across neighborhood environments. In addition to the survey of informants, there is also very rich data on the physical aspects of the neighborhood environment based on systematic social observations in all of the 343 Neighborhood Clusters.

Estimated Levels of Physical Disorder

I took advantage of this in part of my dissertation to explore how small-scale predictors of neighborhood disorder could be constructed from the sample of systematic social observations. Combining the insights from Steve Raudenbush and Rob Sampson regarding the benefit of using multiple items to rate characteristics of the neighborhood environment like disorder and the benefits of the geostatistical method of kriging to measure small-scale changes in the environment, I created a smooth surface of physical disorder across Chicago. Based on this method, one is not limited to pre-defined definitions of neighborhoods because block-level estimates can be reassembled into any configuration desired by the researcher. I then used this to show that observed physical disorder has a strong effect on residents' perceptions of neighborhood safety when we measure physical disorder at very small scales around a respondent, but almost no influence when we measure physical disorder at larger scales.

Of course, this is only one of the ways that I have used (and continue to use) this data. If you are interested, feel free to contact me if you want to learn more about the data -- particularly the systematic social observation component.

  tags: data, disorder, kriging, measurement, neighborhood-effects category: Neighborhoods

Nesting Stata Macros, or Hacking a Hash Map

Monday, June 6th, 2011 6:37p.m.

Programming in Stata is relatively straightforward and this is partly because the programming syntax is both powerful and relatively straightforward. There are, however, a few minor annoyances in Stata's language including using the backtick and apostrophe to indicate local macros (i.e.,`localname'). Among these shortcomings, I would argue that the lack of anything like a list in Stata's language is one of the largest.

In most langauges, you can store a list of items and refer to the item in the list by some sort of index. This is particularly helpful for iterating over the same step multiple times. Lists generally come in two flavors: lists to which you can refer to an item by its position in the list or lists which you can refer to by a keyword (called hash maps in computer science lingo). Stata's matrices can be used for the first, though doing so might become complicated if you want to do something besides storing basic numbers or strings.

  tags: data-management, macros, Stata, tips-n-tricks category: Programming

Structuring Work: Data Cleaning and Construction, Laying the Foundation

Saturday, April 16th, 2011 11:37a.m.

In the last step, we downloaded all of our data and deposited into directories that store this source data, backed it up, and write-protected the files. Now that we have done all of that, it is time to start working with the data! There is only one problem: almost inevitably, the data do not come neat, tidy, and ready to use. Often, the data contain major problems and need to be constructed in order to be usable. In this installment, I will write about managing files for cleaning, constructing and storing datasets.

  tags: advice, data-management, research-process, workflow category: Structuring Work

Front Page


  • Information about the purpose and topics of this blog can be found here.






  • The views presented here are solely and entirely my own, they do not represent those of my colleagues, employer, or any funding agencies which may support me.
  • The writing on this blog is covered by a Creative Commons License (described here). Feel free to distribute or re-post with a link to the original content provided that it is freely available to others.
  • Creative Commons License