metadata: authors: 0: author: Seabold,Skipper
1: author: Coppola,Andrea
count: Central America
docna: 0: docna: Nowcasting prices using Google trends : an
            application to Central America
docty: Policy Research Working Paper
subtopic: Economic Theory & Research,Industrial Economics,Health Care Services Industry,Food Security,Economic Growth,Employment and Unemployment,Economic Modeling and Statistics
teratopic: Macroeconomics and Economic Growth
abstracts: cdata!: The objective of this study is to assess
            the possibility of using Internet search keyword data for
            forecasting price series in Central America, focusing on
            Costa Rica, El Salvador, and Honduras. The Internet search
            data comes from Google Trends. The paper introduces these
            data and discusses some of the challenges inherent in
            working with it in the context of developing countries. A
            new index is introduced for consumer search behavior for
            these countries using Google Trends data covering a two-week
            period during a single month. For each country, the study
            estimates one-step-ahead forecasts for several dozen price
            series for food and consumer goods categories. The study
            finds that the addition of the Internet search index
            improves forecasting over benchmark models in about 20
            percent of the series. The paper discusses the reasons for
            the varied success and potential avenues for future research.
repnme: repnme: Nowcasting prices using Google trends : an
            application to Central America
display_title: Nowcasting prices using Google
            trends : an application to Central America
listing_relative_url: /research/2015/08/24925642/nowcasting-prices-using-google-trends-application-central-america
topicv3: Agriculture and Food Security m1326205 435,Economic Growth m1326241 471,Unemployment m1504051 2747,Macroeconomic Modelling and Statistics
            m1504530 3108,Health m1504661 3480
publishtoextweb_dt: 2015-08-19T00:00:00Z
historic_topic: Macroeconomics and Economic Growth
no_of_pages: 40
author_keys: 0: author_key: 1067394
model_extractions: WPS7398 Policy Research Working Paper 7398 Nowcasting Prices Using Google Trends An Application to Central America _Skipper Seabold Andrea Coppola_ Macroeconomics and Fiscal Management Global Practice Group August 2015
Policy Research Working Paper 7398

# **Abstract**

The objective of this study is to assess the possibility of using Internet search keyword data for forecasting price series in Central America, focusing on Costa Rica, El Salvador, and Honduras. The Internet search data comes from Google Trends. The paper introduces these data and discusses some of the challenges inherent in working with it in the context of developing countries. A new index is introduced for consumer search behavior for these countries using Google Trends data covering a twoweek period during a single month. For each country, the study estimates one-step-ahead forecasts for several dozen price series for food and consumer goods categories. The study finds that the addition of the Internet search index improves forecasting over benchmark models in about 20 percent of the series. The paper discusses the reasons for the varied success and potential avenues for future research.

This paper is a product of the Macroeconomics and Fiscal Management Global Practice Group. It is part of a larger effort by the World Bank to provide open access to its research and make a contribution to development policy discussions around the world. Policy Research Working Papers are also posted on the Web at http://econ.worldbank.org. The authors may be contacted at jsseabold@gmail.com.

_The Policy Research Working Paper Series disseminates the findings of work in progress to encourage the exchange of ideas about development issues. An objective of the series is to get the findings out quickly, even if the presentations are less than fully polished. The papers carry the names of the authors and should be cited accordingly. The findings, interpretations, and conclusions expressed in this paper are entirely those of the authors. They do not necessarily represent the views of the International Bank for Reconstruction and Development/World Bank and its affiliated organizations, or those of the Executive Directors of the World Bank or the governments they represent._ Produced by the Research Support Team
# Nowcasting Prices Using Google Trends: An Application to Central America

Skipper Seabold `American University` Andrea Coppola `The World Bank`<sup>_∗_</sup> JEL codes: E31,C55,C8 Keywords: Macroeconomic modeling and statistics, Inflation, Big Data _∗_ Corresponding author e-mail: jsseabold@gmail.com. This is a preliminary draft.
# **1 Introduction**

It is a well recognized problem that policy makers must make decisions before all data about the current economic environment are available. Given this reality, there is considerable interest in short-term forecasting and nowcasting using intra-period data releases. For example, the forecaster can provide an estimate of GDP this quarter using other data that are available at a monthly frequency. This technique is called nowcasting, or predicting the present. Giannone et al. [2008] lays out three tenets of nowcasting. First, many data series are used. Second, nowcasts are updated as intraperiod data become available. Finally, nowcasting “bridges” higher frequency data releases with the nowcast of the lower frequency series of interest. This study is similar in spirit to that of Giannone et al. [2008]. However, while Giannone et al. [2008] are concerned with nowcasting GDP using a large number of economic data series, this paper nowcasts price series using Internet search keyword data from Google Trends<sup>1</sup> . Furthermore, we do not attempt to “bridge” higher frequency data with lower frequency data explicitly as part of a model. The Google Trends data are not all systematically available at a higher frequency than the series we wish to forecast. Instead, we are more concerned with the efficient aggregation of many series to help improve our nowcasts.

