Of white space, line ending, and GREP in BBEdit

This is completely "inside baseball" and likely of little interest, unless you happen to use BBEdit and LaTeX and want to search and replace using GREP. As a side benefit, it gives me a break from actually working on my tenure file!

The basic problem is finding white spaces and then replace them with LaTeX column separators (&), without having BBEdit include the line endings. An example text is:

2015    Spring  4770    1   3.9 4.5 4.4
2015    Spring  2110    3   4.4 4.5 4.4
2015    Fall    4760    1   4.3 4.3 4.3
2015    Fall    2110    2   4.4 4.3 4.3
2016    Winter  3100    3   4.4 4.5 4.4
2016    Winter  3100    2   4.0 4.5 4.4
2016    Spring  2110    2   4.5 4.4 4.4
2016    Spring  2110    3   4.8 4.4 4.4

I could, of course, just use the column copy and paste in BBEdit, but where is the fun in that!

My first inclination was to use

\s*

but that captures the line endings as well, so I turned to my trusted app Patterns and after a bit I settled on

([[:blank:]]*)

which looked like it did what I wanted in Patterns' search and replace window. The problem was that transferring this to BBEdit gave me

& 2 & 0 & 1 & 5     &  & S & p & r & i & n & g   &  & 4 & 7 & 7 & 0     &  & 1    &  & 3 & . & 9  &  & 4 & . & 5  &  & 4 & . & 4 & 
 & 2 & 0 & 1 & 5     &  & S & p & r & i & n & g   &  & 2 & 1 & 1 & 0      &  & 3    &  & 4 & . & 4  &  & 4 & . & 5  &  & 4 & . & 4 & 
 & 2 & 0 & 1 & 5     &  & F & a & l & l     &  & 4 & 7 & 6 & 0     &  & 1    &  & 4 & . & 3  &  & 4 & . & 3  &  & 4 & . & 3 & 
 & 2 & 0 & 1 & 5     &  & F & a & l & l     &  & 2 & 1 & 1 & 0     &  & 2    &  & 4 & . & 4  &  & 4 & . & 3  &  & 4 & . & 3 & 
 & 2 & 0 & 1 & 6     &  & W & i & n & t & e & r   &  & 3 & 1 & 0 & 0     &  & 3    &  & 4 & . & 4  &  & 4 & . & 5  &  & 4 & . & 4 & 
 & 2 & 0 & 1 & 6     &  & W & i & n & t & e & r   &  & 3 & 1 & 0 & 0     &  & 2    &  & 4 & . & 0  &  & 4 & . & 5  &  & 4 & . & 4 & 
 & 2 & 0 & 1 & 6     &  & S & p & r & i & n & g   &  & 2 & 1 & 1 & 0     &  & 2    &  & 4 & . & 5  &  & 4 & . & 4  &  & 4 & . & 4 & 
 & 2 & 0 & 1 & 6     &  & S & p & r & i & n & g   &  & 2 & 1 & 1 & 0     &  & 3    &  & 4 & . & 8  &  & 4 & . & 4  &  & 4 & . & 4 &

which is not exactly what I had in mind! After quite a bit of digging around, thinking that the problem was with posix in BBEdit, I finally figured out that the quantifiers are treated differently in BBEdit than in Patterns. The correct version in BBEdit is

([[:blank:]]+)

Patterns for some reason does not treat "*" as actual zero whereas BBEdit does. Using this and

\1 \&

gave me this beautifully formatted text instead

2015     & Spring   & 4770     & 1    & 3.9  & 4.5  & 4.4
2015     & Spring   & 2110     & 3    & 4.4  & 4.5  & 4.4
2015     & Fall     & 4760     & 1    & 4.3  & 4.3  & 4.3
2015     & Fall     & 2110     & 2    & 4.4  & 4.3  & 4.3
2016     & Winter   & 3100     & 3    & 4.4  & 4.5  & 4.4
2016     & Winter   & 3100     & 2    & 4.0  & 4.5  & 4.4
2016     & Spring   & 2110     & 2    & 4.5  & 4.4  & 4.4
2016     & Spring   & 2110     & 3    & 4.8  & 4.4  & 4.4

