Economist as a plumber with a body camera (EPBC)

Economists could do more to show their work and to maintain their results.

Economists aren’t particularly transparent in their day-to-day activities, but what they do is very important. Because economics offers little possibility for laboratory-style experiments or hard-science precision, there is a perverse opportunity for conclusions to be reached before data are collected. This is dangerous and would be less likely if economists 1) reported what they do more frequently and more clearly, and 2) shifted some of their responsibilities toward maintenance of existing policy or past results.

Esther Duflo described the potential for a shift in the role economists play in society. Rather than being biased architects designing massive social policies, economists can be the people who are responsible for maintaining social systems and keeping them running smoothly from month-to-month, without any gaps or leaks. Economists can be more like plumbers.

The worst possible way to implement this shift in responsibility would be to hire a separate group of economists to fiddle with policy or day-trade things like the stock of unemployed. Instead, a practical way to do this is for existing (and particularly newly-minted) economists to “wear body cameras”, reporting more of their day-to-day work on personal or work websites or blogs, or on twitter, or GitHub.

Since poverty is deadly and bad policy causes people suffering and death, economists, and others involved in crafting public policy, yield a lethal weapon. If they were in-effect “recorded”, the way these well-paid individuals practice their trade would likely change–both in what results are presented and also in what tasks are undertaken. And if it turns out that economists are already completely honest and unbiased, then “body cameras” would massively boost the field’s credibility.

There are now many free, open-source, and well-documented tools, like python and R, for working with public economic data and contributing to analysis. Plus, there is enough space on the cloud to share other iterations that aren’t presented in a final set of regression coefficients, for example. It would also be helpful for more economists to share the code that produces their results, so that others can extend or modify it. Increasingly, technology is making it possible for economists to show more of their work.

Economists as plumbers with body cameras, in practice, also means following up very frequently on past work and on how existing systems are performing for all people (not just the aggregated/synthetic statistical “person”). For example, the economists who justify liberalization of US trade policy could be the ones responsible for resolving the local effects from the related factory closures. Economists pushing cuts to social services in response to debt levels could report monthly on what their policy does to both the debt level and the poverty rate. In essence, economists could do more checking-up on what they’ve done in the past and, if necessary, clean up after themselves.

The EPBC therefore has two goals: 1) encouraging the showing of how results were obtained, and 2) more frequently revisiting past results. To contribute to achieving this, I’m publishing a series of jupyter notebooks that show my recent attempts at working with public economic data using python. For future projects and blog posts, I’ll link to the new notebooks, and use the tag EPBC (for economists as plumber with body camera). I’m not sure if this will work out, or be sustainable, but its an interesting idea and worth a try.

Here are the first three EPBC notebooks (python 3.6):

Is Amazon killing Walmart?

US exports by trading partner

Efficiently reading fixed-width files like the CPS public use microdata

 

 

 

 

 

 

 

 

 

Advertisements

Tech sector index nearing all-time highs

An important measure of the strength of the tech sector has been climbing rapidly over the past two years and surpassed its turn of the millennium level in June. This doesn’t mean there is another tech bubble, but investors should take heed. 

From 1995 to 2000, millions of US households purchased personal computers and used them to connect to the internet for the first time. It was apparent at the time that new technologies, often from government origins, were bringing massive changes. Private investment poured into the tech sector, including to many companies that had never generated a profit and even some without revenue. Money coming into the sector began to overflow and pour back out in the form of lavish executive spending and absurd demonstrations of wealth. When the speculative “dot-com” bubble burst, people lost jobs and retirement savings.

The tech pulse index, produced by the Federal Reserve Bank of San Francisco, tracks what is going on in the tech sector by looking at relevant changes in investment, employment, industrial production, and consumer spending. The index nearly tripled from 1995 to its peak in October 2000, growing at an average annualized rate of 18.7 percent. By the bubble’s trough in 2003, the measure had fallen to nearly half of its peak. From the 2003 trough until the recent uptick in 2016 the index increased at an average annualized rate of 2.9 percent.

tech_pulse

The tech pulse has been on a tear since 2016. From May 2016 to the latest data, covering July 2018, the index has increased at an average annualized rate of 11.4 percent. In June, the index passed its January 2000 level, and it is currently about 13 percent below the all-time high achieved at the peak of the bubble.