There are three main contributions of this study. First, it focuses on the countries of Central America. Almost the entirety of the nowcasting literature focuses on developed countries with one notable exception in Carri`ere-Swallow and Labb ́e [2013]. Second, this is a large scale study, approaching the problem of nowcasting with Google Trends from a data mining perspective rather than one solely grounded in economic theory. This approach gives us insights that will be useful for forecasters who wish to pursue similar ends. Third, we introduce methods from the statistical learning literature to compute the Google Trends keyword search index that are not yet commonly used in forecasting studies.

Given the large number of series included in this study, we rely heavily on automatic model identification procedures. Despite this potential shortcoming, we find that Google Trends can improve our ability to forecast certain series. These findings are notable and may be worth pursuing in more detail. The outline of the paper is as follows. Section 2 reviews some of the literature for nowcasting and the use of Google Trends data in forecasting. Section 3 introduces the data and includes a section that discusses the challenges of working with Google Trends data for the countries of Central America. Section 4 explains the framework used for forecasting and evaluating forecasts. Section 5

> 1 `http://google.com/trends`

2
discusses the results of this exercise and assesses the usefulness of Google Trends data in forecasting price series for Central American countries. Section 6 concludes, noting several paths for continuing research. While this section deals specifically with ideas for future research there are notes about ongoing research throughout the paper.

# **2 Literature Review**

There is a growing literature that is using Internet search keyword data and Google Trends, in particular, for forecasting and nowcasting. Ettredge et al. [2005] were the first to use search engine keyword data to aid in forecasting. They found keywordbased searches to be helpful in predicting the number of unemployed workers in the United States. The use of Google Trends data, specifically, in forecasting yet to be released macroeconomic series goes back to Choi and Varian [2009, 2012]. They find that Google Trends data help to forecast initial unemployment claims, automobile sales, and consumer confidences in the United States. Since then, there are been numerous efforts to use Google Trends data in forecasting. Schmidt and Vosen [2012] uses search data related to the “cash for clunkers” program to improve forecasts for private consumption in France, Germany, Italy, and the United States. Guzman [2011] uses Google search data to estimate inflation expectations. Suhoy [2009] estimates accurate probabilities of downturn in early 2007 using Google search category data for Israel. The author also finds improvements in estimates of private consumption by employing the search data.

Early results on using Google Trends data as a proxy for consumer sentiment are promising. Traditionally, studies have made use of survey-based sentiment data to provide leading indicators of series of interest. However, this data is not always available, especially in developing countries. Vosen and Schmidt [2011] show that Google Trends outperforms The University of Michigan Consumer Sentiment Index and the Conference Board Consumer Confidence Index in predicting private consumption in the United States. One study which is very relevant to our present effort is that of Carri`ere-Swallow and Labb ́e [2013]. The authors look at the benefits of using Google Trends data in the context of a developing country, Chile. They develop an index of consumer interest in automobile purchaes and find that it outperforms benchmark specifications that take advantage of the IMACEC index of consumer activity. We will use a similar framework to the one employed in that study in what follows.

3
# **3 Data**

This section first describes the raw data and then the transformations that are made to each series before estimation. A subsection is dedicated to addressing some of the challenges inherent in working with the search query data from Google in emerging market countries. For each of Costa Rica, El Salvador, and Honduras<sup>2</sup> , there are two – categories of series that we will forecast data on aggregate consumer prices and their component series and staple food price data.

We obtained the consumer price data from the statistical office of each country. See Appendix A for details. The raw series are in levels and are not seasonally adjusted.

The food price data was obtained from the Global Information and Early Warning System on Food and Agriculture (GIEWS) from the Food and Agriculture Organization of the United Nations (FAO). The types of food that are available from GIEWS are particular to each country. We obtained every available series. Appendix A gives, for each country, the series names, appropriate region, and the units for which we have data available. These series are not seasonally adjusted.

To augment our forecasts, we have obtained Google Trends data on a number of search keywords. These keywords were chosen _ex ante_ with the belief that they contain relevant information that will allow us to use them as a proxy for consumer behavior and beliefs. Obtaining real-time insights into consumer behavior allows us to better predict price changes all other things equal. In some sense, the Trends data takes the place of traditional consumer-sentiment surveys. The keywords that we have chosen are listed in Table 1.

Each individual Google Trend series is relative and not an absolute measures of search volume. That is, the period in which the search interest of a keyword is highest within the dates of inquiry receives a value of 100. All other periods for an individual series are measured relative to this highest period. There is, therefore, no sense of how many people were searching for a term and the terms themselves are not comparable with each other. Furthermore, changes in Internet penetration and the use of Google, in particular, do not matter.

The following transformation is made to each price series before estimation to go from

> 2We could not acquire sufficient data on food prices or on search keywords for Belize, so it is omitted from discussion. Earlier versions of this paper contained every other country in Central America. However, given some of the data challenges discussed below, we chose to narrow our interest to three countries. We chose Costa Rica and El Salvador because they generally have good data availability from Google Trends. The quality of the data for Honduras, on the other hand, was found to be rather poor, so we included it to learn more about how the models perform under adverse data conditions.

4
# **Search Keywords**

||cr|hn|sv|
|---|---|---|---|
|arroz|x|x|x|
|azucar|x|x|x|
|carne|x|x|x|
|caro|x|x|x|
|cerdo|x|x|x|
|combustible|x|x|x|
|cuesta|x|x|x|
|diesel -vin|x|x|x|
|frijoles|x|x|x|
|gas|x|x|x|
|gasolina|x|x|x|
|infacion|x|x|x|
|ingresos|x|x|x|
|maiz|x|x|x|
|pago|x|x|x|
|pan|x|x|x|
|precio|x|x|x|
|precios|x|x|x|
|propano|x||x|
|salario|x|x|x|
|sueldo|x|x|x|
|trigo|x|x|x|

Table 1: The keywords that are used in the forecasting. We found that the search term “diesel -vin” was more reliable in returning searches related to diesel fuel rather than the actor Vin Diesel. All analysis is based on this term.

5
levels to month-over-month percentage changes No series has been seasonally adjusted prior to downloading. Therefore, many of the series exhibit some degree of and sometimes a strong degree of seasonality. As discussed below, we will attempt to model the seasonality explicitly when present.

A few of the GIEWS price data series contain missing observations. The missing observations were replaced using simple linear interpolation before applying this transformation.

The Google Trends data are transformed as follows. Some of the search terms are available at weekly frequencies while other series are only available at monthly frequencies. For those that are available at a weekly frequency, we take the maximum value in each month to be the value for that month. This differs from the approach of Vosen and Schmidt [2011] and Carri`ere-Swallow and Labb ́e [2013] who aggregate the weekly data into monthly series by taking the monthly average of the indicators. Since the data are relative, we do not wish to first smooth them in this way. This could mask potentially important, short-lived events. Further transformations to the Trends data are described in the next subsection.