Now I just need the end of line symbols (and to make the next 14 tables) and I am done!

By the way, instead of the posix version you could use

([^\S\r\n]+)

The same thing apply with the quantifier.

Control of fertility using only traditional contraceptives?

Shamma Alam and I just finished a paper on the effects of income shocks on the timing of fertility in Tanzania using the Kagera data set. There are significant reductions in the likelihoods of being pregnant and giving birth following shocks, consistent with prior results in the literature. What is new is that we can show that this is predominately the results of an increased use of contraceptives. This is interesting for two reasons. First, it shows that the postponement of fertility following a shock is the result of an conscious decision, rather than being an unintended consequence of the shocks' effect on, for example, health or migration. Second, the postponement is achieved almost entirely through the use of traditional contraceptives. This shows that, once the incentives are strong enough, people are able to control their fertility even in the absence of modern contraceptives. The full abstract is:

This paper examines the relationship between household income shocks and fertility decisions. Using panel data from Tanzania, we estimate the impact of agricultural shocks on pregnancy, births, and contraception use. We estimate individual level fixed effect models to account for potential correlation between unobservable household characteristics and both shocks and decisions on fertility and contraceptive use. The likelihood of pregnancies and childbirth are significantly lower for households that experience a crop shock. Furthermore, women significantly increase their contraception use in response to crop losses. We find little evidence that the response to crop loss depends on education or wealth levels. The increase in contraceptive use comes almost entirely from traditional contraceptive methods, such as abstinence, withdrawal, and the rhythm method. We argue that these changes in behavior are the result of deliberate decisions of the households rather than the shocks' effects on other factors that influence fertility, such as women’s health status, the absence or migration of a spouse, the dissolution of partnerships, or the number of hours worked. We also show that, although traditional contraceptives have low overall efficacy, households with a strong incentive to postpone fertility are very effective at using them.

New version of my paper on sex-selective abortions in India

After working through many and excellent comments from 3 referees, I now have a revised version of my paper on sex-selective abortions in India. There is also now a substantial on-line appendix (89 pages). The new abstract is:

This paper addresses two main questions: what is the relationship between fertility and sex selection and how does birth spacing interact with the use of sex-selective abortions? I introduce a statistical method that incorporates how sex-selective abortions affect both the likelihood of a son and spacing between births. Using India's National Family and Health Surveys, I show that falling fertility intensifies use of sex selection, leading to use at lower parities, and longer spacing after a daughter is born. Women with 8 or more years of education, both in urban and rural areas, are the main users of sex-selective abortions and have the lowest fertility. Women with less education have substantially higher fertility and do not appear to use sex selection. Predicted lifetime fertility for high-education women declined more than 10% between 1985–1994, when sex selection was legal, and 1995–2006, when sex selection was illegal. Fertility is now around replacement level. Abortions per woman increased almost 20% for urban women and 50% for rural women between the two periods, suggesting that making sex selection illegal has not reversed its use. Finally, sex selection appears to be used to ensure one son rather than multiple sons.

Parental absence paper published in Review of Economics of the Household

My paper, "Effects of Parental Absence on Child Labor and School Attendance in the Philippines," was published in the Review of Economics of the Household, vol. 14(1), pp 103-130, 2016.

This paper uses longitudinal data from the Philippines to analyze determinants of children’s time allocation. The estimation method takes into account both the simultaneity of time use decisions, by allowing for correlation of residuals across time uses, and unobservable family heterogeneity, through the inclusion of household fixed effects. Importantly, this improved estimation method leads to different results than when applying the methods previously used in the literature. Girls suffer significantly from the absence of their mother with a reduction in time spent in school that is equivalent to dropping out completely. This effect is substantially larger when controlling for household unobservables than when not. Boys increase time spent working on market related activities in response to an absent father, although this time appears to come out of leisure rather than school or doing household chores. Land ownership substantially increase the time boys spend on school activities, whereas renting land reduces the time girls spend on school. Finally, there does not appear to be a substantial trade-off between time spent on school and work, either in the market or at home.