There are many similarities between the current tech boom and the dot-com bubble, such as: absurd demonstrations of wealth, the failure to convert money coming in into new productive assets, a backdrop of rising interests rates, and highly-valued companies not generating profit. In some cases, valuations are so high that it seems people are betting not necessarily on tech companies ability to create game-changing technology, which is already priced in, but on their ability to either force competitors to fail or to absorb competitors until market share allows for monopoly prices and monopsony wages. In some cases, the competitor is a public good, such as local and regional public transportation in the case of Uber and Telsa, respectively. Once our public asset is taken over or goes broke and stops operating, the private alternative can raise its prices and allow its quality to deteriorate.

In the case of Amazon, which currently generates a profit mostly through its web services division, investors seem to be betting that eventually the company will have enough power to raise prices without consumers being able (or willing) to shop elsewhere. It’s also worth noting that Amazon got where it is by not paying sales tax. Apple and Alphabet (Google), which already generate massive amounts of profit, still benefit excessively from not paying taxes.

While I don’t know whether the current tech boom is a bubble, and I lean towards thinking it is not, it’s always good to be cautious and to pay attention to growth rates, like those captured in the very clever tech pulse index (here’s info on the methodology). In general, investors should be wary about buying into companies that are already expensive and where the remaining upside requires the alignment of several events in the unknowable future.

Answer to gig economy question depends on baseline

The US Bureau of Labor Statistics reported on Thursday that contingent and alternative work was occurring at about the same rate in May 2017 that it did in February 2001. Even more surprisingly, some categories of this type of work were actually occurring less frequently in 2017 than in 2005. Media coverage of the report noted the lack of growth in these categories of work and the surprise among those who expected confirmation of a growing gig economy. One take that has been missing, however, is the possibility that other changes to the labor market mean we should expect much less contingent and nonstandard work. Two indicators that nonstandard work has been falling come from regularly monthly data showing the long-term decline in self-employment and multiple job holding. Relative to this alternative baseline, the BLS report shows a labor market that has been changing in dangerous ways.

Definitions

“Contingent” work is comprised of jobs that are not expected to last, even if there is no change to the economy. In a related concept, “alternative” work arrangements include independent contracting, on-call work, and working for a temp agency or contract company while assigned to one client’s place of business. The structure of these jobs varies but they all have a nonstandard employment relationship; independent contractors may provide their labor with less intermediation than the standard worker while contract company and temp agency employees operate through more labor market intermediaries. While only some alternative work arrangements are contingent, all of these categories might be associated with a less-smooth income stream.

Importantly, despite the popularity of treating “contingent”, “alternative”, and “gig” work as synonymous, BLS defines gig work very narrowly as only those jobs that include work found and paid for through a website or mobile app. BLS has not yet released any estimate of gig work, but plans to do so by September 30, in a Monthly Labor Review article. The gig work questions ask people whether they have done ANY gig work, whereas the contingent and alternative work questions focus on the main job.

Interpreting the survey results relative to an alternative baseline

With lots of discussion about Uber drivers, shortened job tenure, and the fissured workplace, analysts were expecting to see a growing share of US workers employed in contingent and alternative work arrangements. However, this expectation seems to forget major demographic changes since 2005. The overall employment rate has fallen since 2001, particularly among young people and students, who are traditionally disproportionately “contingent” workers. Simultaneously, people are now much more likely to have a college degree. Since contingent workers tend to be younger, and those with college degrees tend to have more stable employment, a baseline assumption about the labor force, based on demographics alone, would suggest that nonstandard work arrangements become less common, not more common.

Two indicators that show this changing baseline are the incidence of unincorporated self-employed workers and the rate of multiple jobholding. Both measures are proxies of contingent and alternative work and have fallen by a third or more since the first contingent worker supplement was conducted in February 1995.

Fewer unincorporated self-employed

It’s important to remember that the analysis released by BLS on Thursday came from a one-time supplement to a survey that is conducted every month. If, during the week before one of the monthly interviews, someone drove for Uber, provided labor through Task Rabbit, or worked one of many non-gig independent contractor jobs, as either their first or second job, they will show up as “self-employed, unincorporated.” As expected by demographics, the share of the population that is classified this way has fallen since 1995 for both those age 25 to 54 and for those age 55 or older (figure 1).