# **3.1 Challenges in Using Google Trends Data**

Several challenges present themselves when working with the Google Trends data in a developing country context. First, as pointed out by Carri`ere-Swallow and Labb ́e [2013], Google Trends historical data are not constant over time. Within the same 24-hour period, the results will be the same. However, from day to day the results can be different. Indeed, not only do the values change, but on one day monthly data may be returned. On another biweekly or weekly data for the same keyword search. It is unclear, what exactly – is driving these differences whether different normalizations, sampling considerations, or something else, but for practical purposes we can treat the data as being recorded with sampling error with the same consequences. For the present study, we collected data on all of the keywords for ten days over a period of one month. Figures 1 and 2 show the sampling error for two representative series collected during this period.

These series are chosen to be representative of all of the series used and show the two most salient features for the purposes of this study. First, the sampling error is evident 6
<!-- Start of picture text --> Costa Rica<br>"precios"<br>100<br>80<br>60<br>40<br>20<br>0<br>2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014<br><!-- End of picture text --> Figure 1: Results for 10 days during the study period for the “precios” keyword in Costa Rica. The dark line is the average. The gray bands are minimum and maximum observed values for that month over the study period.

7
<!-- Start of picture text --> El Salvador<br>"caro"<br>100<br>80<br>60<br>40<br>20<br>0<br>2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014<br><!-- End of picture text --> Figure 2: Results for 10 days during the study period for the “caro” keyword in El Salvador. The dark line is the average. The gray bands are minimum and maximum observed values for that month over the study period.

8
in both figures. Figure 1 is in some sense a best case scenario. Variability is very large for the first two years of the sample but becomes quite a bit more stable after this initial uncertainty. Figure 2, on the other hand, shows high sampling variability throughout the entire period. We will assume that the signal of each series can be well approximated by its average and use the average when referring to the series for a single keyword in what follows unless otherwise indicated.

The second thing to note in figures 1 and 2 are that many of the observations for a single draw of the Google Trends data are exactly zero. These zero observations present two difficulties in particular – one conceptual and one practical. First, conceptually, these zeros suggest a lack of signal where presumably there should be some. As we collect more daily samples of the data, this problem becomes less and less, again assuming that the signal is well approximated by the mean. However, this problem does not disappear. Looking at the early parts of both series, there are still observations which are zero even at the mean.

Second, as a practical problem, some of the Google Trends data contain strong seasonal components. Studies such as Carri`ere-Swallow and Labb ́e [2013] alleviate the effects of seasonality in the trends data by using year-over-year percent changes for them as well as the series to forecast. However, if the base year is zero, we would lose this entire year of data.

We employed several techniques in an attempt to overcome these problems, which we will now describe. The Google trends data can be written more formally as _Xi,j,t_ – where _i_ represents the vintage a downloaded sample on a particular day, _j_ represents a particular keyword, and _t_ represents the weekly, bi-weekly, or monthly observation of each keyword. The first task is to deal with the _i_ vintage, or sample, index. We took the mean and the median of all the samples. This leaves us with either for the mean, where _I_ is the total number of samples taken or for the median.

After handling the sampling dimension, we apply transformations to smooth the data for each keyword and attempt to better identify the signal from the noise, given the 9
nature of the search data. Here, we take several different approaches. First, we apply a simple exponential smoothing model with additive errors to the data. Following the notation of Makridakis et al. as used in Hyndman et al. [2002], this model can be written We choose to fix _α_ = _._ 5. Results typical of this smoothing can be seen in figures 3 and 4. We include both the forecastable part of the series and the unsystematic “surprise” part of the series.