Compensating wage differentials in an online labor market

We have recently finished the first in a series of planned papers based on experiments that we ran. The first paper is on the compensating wage differentials theory, with the title "Only if You Pay Me More: Field Experiments Support Compensating Wage Differentials Theory". Abstract below:

Compensating wage differentials is Adam Smith’s idea that wage differences equalize differences in job and worker characteristics. Other than risk of death, however, no job characteristics have consistently been found to affect wages, likely because of problems with self-selection and unobservable job characteristics. We run experiments in an online labor market, randomizing offered pay and job characteristics, thereby overcoming both problems. We find, as predicted by our model, that increasing job disamenities significantly reduces both likelihood of working and amount of work supplied. Correspondingly, the wage increases necessary to compensate workers for worse job disamenities are substantial, supporting the theory.

Congratulation to Chasya Hoagland

A big congratulations to Chasys Hoagland who successfully defended her PhD thesis today.

Chasya's main paper is on black women's hair styles and how people react to them using a very neat experiment. From the results it looks like hair styles affect perceptions of worker quality if there is imperfect information, but not if there is strong information about quality.

She also has a paper on the different effects of test scores, grades, and self-perception of ability in math and English on schooling outcomes and subsequent earnings. Even controlling for test scores and grades there is a strong effect of perceived abiility on earning, although not much effect on schooling outcomes.

Sex-selective abortion paper available as World Bank Policy Research Working Paper

My paper on sex-selective abortions in India is now available as a World Bank Policy Research Working Paper. You can find it here. The abstract is

Previous research on sex-selective abortions has ignored the interactions between fertility, birth spacing, and sex selection, despite both fertility and birth spacing being important considerations for parents when deciding on the use of sex selection. This paper presents a novel approach that jointly estimates the determinants of sex-selective abortions, fertility, and birth spacing, using data on Hindu women from India's National Family and Health Surveys. Women with eight or more years of education in urban and rural areas are the main users of sex-selective abortions and they also have the lowest fertility. Predicted lifetime fertility for these women declined 11 percent between the 1985-1994 and 1995-2006 periods, which correspond to the periods of time before and after sex selection became illegal. Fertility is now around replacement level. This decrease in fertility has been accompanied by a 6 percent increase in the predicted number of abortions during the childbearing years between the two periods, and sex selection is increasingly used for earlier parities. Hence, the legal steps taken to combat sex selection have been unable to reverse its use. Women with fewer than eight years of education have substantially higher fertility and do not appear to use sex selection.

Paper on children's time allocation in the Philippines forthcoming at Review of Economics of the Household

My paper "Effects of Parental Absence on Child Labor and School Attendance in the Philippines" has been accepted for publication in Review of Economics of the Household.

This paper uses longitudinal data from the Philippines to analyze determinants of children’s time allocation. The estimation method takes into account both the simultaneity of time use decisions, by allowing for correlation of residuals across time uses, and unobservable family heterogeneity, through the inclusion of household fixed effects. Importantly, this improved estimation method leads to different results than when applying the methods previously used in the literature. Girls suffer significantly from the absence of their mother with a reduction in time spent in school that is equivalent to dropping out completely. This effect is substantially larger when controlling for house- hold unobservables than when not. Boys increase time spent working on market related activities in response to an absent father, although this time appears to come out of leisure rather than school or doing household chores. Land ownership substantially increase the time boys spend on school activities, whereas renting land reduces the time girls spend on school. Finally, there does not appear to be a substantial trade-off between time spent on school and work, either in the market or at home.

The paper has been previously been circulated under the title "Children's Time Allocation, Heterogeneity, and Simultaneous Decisions".