seu

In 1995, 7.3 percent of the age 25 to 54 population was unincorporated self employed, compared to 6.3 percent in 2001, 6.2 percent in 2005, and 4.8 percent in the year ending May 2018. The share of those over age 55 who are self employed and unincorporated has also fallen, from 5.1 percent in 2005 to 4.3 percent over the past year.

Since my calculation above includes those who are self employed as their second job, it helps to rule out the possibility that the contingent and alternative workforce numbers are misleadingly low because they do not capture the second job. Additionally, using a moving annual average of the data helps to smooth out the volatility that is possible when looking at any single month of CPS data.

Falling multiple jobholder rate

A second indicator supporting a lower baseline for comparison of recent BLS estimates comes from the fall in the share of workers with more than one job (figure 2).

mjh

The share of employed with more than one job has fallen from 6.6 percent in 1995 to 5.3 percent in 2005 and to 4.7 percent in the year ending May 2018. Among women, the trend is less pronounced, with 6.4 percent of female jobholders reporting more than one job in 1995, compared to 5.7 percent in 2005, 5.6 percent in 2017, and 5.4 percent over the past year. Since some explanation of the lower-than-expected BLS estimates has focused on concerns over measurement, and specifically that second jobs are not captured, it is worth pointing out how much less common second jobs now are in the CPS, compared to the period when the earlier survey supplements were conducted.

Policy should focus on people not work

When adjusting for increased education, an aging workforce, and changes to overall employment rates, incidence of contingent and alternative work actually seems to have grown relative to its 2001 rate. In age and education, those who are currently working are more demographically similar to those who traditionally hold standard jobs, with the potential exception of some independent contractor jobs. When compared to a baseline where, all else equal, contingent and alternative work should actually have fallen over the past 12 years, it is concerning to see this type of work retain its share of the labor market.

One explanation for the relative persistence of nonstandard work is that many of the jobs that used to be temporary or unstable have been either outsourced, automated, or lost to the housing bubble, while jobs that used to be stable and standard are being destabilized. The influence that companies in places like Silicon Valley have over labor policy has grown, and these companies seem to be using their influence to try to make otherwise unprofitable ventures profitable, at the expense of workers. Partially as a result of corporate influence, and in the context of other changes in the US labor market, the main difference between the 2001 and 2017 contingent worker supplement results may be that the less stable jobs of today take a lot more student debt to get.

Perhaps more importantly, though, it is off-target to focus on the share of the economy currently claimed by contingent and alternative work. Financial statements already show that many of the new labor market intermediaries are not profitable. The focus should instead be on policy that tries to protect and improve job quality and to prevent gaps in unemployment insurance from needlessly putting people in poverty during the next economic downturn. The ACA, as one relevant policy example, may have been blessed by the 2017 survey data: health insurance among contingent and alternative workers is now much more common.

 

 

Sawing off the top of a step ladder

Policymakers may have accidentally demonstrated that they have the skills needed to curb the pay of the top earners in a profession. Unfortunately, these problem solving skills were not applied to CEOs, who regularly get paid a thousand times what their middle-paid worker makes. Instead, some state lawmakers have tackled the non-existent problem of teachers making too much money.

In 2016, public school teachers in the states with recent strikes or large scale protests (West Virginia, Oklahoma, Arizona, Kentucky, North Carolina, and Colorado) are paid about three dollars per hour less than other teachers nationwide. This is not new. After adjusting for prices, the gap was about the same in 2006. What has changed is teacher pay near the “top”. In 2006 a public school teacher making $40.93 per hour (in 2016 dollars) makes more than 90 percent of public school teachers nationwide, while it takes an hourly wage of $37.95 to make more than 90 percent of teachers in states with strikes and protests. The nationwide 90th percentile wage ticked up to $43.27 by 2016, but fell to $34.98 for the states that have subsequently organized strikes and protests.

teacherpay