We also tried smoothing the results by applying the Christiano-Fitzgerald (CF) bandpass filter [Christiano and Fitzgerald, 2003]. The CF filter starts from the (false) assumption that the underlying data obeys a unit root process. Using this assumption, the CF filter provides an approximation to an optimal band-pass filter as follows where _Bj_ =<sup>sin(</sup><sup>_<u>jb</u>_</sup><sup><u>)</u></sup> _πj_<sup>_−_sin(</sup><sup>_<u>ja</u>_</sup><sup><u>)</u></sup> _, j ≥_ 1 and _B_ 0 =<sup>_<u>b−</u>_</sup> _π_<sup>_<u>a</u>_,</sup><sup>_a_=</sup><sup><u>2</u></sup> _p_<sup>_<u>π</u>_</sup> _u_<sup>,</sup><sup>_b_=</sup><sup><u>2</u></sup> _p_<sup>_<u>π</u>_</sup> _l_<sup>,</sup><sup>_B_ ̃</sup><sup>_k_=</sup><sup>_−frac_12</sup><sup>_B_0</sup><sup>_−_</sup> � _j_<sup>=1</sup><sup>_k−_1</sup><sup>_Bj_.Theparameters</sup><sup>_pu_and</sup><sup>_pl_denotethecut-offsforthecyclesforthehigh</sup> and low frequency elements, respectively. We remove all stochastic cycles at a periodicity lower than 3 months and higher than 12 months. This has the effect of both smoothing the series and removing long-term seasonality. The results of applying the CF filter to our two selected series can be seen in figures 5 and 6.

One notable advantage of techniques such as exponential smoothing and the CF filter is that they provide us with real-time estimates at the ends of our series so that we do not need to truncate our observed series at the beginning or the end as would be necessary if we used a simple moving averages, seasonal differences, or, another filter such as the Baxter-King.<sup>3</sup>

> 3 Of course, we could estimate a model and forecast and backcast then apply a filter that truncates, using these extra data points. However, this is another form of uncertainty that we would like to avoid introducing. Instead, we prefer to use only the information we have.

10
<!-- Start of picture text --> Costa Rica<br>"precios"<br>90<br>80<br>70<br>60<br>50<br>40<br>30<br>20 Series Average<br>10 A,N,N<br>0<br>2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014<br>80<br>60 Unsystematic Part<br>40<br>20<br>0<br>20<br>40<br>2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014<br><!-- End of picture text --> Figure 3: Smoothed results for the average of the “precios” keyword in Costa Rica. The top pane contains the original series and the smoothed, in-sample forecasted series. The forecasted series is labeled _A, N, N_ indicating additive errors, no trend, and no seasonality according to the Hyndman et al. [2002] taxonomy. The bottom pane contains the unsystematic or “surprise” component of the series.

11
<!-- Start of picture text --> El Salvador<br>"caro"<br>90<br>80 Series Average<br>70 A,N,N<br>60<br>50<br>40<br>30<br>20<br>10<br>0<br>2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014<br>50<br>40 Unsystematic Part<br>30<br>20<br>10<br>0<br>10<br>20<br>30<br>40<br>2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014<br><!-- End of picture text --> Figure 4: Smoothed results for the average of the “caro” keyword in El Salvador. The top pane contains the original series and the smoothed, in-sample forecasted series. The forecasted series is labeled _A, N, N_ indicating additive errors, no trend, and no seasonality according to the Hyndman et al. [2002] taxonomy. The bottom pane contains the unsystematic of “surprise” component of the series.

12
<!-- Start of picture text --> Costa Rica<br>"precios"<br>100<br>filtered<br>original<br>80<br>60<br>40<br>20<br>0<br>20<br>2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014<br><!-- End of picture text --> Figure 5: Smoothed results for the average of the “precios” keyword in Costa Rica. The smoothed series is computed using the Christiano-Fitzgerald filter with all stochastic cycles at a periodicity lower than 3 months and higher than 12 months removed.

13
<!-- Start of picture text --> El Salvador<br>"caro"<br>filtered<br>80 original<br>60<br>40<br>20<br>0<br>2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014<br><!-- End of picture text --> Figure 6: Smoothed results for the average of the “caro” keyword in El Salvador. The smoothed series is computed using the Christiano-Fitzgerald filter with all stochastic cycles at a periodicity lower than 3 months and higher than 12 months removed.

14
# **4 Methodology**

To nowcast a series at a particular point in time, we produce an estimate of the series before that variable has been observed but when other contemporaneous variables in our information set have been observed. For instance, we might use data available to us now to get an estimate for economic growth or inflation before official statistics are released. As a concrete example, suppose that in mid-April 2014, we have either a few weeks of Google Trends data or perhaps some preliminary monthly estimate of a search term, but we do not yet know the current inflation. Lags in publication of inflation could mean that we only have estimates for inflation through March or even February 2013. If a policymaker is interested in knowing inflation today, we would nowcast at a monthly _m_ horizon of _hm ≥_ 1.

Our strategy for this exercise is as follows. For each series in each country we will compare nowcasts using Google Trends data and one-step ahead forecasts from a best effort ARIMA model to some benchmark models to assess if the information available from Google Trends data improves our forecasting ability. We now introduce our benchmark models. In the following subsection, we discuss what we mean by a “best effort” ARIMA model.

## **4.1 Benchmark Models**

