Can Google queries help predict economic activity?

In Bill Tancer’s book Click, he gives some examples of how near real-time Internet data provides a time advantage over traditional leading economic indicators.  These indicators are typically only available with a time lag.  The data for a particular month is generally released about halfway through the next month.  I found this concept quite interesting when I read the book a year ago.  I never really pursued it analytically myself, until I recently discovered a nice interface to query Google Trends data from within the leading freely available open-source statistical software package R.   The R package RGoogleTrends (developed under the Omegahat Project) provides a very useful tool to extract and analyze Google query data in an efficient manner.   In the documentation for this package it is stated that its development was inspired by a blog post by Google’s chief economist, Hal Varian, which was published on the Google’s Research Blog.  They illustrate some simple forecasting methods, and encourage readers to undertake their own analyses.  By their own admission it is possible to build more sophisticated forecasting methods.  We decided to take up the challenge, because at Clicks2Customers we are always keen for an analytical challenge, especially if it comes from the mighty Google.

R has a wide range of sophisticated time series packages, which we decided to put to the test to see if the incorporation of query data can indeed improve the estimation and forecasting of leading economic indicators.  In this post we will focus on the monthly home sales data released by the US Census Bureau and the US Department of Housing and Urban Development at the end of each month and which was used in Google’s study.  In order to make our results comparable to that of Google, we use the same January 2004 to July 2008 time window.

Our aims are two-fold:

  1. Verify that a more sophisticated time series modeling approach improves accuracy compared to Google’s relatively simple models
  2. Verify that the inclusion of query data in models improves the accuracy of estimates

In figures 2 and 3 we show the raw and seasonally adjusted home sales data downloaded from the US Census Bureau.   Similar to the Google study we will start our modeling process on the seasonally adjusted sales figures.   This is to aid a comparison of our results with those of Google, although the seasonal component can easily be modeled directly.  Google Trends provides an index of the volume of Google queries by geographic location and category.  The query index of a search term reflects the query volume for that term in a given geographical region divided by the total number of queries in that region at a point in time.  This index is then normalized relative to January 1, 2004.  The index at a later date therefore reflects a percentage deviation from January 1, 2004.  Google Trends data is also reflected on a category and sub-category level.   Figure 3 reflects the search index data for the ‘Real Estate’ category and 5 of its sub-categories: Real Estate Agencies, Home Financing, Home Inspections & Appraisal, Property Management, and Rental Listings & Referrals.

Figure 1: Raw Home Sales Data

Figure 1: Raw Home Sales Data

Figure 2: Seasonally adjusted home sales data

Figure 2: Seasonally adjusted home sales data

Figure 3: Google query volumes for the Real Estate category and 5 of its sub-categories

Figure 3: Google query volumes for the Real Estate category and 5 of its sub-categories

The Google study fits simple auto-regressive models using standard linear model fitting functions.  A closer investigation of these models shows that they do not adequately model the correlation structure in the data.  We will follow a more classical time series approach based on the classic autoregressive integrated moving average (or ARIMA) time series models.  In our study we will first model the house sales data on its own, in order to establish a performance benchmark.  Thereafter, we will incorporate query data in the models to test if its inclusion can improve the prediction of house sales data.  We will evaluate the prediction of the different models by making a series of one-month ahead predictions and compute the prediction error, known as the mean absolute error (MAE), as defined in the Google study. Each forecast uses only the information available up to the time the forecast is made, which is one week into the month in question.

The simplest time series model that is closest to the null model (Model 0), presented by Google is an ARIMA(1,1,0) model.  The difference being that our model takes a lag-1 difference of the log-transformed data to reduce it to a stationary data series, which is a necessary prerequisite.   This model provides a reasonable fit to the data and gives a prediction error of 6.03%, which is lower than the 6.91% of Google’s null model.  There is some suggestion in the data that a higher order auto-regressive model may provide a better fit.  We found that an ARIMA(7,2,0) model does result in an improved fit and a significantly reduced prediction error of 4.04%.  The previous model already outperforms Google’s more advance model (Model 1) with a prediction error of 6.08%, which already incorporates query data and house prices.  Next we take it up a notch by incorporating the above Google query data and fitting a multivariate time-series model.  We use the query data in the first week of each month.  We experiment with different combinations of the above query indices and found that the Property Management query index gives the lowest prediction error of 3.7%.  The model we fit is a vector auto-regressive model with a lag of 3 using the R package dse.  The monthly 1-step ahead prediction errors for the above models above are plotted in figure 3.

Figure 4: US home sales data 1 step ahead prediction errors

Figure 4: US home sales data 1 step ahead prediction errors

Let us return to our stated aims.  It seems like we have verified both aims, namely that a more formal time series approach improves considerably on the models presented by Google and that the inclusion of query data has the potential to further improve the 1-step ahead prediction in the case of the house sales data.  Our best performing model improves about 39% on the best model presented in the Google study in terms of 1 step ahead prediction accuracy (without incorporating the house price data used by Google yet).  There seems to be potential in using Google query data in forecasting economic data.

This is a single example and a proper study will have to apply a more sophisticated modeling approach to a much wider range of data sets.  The Google study also illustrates the use of Google Trends data in predicting travel visits.  In their example they use data from the Hong Kong Tourism Board.  We intent to perform a similar study using monthly tourism data released by Statistics South Africa in conjunction with Google Trends data for the period building up to the 2010 FIFA World Cup.  This should make for an interesting case study for the use of Google Trends data.  Keep an eye on our blog for the results sometime in the future!

About Wiesner Vos
A chartered statistician with a passion for quantitative marketing.

Comments

One Response to “Can Google queries help predict economic activity?”
  1. Wiesner Vos says:

    PS: It is worth mentioning that I also compared the VAR(3) method against an equivalent univariate AR model without the inclusion of query data. This yielded a MAE of 4%, similar to the ARIMA(5,1,0) model. So there is still an improvement in predictive ability. There is more work than can be done in terms of the subset of monthly query data that can be included etc. Wiesner

Speak Your Mind

Tell us what you're thinking...
and oh, if you want a pic to show with your comment, go get a gravatar!