The top half of the public school teacher wage distribution is already low compared to other occupations. But after state efforts to curb teacher pay, 90 percent of the public school teachers in states with strikes and protests make less than $35 an hour, and more than a quarter of the group is paid less than $16 an hour. These hourly wage figures are based on annual earnings in the March CPS, so they already account for differences in weeks worked per year and hours worked per week, and are therefore more comparable to the hourly wages of other occupations. Using these wage values, teachers, relative to other occupations, have the additional burden of being paid, on average, for fewer hours per year, making it harder for them to make ends meet.

Policymakers should reverse the misguided efforts to cut teacher pay. If anything, teachers should be better rewarded for their contribution to society. It shouldn’t take strikes and protests to make this point.

Technical note: The box plot above shows the average (green diamond), median (white line), 90th, 75, 25th, and 10th percentile hourly wage. Public school teachers are identified as persons in occupations 2200 to 2340 who are employed by the government. The hourly wage variable is generated as the ERN-VAL / (WKSWORK * HRSWK). 

Can a tight labor market pull young people back to full-time work?

From 2001 to 2013, college enrollment in the US increased rapidly. Young people delayed the full-time work portion of their lives, ostensibly to seek skills for an evolving set of jobs. Trends since 2014, however, suggest that the increase in education is not an entirely structural change. Over the past few years, a tighter labor market has been leading more young people to full-time work, suggesting that a weak labor market, rather than concern over a changing set of jobs, was pushing some young people to enroll from 2001 to 2013.

The Current Population Survey shows that from 1994 to 2001 young people were increasingly taking full-time jobs. By March 2001, an annual average of 40.5 percent of people age 19 to 21, and 61.5 percent of people age 22 to 24, were employed full-time. Following the recession of 2001, the trend reversed completely. By March 2013, an annual average of only 23.3 percent of those age 19 to 21 had full time jobs, and only 46.0 percent for those age 22 to 24.

fte_by_age

While data show a long-term decrease in full-time employment among younger people, the same data also show two signs that a weak labor market plays a role. First, the full-time employed share of both age groups has increased steadily since 2014. As of the year ending in March 2018, 28.3 percent of those age 19 to 21, and 52.2 percent of those age 22 to 24, are employed full-time.

Second, if education were driving the change in youth employment then summer youth employment would increase relative to school-year employment. Since most US schools offer students a summer break, the share of young people employed full-time during June, July, and August is much higher than at any other point during the year. If young people are opting for school because of abundant attractive new jobs, then summer break might provide an increasing chance for full-time employment for those in school during the rest of the year. However, summer full-time employment has actually fallen relative to school-year employment, suggesting the opposite, that young people are having a harder time obtaining summer jobs compared to the period from the mid 1990s through 2001.

The weak labor market therefore plays a role in encouraging school enrollment; those who are able to do so can wait out a poor set of job opportunities while gaining new skills. It’s important to note, however, that the tighter labor market since 2014 seems to have slowed, but not reversed, the previously rapidly increasing share of young people who are not in the labor force, and do not want a job, because they are enrolled in school.

nilf_by_age

In 1994, for about half of those age 19 to 21 who are not in the labor force (meaning they are not employed and have not been looking for work) the reason was school enrollment. The rest are often staying home to take care of family, disabled and unable to work, or sometimes believe that there is no job available. Since then, school enrollment has rapidly increased labor market non-participation. By the latest data, covering the year ending in March 2018, more than two thirds of non-participation is due to school enrollment. Among those age 22 to 24, the rate climbs from about one third in 1994 to about one half in the latest year of data. School-related non-participation growth among the slightly older cohort has largely stalled since 2013, while growth has slowed some among the younger group.

Much of the overall drop in full-time employment among young people comes from school enrollment. At least some portion was motivated by the particularly poor quality of the labor market during the years from 2001 to 2013, with students hoping to emerge more competitive and ideally at a time when job applicants have more bargaining power. It remains to be seen how much the Fed will allow the labor market to tighten  and how full-time employment and school enrollment will respond among younger people.

College degree boom and a changing labor market baseline

The March FOMC meeting minutes, released today, noted that increased education is changing the unemployment baseline:

A few participants warned against inferring too much from comparisons of the current low level of the unemployment rate with historical benchmarks, arguing that the much higher levels of education of today’s workforce—and the lower average unemployment rate of more highly educated workers than less educated workers—suggested that the U.S. economy might be able to sustain lower unemployment rates than was the case in the 1950s or 1960s.