Five simple models are estimated to provide a baseline for the candidate models described below. The estimated baseline models are the simple mean of the series, the median of the series, the value of the series in the previous period, an AR(1) model, and an _A, A, N_ exponential smoothing model. This exponential smoothing model written in its recursive form is given by where _lt_ and _bt_ are the level and growth rate, respectively, and the parameters along with the initial states are estimated as described in section 3.1. This model is otherwise known as Holt’s linear method with additive errors and is equivalent to an ARIMA (0 _,_ 1 _,_ 1) model [Hyndman et al., 2008]. Our one-step ahead point forecasts are given by 15
# **Benchmark Results**

|Benchmark Model|Total|
|---|---|
|ar|23|
|ets|4|
|mean|11|
|median|20|

Table 2: The total number of series for which each benchmark model is deemed the best by the MSE criterion.

where _εt ∼ N_ (0 _, σ_ ) in (5d). We choose the baseline model for each series based on mean squared error (MSE). MSE is defined as usual where _Y_<sup>ˆ</sup> _t_ is our forecast estimate, _Yt_ is the true observation at time _t_ , and _T_ is the total number of observations.

To compute the MSE for the benchmarks, we start with two years of data and compute one-step ahead forecasts using each benchmark model until time _T −_ 1 where _T_ is the last period for which we have data that we wish to forecast. We then choose the model that has the best performance in all periods as the benchmark model for that series. Table 2 presents an overview of which benchmark model is best in an MSE sense. The AR(1) and median are preferred the most often. The benchmark for the individual series is presented with the full results in section section 5 for ease of comparison.

16
# **4.2 Forecasting and Nowcasting Models**

To attempt to improve over these baseline models, we first estimate a possibly seasonal Autoregressive integrated moving-average (ARIMA) model for each monthly series.

where _yt_ is the series we wish to forecast, _εt_ follows a white noise process, _L_ is the lag operator _L_<sup>_i_</sup> _yt_ = _yt−i_ , _φ_ ( _L_ )<sup>_p_</sup> = (1 _− φ_ 1 _L −· · · − φpL_<sup>_p_</sup> ) is the non-seasonal polynomial of order _p_ in the lag operator that describes the autoregressive component of the model and _φ_ 12 ( _L_<sup>12</sup> )<sup>_P_</sup> = �1 _− φ_ 12 _,_ 1 _L −· · · − φ_ 12 _,P L_<sup>_P_�</sup> is the seasonal polynomial of order _P_ in the lag operator that describes the seasonal autoregressive component of the model. The polynomial of order _q_ that denotes the non-seasonal MA component of the model is _θ_ ( _L_ )<sup>_q_</sup> , and likewise the seasonal MA component of order _Q_ is denoted _θ_ ( _L_<sup>12</sup> )<sup>_Q_</sup> . The non-seasonal and seasonal orders of differencing are denoted _d_ and _D_ , respectively.

We use the auto.arima function from the forecast package in R<sup>4</sup> for order identification for each series. See Hyndman and Khandakar [2008] for more information on the model identification procedure.<sup>5</sup> The auto.arima automatic model identification procedures allows parameters to be zero, so in principal, for example, the model is only differenced or includes a seasonal component when it is appropriate.

To test whether there is information in the Google Trends data that will help us forecast each series, we use a possibly seasonal ARIMAX model where the Trends data is used as an exogenous variable.<sup>6</sup>

## The seasonal ARIMAX model estimated is specified

> 4We used the 5.4 develpment version obtained from `https://github.com/robjhyndman/forecast/`

> 5We also performed order identification using the AUTOMDL procedure from X-13ARIMA-SEATS [Staff, 2013] as well as using (seasonal) unit root tests to identify the order of (seasonal) differencing and then using the Bayesian information criteria (BIC) to select the best model. None of the procedures used produced identical results, nor did any procedure do unambiguously better than any other. The auto.arima function was the most computationally performant and is thus the basis for the results below. We used the default arguments for this function.

> 6This model is sometimes referred to as a regression model with ARMA errors. Ignoring seasonality, it may be written

This is to contrast it with the ARMAX model which is written 17
_φ_ ( _L_ )<sup>_p_</sup> _φ_ 12( _L_<sup>12</sup> )<sup>_P_</sup> (1 _− L_ )<sup>_d_</sup> (1 _− L_<sup>12</sup> )<sup>_D_</sup> ( _yt − β_<sup>_′_</sup> _xt_ ) = _θ_ ( _L_ )<sup>_q_</sup> _θ_ 12( _L_<sup>12</sup> )<sup>_Q_</sup> _εt_ (9) where everything is as in (6) and _xt_ contains the Google Trends Index that we describe in the next section. The addition of this term allows us to model the information contained in the Google Trends data as a time-varying mean.

# **4.3 Index Construction**

In order to incorporate the information from the various Google Trends search keywords, it is desirable to synthesize the information in all of the Google Trends data into something more manageable. Formerly, authors used the Google Insights search categories data. This data is used in many of the studies referenced in section 2. However, previously such an index from Google Insights was usually not available outside of large, developed countries, so studies such as Carri`ere-Swallow and Labb ́e [2013] estimate their own. The advantage of having an index is mainly parsimony of information. Indeed, such an index may be of interest in its own right. Furthermore, in September 2012 Google merged some features of Google Insights with Trends and discontinued the aggregate search categories entirely.<sup>7</sup> To solve the keyword aggregation problem Carri`ere-Swallow and Labb ́e [2013] creates an index from multiple search terms by use of an expanding linear regression model described below. Other approaches rely on factor analysis techniques for dimension reduction such as unweighted least squares [Vosen and Schmidt, 2011] or principal components analysis [Stock and Watson, 2002]. These methods assume that there are some underlying, unobserved common factors for all of the series. We describe our use of statistical learning techniques for variable selection below.