Fertility incentives

An example of a positive relationship between number of children and their education level. People really do respond to incentives!

Her parents were true pioneers and moved from Minnesota to Alaska in 1925 with Dolores (4) and 4 other children, heading to Pt Agassiz across the water from Petersburg to homestead land there-- the territory of Alaska promised to build a school house and furnish a teacher if there were 7 students-and the Ramstead family soon fulfilled the quota. Three more children were born to the Ramstead family in Alaska, all growing up on the farm.

I see a paper using this policy as a natural experiment coming up...

"High School Dropouts and Sexually Transmitted Infections" accepted at Southern Economic Journal

Mark Anderson and my paper, "High School Dropouts and Sexually Transmitted Infections," has been accepted for publication at the Southern Economic Journal. Not sure about the exact publication date yet. The abstract for the paper is:

People who drop out of high school fare worse in many aspects of life. We analyze the relationship between dropping out of high school and the probability of contracting a sexually transmitted infection (STI). Previous studies on the relationship between dropout status and sexual outcomes have not empirically addressed unobserved heterogeneity at the individual level. Using fixed effects estimators, we find evidence supporting a positive relationship between dropping out of high school and the risk of contracting an STI for females. Furthermore, we present evidence that illustrates differences between the romantic partners of dropouts versus enrolled students. These differences suggest that female dropouts may be more susceptible to contracting STIs because they partner with significantly different types of people than non-dropouts. Our results point to a previously undocumented benefit of encouraging those at risk of dropping out to stay in school longer.

Export Keynote slides to PDF with Keyboard Maestro

I write most of my slides for teaching in Keynote and, as much as I like it for making easy to read slides that are (relatively) nice to look at, it does have some annoyances. The main one for me is when exporting the files for uploading to our course management system. I export everything meant for the students, including Keynote slides, to PDF. It looks the same for all students and with about half of the students using Macs and the other half using Windows, I do not have to worry about them not being able to read it. Now, Keynote has an export option, but for some unfathomable reason it does not remember my preferences from one time to the next and always show the following menu:Keynote's export window

But I want the slides without border, dates, and without showing each builds every single time. I could, of course, click on the check boxes each time I export a set of slides but that gets old really quickly. Keyboard Maestro and some Applescript to the rescue! The screenshot below is of the macro I ended up putting together. Now I only have to use a keyboard short-cut and my slides are ready to download in exactly the format I like them. Keyboard Maestro macro

It took longer to write this than it should have, mainly because I had forgotten how particular Applescript is about referring to windows and sheets. I am sure this could have been written more efficiently but it works and if you want, say, slide numbers you can just change that part of the macro. If you are interested you can download the Keyboard Maestro macro here. As always, use at your own risk.

XXVII IUSSP International Population Conference

Just back from the XXVII IUSSP International Population Conference, held in Busan, Korea. I presented my paper on family planning in Ethiopia (joint with Kathleen Beegle and Luc Christaensen) and a poster on my work on sex selective abortions in India. My student, Shamma Alam, presented our joint paper on income shocks and timing of fertility in Tanzania.

All-in-all it was a great conference and very well-organized. Only complaint was that many of the best US demographers did not attend. Quality of the sessions were a little more varied than what you find at the PAA, but I will be back again in four years. Finally, if you get a chance to go to Korea: take it; it is a wonderful place to visit.

Taking meeting notes with TextExpander

Inspired by Macsparky's post about taking better meeting notes with TextExpander I spent a bit of time tweaking it. To recap, the basic idea is to have a structured set-up for meeting notes that incorporates action/to-dos for everybody in the meeting. The difference between mine and the original is that mine automatically ignores anybody who is not attending when generating the action items section. It is also edited to allow for similar behavior in both nvALT on my macs and Drafts on iPhone/iPad. You can download the version here. By the way, oa1 is "other attendee 1", oa2 is "other attendee 2", etc. The other attendees are people I work with on a regular basis.