It’s worth reiterating the Fed point with another labor market example. From the CPS, the median weekly earnings of women between the age of 25 and 54 increased steadily from 1997 to 2003 and again from 2014 to present.

uwe

But women with a college degree in this age group did not see the more recent increase. Instead, their earnings are nearly $50 per week below the 2003 peak, after adjusting for inflation.

uwe_ba

The same wage series for those with less than a bachelor’s degree and those with advanced degrees also peak around 2003. The increase in education is what explains overall median wage growth. Because college educated workers earn more than workers without a college degree–and because so many more people have obtained college degrees compared to 2006–median wages for the entire group increase.

The increase in the share of this group with a college degree is so astounding that the population of 25-54 year old women without at least a bachelor’s degree has been falling rapidly since 2007.

pop_ltba

Recent overall wage growth is not driven by an unsustainable unemployment rate, but by families and individuals sacrificing time and money for a decreasing reward.

The U.S. economy looks a lot better, starting in 2014

As we head into 2018, I still occasionally see arguments about the U.S. economy based on data that do not cover the years from 2014 to present. There is presumably nothing wrong with pre-2014 data, but it is worth keeping in mind that the economy looks a lot better since 2014. Perhaps most notably, wages and employment prospects improve for large portions of the population, an encouraging change in direction after many consecutive years of loss or stagnation. Recent data show a stronger economy coexisting comfortably with the environmental and labor policies of the past four years.

Specifically, three major pieces of the U.S. economic growth puzzle fall into place around 2014 and boost growth each year since: lower oil and energy prices, tighter labor markets, and available low-cost credit. These are discussed below and captured by the period averages in table 1.

Capture

Savings on energy boosted household finances

First, the price of oil fell sharply in 2014 and has remained low due to slowed demand from China, a large increase in domestic oil and gas production, increased green energy production, and more efficient energy use (for example more hybrid and electric cars). Several years with an average discount of 35 percent on oil, and similar discounts on other sources of energy, has improved household finances and boosted the economy. It translates to higher real income for Americans facing lower prices less at the pump, at the store, and on utilities.

Household spending on gasoline and similar fuels accounted for 2.5 percent of U.S. GDP from 2010 to 2014, but has fallen to an average of less than 1.8 percent of GDP from 2014 onward and is currently down to around 1.5 percent of GDP. Rather than save the money left over from less expensive commutes, which could have the effect of slowing the economy, Americans have turned it into new spending. Meanwhile, U.S. energy production has been expanding despite lower prices for gas and oil, thanks in part to increased export capabilities. Reasonably good fortune for both consumers and producers in the industry does not scream overly burdensome regulation.

Yellen pushed unemployment lower than expected

Next, the unemployment rate is currently much lower than many economists had believed it could go, and the Fed should get some credit for this. In January 2014, the unemployment rate was 6.6 percent and 76.4 percent of Americans age 25-54 had jobs. Instead of responding to missing-yet-theoretically-predicted inflation as the unemployment rate neared 5.5 percent, Chair Yellen’s Fed allowed the rate to fall to the current 4.1 percent. As of November 2017, inflation is low and stable and 79 percent of Americans age 25-54 have jobs, an increase over the January 2014 level equivalent to 3.3 million jobs. The rebound in employment for ‘working-age’ Americans should bring pause to claims that the economy has permanently written off portions of its previous workforce. The economy is not only still adding jobs at a rapid pace, but it is still pulling workers off of the sidelines and into the labor market. These trend are even more pronounced for black and Hispanic Americans.

Critically, when we near full employment, as we are doing now, there are no longer huge numbers of available unemployed workers to compete for new jobs or to replace workers who quit. As unemployed workers become scarce, businesses must increasingly compete with each other as employers. They do so by raising wages and making jobs better, and by better training and equipping existing workers. Benefits of full employment therefore include both increased wages and increased productivity. As pointed out by Dean Baker and others, recent data suggest that we are seeing this benefit. 

Borrowing is back despite [efforts at] regulation