We took several approaches to constructing our search indices. First, we applied the linear index approach of Carri`ere-Swallow and Labb ́e [2013]. This is a common approach in the literature and is an attractive choice mainly for its simplicity. Let **_X_** be our matrix of year-over-year percent changes for the Google Trends terms. We construct an index _It_ for these terms, for each series _yt_ that we wish to forecast in the following way. In each period, we estimate the weights _β_<sup>ˆ</sup> by using the observations up to time _t −_ 1 and fitting a linear model

> 7 `http://insidesearch.blogspot.com/2012/09/insights-into-what-world-is-searching. html` One may only speculate that it was discontinued because this task is very difficult to automate.

18
The index for period _t_ is Given that _y_ and **_X_** contain monthly percent changes, we can interpret _It_ as the linear combination of search terms which best explains the series that we are forecasting, in a linear least squares sense. The expanding nature of the construction of the index allows for the factors in the trends that explain the changes in our price series to change over time. This is certainly something we might be interested in given the heterogenous character of the included terms. Figure 7 contains an example of an index created using the expanding linear OLS. That is, this is the last out-of-sample fitted value of each index created for a single price series.

We anticipate two potential problems with this approach for the current exercise, and we construct this linear index using two other methods from the statistical learning literature. Both of these techniques were implemented using the scikit-learn Python package [Pedregosa et al., 2011]. First, we have a high number of variables relative to the number of observations, especially in the early years of the index. To improve the degrees of freedom of our fit, we are interested in obtaining sparse models. To this end, we applied the lasso technique introduced in Tibshirani [1996].<sup>8</sup> The lasso is a penalized least squares method that allows both continuous shrinkage and variable selection through the imposition of an _L_ 1 _−_ penalty on the regression coefficients _β_ . That is, the coefficients are pushed both towards and to zero when appropriate. The optimization function for the lasso is where _α_ is chosen via _K−_ folds cross-validation with _K_ = 5 and the _LP −_ norm is defined _∥X∥p_ =<sup>�</sup><sup>_n_</sup> _i_ =1<sup>(</sup><sup>_|xi|p_)1</sup><sup>_/p_.Figure8containsanexampleofanindexcreatedusing</sup> the expanding lasso linear model. The fit is much more conservative than the linear OLS fit given the sparse nature of the solution.

> 8We also considered the more general LARS estimator introduced by Efron et al. [2004]. The results of this estimator were comparable, though slightly worse than the lasso. It should also be noted that we ran the computationally efficient LARS algorithm variant for the lasso solution path.

19
# **OLS Index: CPI in Costa Rica**

<!-- Start of picture text --> 4<br>cpi<br>Linear GT Index<br>3<br>2<br>1<br>0<br>1<br>2<br>2006 2007 2008 2009 2010 2011 2012 2013<br><!-- End of picture text --> Figure 7: Linear OLS index created for CPI series from Costa Rica. Displays some evidence of overfitting.

20
# **Lasso Index: CPI in Costa Rica**

<!-- Start of picture text --> 2.5<br>cpi<br>LASSO GT Index<br>2.0<br>1.5<br>1.0<br>0.5<br>0.0<br>0.5<br>1.0<br>2006 2007 2008 2009 2010 2011 2012 2013<br><!-- End of picture text --> Figure 8: Lasso model index created for CPI series from Costa Rica. Conservative fit. Does not vary much.

21
Both Zou and Hastie [2005] and Tibshirani [1996] point out that the lasso may not perform well empirically in the cases where the number of variables is higher than the number of observations<sup>9</sup> , there are groups of variables with high pairwise correlation, or there are high correlations between all predictors. These are all possible concerns for our keywords from Google Trends. To account for these issues, we employ the elastic net estimator of Zou and Hastie [2005].

The elastic net estimator is a linear combination of the _L_ 1 _−_ penalty of the lasso and the _L_ 2 _−_ penalty of ridge regression [Hoerl and Kennard, 1970]. The objective function of the elastic net is where _α_ and _ρ_ are chosen via K-folds cross-validation with _K_ = 5. Using both the lasso and the elastic net, we compute the index in the same way as the linear OLS index except that the _β_ coefficients are obtained from the two new estimators. Figure 9 contains an example of an index created using the expanding elastic net model. The fit is somewhere between the high variance OLS model and the conservative lasso model. In the following section we describe the empirical results of using these indices.

# **5 Forecasting Results**

Our hypothesis is that there is additional information in our transformations of the Google Trends data that allows improved nowcasts of the series of interest before their respective data releases have been made versus an ARMA model and our respective benchmarks. To test this hypothesis we compute one-step ahead forecasts using (6) and (9) and compare them to the chosen models from (5). Just like for the benchmarks, we start with two years of monthly data and then estimating expanding window models until time _T −_ 1 where _T_ is the last period for which we have data for the series we wish to forecast and for which we have _T_ Google Trends index values. At each time _t_ in _t_ = 24 _. . . T_ + 1 we recompute the order of the seasonal ARIMA(X) model as described above. This is to emulate what a practitioner would do in any given period. For each forecast (and nowcast) we compute the one-step ahead forecast error

> 9This is not the case in the current analysis, though we do have the case where the number of variables is only slightly smaller than the number of observations in the early periods of our index construction

22
# **Elastic net Index: CPI in Costa Rica**

<!-- Start of picture text --> 2.5<br>cpi<br>ElasticNet GT Index<br>2.0<br>1.5<br>1.0<br>0.5<br>0.0<br>0.5<br>1.0<br>2006 2007 2008 2009 2010 2011 2012 2013<br><!-- End of picture text --> Figure 9: Elastic net model index created for CPI series from Costa Rica. Somewhere in between high variance OLS and low variance lasso.

23
_e_ ˆ _k,t_ +1 _≡ yk,t_ +1 _−_ E _t_ [ˆ _yk,t_ +1] (10) for model _k_ . We compute the relative MSE for each series combination method defined in section 4.3. That is, for the original data _Xi,j,t_ we computed the results for each of reduction methods of the _i_ sampling dimension – mean, median, applying the CF – filter after taking the mean, and ETS smoothing after taking the mean and for each _i_ – reduction we also computed the three linear indices over the _j_ keywords linear OLS, lasso, and elastic net. We found first that the linear OLS trend preformed unambiguously the worst. We were we unable to beat both the benchmark model and the ARMA model even once regardless of the smoothing technique that we applied. This is not wholly suprising given that we did not apply any variable selection of the keywords beforehand. Inclusion of inappropriate keywords appears to have led to overfitting and poor out of sample performance.

Moving to the lasso and the elastic net, for each respective estimator the ETS smoothed results performed best. Between the classifiers, the elastic net performed marginally better, beating both the benchmarks and the ARMA models in a few more cases. Again, this is not wholly surprising given the documented better empirical performance of the elastic net estimator when there is high pairwise correlations among the regressors. Due to the large number of results, Table 3 contains only the results of the ETS smoothed data and the trend computed via the elastic net estimator.

Using our best performing method, the ARMAX model outperforms the benchmark in 28% of the cases or for 16 out of the 58 series. In each of these cases, the ARMAX also outperforms the ARIMA model. The ARMA model fairs only slightly better versus the benchmark, outperforming the benchmark in 22% of the series or for 13 out of 58 series. However, the ARIMA model is only the best model versus the ARIMAX model in 7 of these cases. The food price series appear to be particularly difficult to forecast. If we consider only the consumer price series, then the ARMAX model is the best model in 24% of the cases while the ARMA model is only the best in 14% of the cases. The difficulty in forecasting food prices is likely due to the food price crisis during the period. The price US dollar price fluctuations during the time under consideration were due largely to events external to the countries of Central America.

These results, though only partially successful, indicate that there may be some benefit to exploring the further use of Google Trends data in forecasting economic series in Central America. We use the concluding section to speculate on some of the reasons for this success or lack thereof and give suggestions for future research.

24
25
Table 3: The results for each series using the ETS smoothed data and the elastic net estimator. Relative MSE (1) is the MSE for the expanding window ARMA model results versus the benchmark model given in columns 6. Relative MSE (2) is the MSE for the elastic net model versus the benchmark in column 6. A relative MSE less than 1 indicates that the proposed model beat the benchmark.

|Country|Series|Relative MSE (1)<br>Relative|MSE (2)|N|Benchmark|
|---|---|---|---|---|---|
|cr|food01|1.04644|1.09103|94|ar|
|cr|food02|1.00313|1.09517|94|median|
|cr|food03|1.08606|0.977452|94|mean|
|cr|food04|1.0755|1.06406|94|median|
|cr|food05|1.32068|1.32068|38|median|
|cr|food06|1.01586|1.04028|94|ar|
|cr|food07|1.08315|1.1684|94|mean|
|cr|food08|1.08143|1.17251|94|mean|
|cr|food09|0.886634|1.20473|57|median|
|cr|inf01|0.980986|1.09914|94|ar|
|cr|inf02|1|1.00755|63|mean|
|cr|inf03|0.993006|2.13919|63|median|
|cr|inf04|1.08064|1.08917|63|mean|
|cr|inf05|0.981035|1.11166|95|ets|
|cr|inf06|0.840378|0.808711|63|ar|
|cr|inf07|1.03188|1.00261|63|ar|
|cr|inf08|1.03867|0.860798|63|ar|
|cr|inf09|1.0767|1.01002|63|median|
|cr|inf10|1.11333|1.23137|63|ets|
|cr|inf11|1.10306|1.15871|63|median|
|cr|inf12|1.17467|1.18608|63|ets|
|cr|inf13|1.14892|1.35561|63|ets|
|cr|inf14|1.0491|1.04081|63|ar|
|hn|food01|1.11477|1.23652|94|median|
|hn|food02|1.06082|1.02454|94|mean|