In addition to benefits from more employment, Fed policy has kept mortgage rates and other borrowing costs low, further boosting the overall economy. At the end of 2017, the average interest rate for a 30-year fixed rate mortgage is slightly less than four percent. For context, this rate, which partially determines how much people pay for a home loan, had not fallen below five percent prior to the great recession. Importantly, unlike in the years immediately following the crisis, consumer access to credit has been growing in recent years, making loans both relatively cheap and more readily available. The often discussed credit freeze seems to thaw from 2014 to 2017.

Mortgages for younger Americans also become more common in recent years. First-time buyers made up only 29 percent of home sales in 2013, according to a June 2017 report from Genworth Mortgage Insurance, well below the 2009 or 2010 level. However, by 2016 new buyers make up 37 percent of sales, the highest share since 1999. I suspect that the average age of new home buyers is older now than it was in 1999, but average years of schooling have also increased over this period, so some delay to home ownership is expected. Commonly-accepted notions of young Americans shunning home ownership by choice (think avocado toast memes) are starting to look as suspicious as the financial sector claims about regulation preventing lending.

Gains from inherited policy can be saved or squandered

Many stories that make sense when describing the lack of economic recovery from 2008 to 2013 fail to fit the recent data. Peak oil, job-stealing robots, aging populations, crippling regulation, and people playing video games, we have been told, consign us to a different growth path. But, as I have discussed, contrary to the prediction of these stories, data covering the years since 2014 show rebounding employment rates, reasonable energy prices and interest rates, and the potential for strong wage and productivity growth. Beyond serving as face value good news, the sustained economic turnaround started in 2014, suggesting that the worker and environmental protection policies in place over the last four years are not too burdensome. As long as people like them, these policies should be maintained; the economy is growing just fine with them in place. If people particularly like some, like health care exchanges, there’s no reason not to improve or expand them.

Despite rapid improvement since 2014, the economy can still add millions of jobs before reaching full employment. This offers room for the current administration to score more policy gains than just the ones it has inherited (little additional growth is expected from its single policy accomplishment, the TCJA). Low-hanging fruit stems from the current interest rate of 2.75 percent on 30-year treasury bonds. Given the low cost of borrowing, the U.S. has little excuse for carrying a long list of unstarted infrastructure projects into 2018. The current administration, with a Republican majority in all three branches of government, is unhindered in its ability to shift more growth levers in the ‘four percent’ direction and push the country closer to full employment, and can do so with federal investments in infrastructure. Doing the opposite, such as by making unpopular cuts to social insurance, would have the effect of slowing the economy. New data and economic theory agree with voters on this one: keep the policies that work and focus on infrastructure.

 

Using APIs to get economic data with Python — list of Jupyter notebooks

I’ve cleaned up jupyter notebook examples of using data providers’ APIs to request data using python. Each notebook works through at least one example and has links to documentation.

Here are links to the individual notebooks:

Using the IMF Data API: Retrieving an IFS series with Python

April 5, 2017 Update: I’ve put together a newer version of the code/guide located here.

The following tutorial shows how to use python’s requests package to get data directly from the International Monetary Fund (IMF). The IMF’s application programming interface (API) provides access to economic and financial data of more than 180 countries over more than 60 years.

More information on the IMF Data API

The IMF offers guidance on using their data services. The API is not stable, so check the IMF data services news if you receive error messages.

More information on Python

This example works with the Anaconda distribution of Python 2.7.

A short example: Loading IMF data into pandas

Below is a short working example of loading the Australian export price index time-series from International Financial Statistics (IFS) into a pandas dataframe directly from the IMF API.

In [1]:

# Example: loading IMF data into pandas

# Import libraries
import requests
import pandas as pd

# URL for the IMF JSON Restful Web Service, 
# IFS database, and Australian export prices series
url = 'http://dataservices.imf.org/REST/SDMX_JSON.svc/CompactData/IFS/Q.AU.PXP_IX.?startPeriod=1957&endPeriod=2016'

# Get data from the above URL using the requests package
data = requests.get(url).json()

# Load data into a pandas dataframe
auxp = pd.DataFrame(data['CompactData']['DataSet']['Series']['Obs'])

# Show the last five observiations
auxp.tail()

Out [1]:

@BASE_YEAR @OBS_VALUE @TIME_PERIOD
232 2010 94.6044171093095 2015-Q1
233 2010 90.4668716801789 2015-Q2
234 2010 90.4668716801789 2015-Q3
235 2010 85.5465473860777 2015-Q4
236 2010 81.5208275090858 2016-Q1

Breaking down the URL

The ‘key’ in our request is the URL, which contains instructions about which data we want.

The URL has three parts,

  1. http://dataservices.imf.org/REST/SDMX_JSON.svc/CompactData/ The base for requests using the JSON restful data service;
  2. IFS/ the database ID, IFS, for International Financial Statistics;
  3. Q.AU.PXP_IX.?startPeriod=1957&endPeriod=2016 the data dimension and time period information.

The third part, data dimension and time period information, is broken down on the IMF Web Service knowledge base as:

{item1 from dimension1}+{item2 from dimension1}{item N from dimension1}.{item1 from dimension2} +{item2 from dimension2}+{item M from dimension2}? startPeriod={start date}&endPeriod={end date}

For guidance on finding dimension information and building your request, see my previous example of using the IMF API to retrieve Direction of Trade Statistics (DOTS) data. 

Cleaning up the dataframe

Let’s add more meaningful headers and set the date as our index

In [2]:

# Rename columns
auxp.columns = ['baseyear','auxp','date']

# Set the price index series as a float (rather than string)
auxp.auxp = auxp.auxp.astype(float)

# Read the dates as quarters and set as the dataframe index
rng = pd.date_range(pd.to_datetime(auxp.date[0]), periods=len(auxp.index), freq='QS')
auxp = auxp.set_index(pd.DatetimeIndex(rng))
del auxp['date']

# Show last five rows
auxp.tail()

Out [2]:

baseyear auxp
2015-01-01 2010 94.604417
2015-04-01 2010 90.466872
2015-07-01 2010 90.466872
2015-10-01 2010 85.546547
2016-01-01 2010 81.520828

Plot the data

Now we can use matplotlib to create a line plot showing the history of the Australian export price index.

In [3]:

# import matplotlib and pyplot
import matplotlib as mpl
import matplotlib.pyplot as plt
%matplotlib inline

# Create line plot and add labels and title
auxp.auxp.plot(grid=True, figsize=(9, 5), color="orange", linewidth=2,)
plt.ylabel('Index')
plt.xlabel('Year')
plt.title('Australia: Export Price Index (baseyear=' + str(auxp.baseyear[0]) + ')');

Out [3]:

Output from script

Save as a csv file

To save the data for use in another program, you can easily create a csv file.

In [4]:

auxp.to_csv('auxp.csv')

 

Update 2 (August 2018)

The IMF API and python have changed since my original post on using the IMF API.

The version on my newer website still works.

Here’s an updated chunk of code for the retrieval of information on Australia’s export prices. When run in a jupyter notebook cell, this version returns a graph of the 12-month percent change in the Australian export price index. The code also shows how to use a dictionary comprehension to convert the IMF API json data into a pandas series.

In [1]:

import requests
import pandas as pd
%matplotlib inline

url = 'http://dataservices.imf.org/REST/SDMX_JSON.svc/'
key = 'CompactData/IFS/Q.AU.PXP_IX' # adjust codes here
r = requests.get(f'{url}{key}').json()
obs = r['CompactData']['DataSet']['Series']['Obs']
(pd.Series({pd.to_datetime(i['@TIME_PERIOD']): 
            float(i['@OBS_VALUE']) 
            for i in obs}).pct_change(12).multiply(100)
 .plot(title='Australia Export Price Index Inflation Rate'))

 

Brexit and the feedback of uncertainty through asset prices

The medium- and long-run consequences of Brexit are unknown, but increased uncertainty in response to the event will likely have real global effects of its own. Individuals are now less confident in their guesses about the future, and this uncertainty changes behavior, increasing risk aversion and decreasing business investment. Global market reactions to Brexit reflect not only the new average belief about expected future earnings, but also the indirect feedback effects of the higher level of uncertainty.

Medium- and long-term effects unclear

The U.K.’s June 23 vote to leave the European Union, termed ‘Brexit’, surprised many analysts. As the referendum vote neared, markets (representing the average belief of individuals) increasingly expected the ‘remain’ party to win. Some well-educated analysts explained how Brexit would never happen (possibly what Nassim Nicholas Taleb would consider proof of a black swan). The ‘leave’ campaign won with 51.9 percent of the vote, prompting David Cameron’s announced resignation.