Continued on next page 26
Table 3: The results for each series using the ETS smoothed data and the elastic net estimator. Relative MSE (1) is the MSE for the expanding window ARMA model results versus the benchmark model given in columns 6. Relative MSE (2) is the MSE for the elastic net model versus the benchmark in column 6. A relative MSE less than 1 indicates that the proposed model beat the benchmark.

|Country|Series|Relative MSE (1)<br>Relative|MSE (2)|N|Benchmark|
|---|---|---|---|---|---|
|hn|food03|1.02453|1.22845|56|ar|
|hn|food04|1.05794|1.02891|56|ar|
|hn|food05|1.50041|1.41338|56|median|
|hn|food06|1.06789|1.34548|56|ar|
|hn|food07|1.02272|1.19456|56|ar|
|hn|food08|1.02289|1.02308|56|ar|
|hn|inf01|1.14475|1.07673|94|ar|
|hn|inf02|0.954699|1.13202|94|ar|
|sv|food01|1.32029|1.34929|69|ar|
|sv|food02|0.981255|1.17397|69|ar|
|sv|food03|0.999156|1.4412|69|ar|
|sv|food04|1.00938|1.37656|69|ar|
|sv|food05|1.0587|1.22251|69|median|
|sv|food06|1.01563|1.2812|69|ar|
|sv|food07|1.14023|1.42201|69|median|
|sv|food08|1.26369|1.31265|69|median|
|sv|food09|1.08291|1.07086|69|median|
|sv|food10|1.05501|1.22104|69|ar|
|sv|food11|1|0.998684|69|median|
|sv|food12|1.24149|1.24152|69|median|
|sv|inf01|1.44499|1.33092|34|median|
|sv|inf02|0.986749|0.834845|34|ar|
|sv|inf03|1.10362|1.51751|34|median|
|sv|inf04|0.97742|0.97742|34|median|
|sv|inf05|1.11776|1.15664|34|ar|
|sv|inf06|1|0.999088|34|mean|
||Conti|nued on next page||||

27
Table 3: The results for each series using the ETS smoothed data and the elastic net estimator. Relative MSE (1) is the MSE for the expanding window ARMA model results versus the benchmark model given in columns 6. Relative MSE (2) is the MSE for the elastic net model versus the benchmark in column 6. A relative MSE less than 1 indicates that the proposed model beat the benchmark.

|Country|Series|Relative MSE (1)|Relative MSE (2)|N|Benchmark|
|---|---|---|---|---|---|
|sv|inf07|1.29662|0.986124|34|ar|
|sv|inf08|0.948536|0.948536|34|median|
|sv|inf09|1.0029|1.00293|34|mean|
|sv|inf10|1.00788|1.13624|34|mean|
|sv|inf11|1.18043|1.03241|34|mean|
|sv|inf12|1.03771|1.01186|34|median|
|sv|inf13|1.04429|1.29648|34|mean|

28
# **6 Conclusion**

In this paper, we studied the possibility of using Internet search keyword data to nowcast price changes in Central America. We gathered price data for Costa Rica, El Salvador, and Honduras. We also identified several search keywords and downloaded data for them from Google Trends over a period of weeks. We tried several aggregation, smoothing, and linear index construction methods for this Internet search data and were partially successful in improving nowcasts for Costa Rica and for El Salvador, countries for which the search data were of higher quality.

As part of the exercise, we were able to identify several important points for practictioners who wish to forecast using high-dimensional Internet search keyword time series. First, variable selection is of upmost importance. Many, if not most, of the successful forecasting studies that use Internet search keyword data are based on some theory of consumer behavior. This may be the idea that consumers use the Internet to do research before the purchase of a consumer durable as in Carri`ere-Swallow and Labb ́e [2013] or searches for jobs and unemployment and welfare as in Choi and Varian [2009]. In the absence of a strong model of consumer behavior, one should incorporate some kind of variable selection mechanism. Naively including a large number of search keyword terms into a model for a search index with the hope that the coefficients on unimportant terms will be small leads to very poor results. However, by employing some variable selection methods from the statistical learning literature we were able to substantially improve all of our forecasts and beat both the ARMA models and benchmarks in several instances.

The second takeaway is the importance of order identification in ARIMA modeling. This is perhaps not a surprise for any forecaster, but the successful results here using automatic techniques are encouraging. If a forecaster were to focus on fewer series and apply the Box-Jenkins methodology rather than relying on automatic model selection procedures it might be possible to outperform the benchmark models further.

Finally, this study suggests several avenues for further research. We might consider more estimators such as the TS-LARS, which is LARS estimator explicitly written with time-series data in mind [Gelper and Croux, 2008]. It allows selection of distributed lags and ranking of predictors. Ranking of predictors will be of particular interest for those who use an exercise such as the one in this paper to generate ideas about consumer behavior and the search for keywords and categories that help forecast price changes. One might also explore using dynamic linear models or a structural model where the Internet search information stands in explicitly for some aspect of the theoretical model. There are also a number of different smoothing techniques and variable selection methods 29
that might be explored.

In conclusion, the study of the manifestation of consumer sentiment via Internet search behavior is very much still in its infancy. It certainly presents a number of challenges, but the potential insights and use cases are varied and exciting. It may be tempting to dismiss this excitement as hype. All the same, it is difficult to deny the possible benefits of real-time consumer sentiment to future economics research and forecasting studies.

30