The medium-term consequences for the U.K. and E.U. (or anywhere else) are entirely unclear. For example, should unemployment increase and production falter in the U.K. during the next few months, the Bank of England may need to ease monetary policy further and adopt very unconventional tools. However, if the market reaction to Brexit can be fully absorbed by exchange rate adjustment, the Bank of England may need to raise interest rates in response.

On June 24, the pound sterling fell more than eight percent against the dollar (figure 1). In response to the currency depreciation, many here in the U.S. joked about buying goods online from the U.K. or planning vacations. Many others expressed uncertainty about the future of the U.K. and the E.U., and the economic and political implications for the U.S.

gbp_jun262016
Figure 1. The pound sterling fell against most currencies following the Brexit vote, including by more than eight percent in one day against the U.S. dollar.

Markets reminded of their anxiety issues

Within hours of the ‘leave’ campaign victory, stock prices of some financial services companies, such as Lloyds, fell by 30 percent. Although real changes from the vote may take two years to implement, the average belief about the appropriate cost of equity for these firms changed dramatically overnight. The fundamentals for people and businesses in the U.K. do not immediately change, but their behavior and asset prices do, and this has an indirect feedback effect on the fundamentals

Likewise, the U.S. is clearly not part of the E.U. or U.K., however, it is intimately linked to both markets through trade and investment. The Dow Jones Industrial Average fell 610 points (3.39%) on Friday in response to the news. The most widely-used measure of market volatility jumped nearly 50 percent (figure 2). The sales revenue of the largest U.S. companies is practically unchanged, however, individuals’ collective behavior has changed in response to uncertainty.

Individuals are repricing the assets that they previously overvalued. However, if the Bank of England is forced to wait to decide which direction its key policy will turn, how well can individuals immediately reprice future earnings? The immediate reaction to Brexit reflects not a new certainty about future earnings but increased uncertainty. Individuals never know what the future will hold, but these large unexpected events make them less confident in all of their guesses, and it changes their behavior.

vix_jun252016
Figure 2. VIX, the CBOE measure of expected near-term equity market volatility, saw an almost 50 percent daily increase following the Brexit result

Searching for safety and the uncertainty feedback loop

When people are less certain about the future, they take fewer risks. For example, business investment falls when equity market volatility is high. Individual and institutional investors also show preference for safe assets during times of increased uncertainty. In an immediate reaction to Brexit, U.S. treasuries, gold, and Japanese Yen saw inflows, while equity markets saw net outflows. Neither business fundamentals nor any rules had changed; people were showing risk aversion.

Investors’ increased aversion to equity investment raises firms’ equity cost of capital. This cost of capital is a major factor in firms’ investment decisions, especially for smaller and less-cash-flush firms. Therefore, the uncertainty induced asset price shock has a feedback mechanism through which it affects the future value of companies. This dangerous feedback mechanism can be procyclical.

What it means for the U.S.

The medium- and long-term direct effects of Brexit on the U.S. are very unclear. Brexit-induced equity market volatility, higher levels of uncertainty, and the negative effects these entail can however be analyzed with attention to the current U.S. macroeconomic environment. Three potential short-run consequences emerge:

1) Continued volatility in equity markets and strong demand for treasuries;

2) More downward pressure on business investment, which was already negative in the first quarter of 2016; and

3) Delay of the next Federal Funds rate hike in response to the above.

While the downward pressure on already weak business investment is worrisome, none of the above are enough to induce major concern. Households, many of which have recently started seeing long-awaited wage and income increases, will play a key role in determining whether recent asset price volatility will spill into consumer sentiment and awake a much worse set of feedback mechanisms.

Check out the dashboard and please leave feedback

Nearly 100 freshly updated charts:

U.S. Macro and Markets Dashboard (Updated June 26, 2016)

References and additional reading

Networks, Crowds, and Markets: Reasoning About a Highly Connected World by David Easley and Jon Kleinberg

Nick Bloom comment on Brexit 

BBC: The UK’s EU referendum: All you need to know