In a recent statistics course, I had to research and present the fundamentals of an advanced statistic. My topic was time-series analysis, a modeling technique that analyzes a variable measured repeatedly over time and at regular intervals (Tabachnick and Fidell, 2016). It is used in contexts such as forecasting business data, studying climate change, and even in tracking behavioral events in educational contexts. A good recent example is a study by Markowitz (2018) that investigated the effect of No Child Left Behind (NCLB) on school engagement, finding that school engagement increased after NCLB but than decreased, ultimately becoming negative. This was compared to engagement in private schools, which continued to increase and saw no effect from NCLB.
To help get a handle on this statistic, I decided to play with real data: google trend data. Google trend data tracks search terms based on relative popularity of the term. I decided to track the worldwide popularity of the search term “study English in the USA” from January 2011 to the present (at the time of research, November, 2018). I decided to look at this data through the lens of interrupted time-series analysis. In interrupted time-series analysis, you are assessing the effect of an event or intervention on the time-series data. In other words, is there a correlation between the event and some major change in the trend of the data. In this case, I wanted to see of the election of Donald Trump had shifted the popularity of this search term either up or down. The purpose here was to investigate whether or not there was a Trump effect.
My hypothesis was that there would be a Trump effect, informed by the decrease in international student enrolments in universities, especially Intensive English Programs.
I am going to present my analysis below, with some key vocabulary and concepts defined. Keep in mind that my assignment was to understand the basics of time-series analysis, which is a quite complicated statistical procedure. So, the information I present below may not be accurate (for those familiar with time-series analysis, I would love your feedback!). My purpose with this blog post is just to show some fun things I did with statistics!
Identifying the Data
The entire time-series data from 2011 to 2018 is variable, with no discernible pattern or seasonality (patterns connected to calendar time), but it does seem to have a negative trend towards the end. To do interrupted time-series analysis right, I need to look at only 2011 to 2016, pre-Trump data. This will allow me to predict what happens after November, 2016 and allow comparisons to what actually was measured.
The pre-Trump time-series data also suggests a negative trend (see figure 1) which has been made stationary by one order of difference ( see figure 2). Making data stationary removes trends from the data, a necessary step for making accurate models. Differencing is a data transformation method common in time-series analysis.
Figure 1. Time-series data before differencing. Note slight negative trend.
Figure 2. Time-series data after differencing. No trend.
Now that it is stationary, I can examine the autocorrelation and partial autocorrelation functions to determine what points in the data have significant correlations and begin to estimate what ARIMA components I may need.
That is a lot of jargon to unpack. Autocorrelation functions look at correlations between observations at different time points, called lags. Autocorrelation at lag 1 is similar to the correlation between December and November. Autocorrelation at lag 5 would be December with July (5 months prior).
ARIMA is one of many different time-series modeling techniques. It is a mathematical model that consists of three components. The numbers chosen for these components create different linear equations, which are used to make predictions based on the already-observed data (the equations are similar to the linear equations used in regression). These numbers/components are chosen based on significant autocorrelations/partial autocorrelations after the time-series data is stationary.
The ARIMA components are:
- AR: autoregression - how one observation is affected by the preceding observation;
- I: integrated - the number of times your data was differenced to become stationary (in my case, 1); and
- MA: moving average, how one observation is affected by the preceding random shock (random error).
Each component (AR, I, MA) requires a different number, and the different combinations indicate different linear equations.
I based some of my component selection on David Nau’s Rule 7, “If the ACF of the differenced series displays a sharp cutoff and/or the lag-1 autocorrelation is negative-i.e., if the series appears slightly “overdifferenced”-then consider adding an MA term to the model. The lag at which the ACF cuts off is the indicated number of MA terms.”
My ACF seems to cut off at lag 1, though the increase that begins towards the end worries me and may be a sign of a random walk (a concept at the time of writing I don’t fully understand). So, I’m just going to ignore that part. So, I will estimate an MA = 1 component.
However, ARIMA parameter estimation can be considered as much art as science, so I am going to try and estimate the following models:
ARIMA(0,1,1), ARIMA(1,1,0) and ARIMA(0,1,2)
Estimating the Model
Using SPSS ARIMA (Forecasting), results indicated that ARIMA (1,1,0) and ARIMA (0,1,1) are both significant and that, while the first MA component of ARIMA (0,1,2) was significant, the second MA component was not, indicating only one MA component should be considered. Thus, I will continue with the first two ARIMA models.
ARIMA(0,1,1), ARIMA(1,1,0) and ARIMA(0,1,2) respectively
Diagnosing the Model
After estimating significant models, you are not finished. You have to make sure these models account for all patterns in the data. This requires diagnosis. Diagnosing the model is looking at residual ACF and PACF statistics and plots to determine if all patterns have been accounted for in the model. If there are significant correlations in the residuals, your model does not account for the patterns and thus it should not be used. ARIMA(1,1,0) has several significant residuals. ARIMA (0,1,1) has no significant residuals, so this is likely the best model. The equation for this model turns out to be Ŷt = Yt-1 - θ1et-1.
ARIMA(0,1,1) - No residuals are outside the confidence bands; thus, there are no significant patterns unaccounted for in the model.
ARIMA(1,1,0) - Several residuals are outside the confidence bands; thus, there may be significant patterns unaccounted for in the model.
Now, I will ask SPSS to use the ARIMA(0,1,1) model to predict the time series from November 2016 (Trump’s election) to October 2018. I can use this to compare results in the next step.
The predictions indicate a pretty consistent search popularity that seems no higher or lower than the average previous popularities of the search term. While it had spiked up and down, it always remaining consistently between 35-45.
Testing my Hypothesis
Now the fun stuff: is there a Trump effect? To test this, I dummy coded a trumpEffect variable 0 and 1, where 0 means trump was not elected and 1 means he was elected (beginning November, 2016). I can now re-run SPSS ARIMA using ARIMA (0,1,1) on the entire time series data and include trumpEffect as an independent variable.
0 indicates the times before trump was elected; 1 indicates the times after he was elected
The results indicate that the popularity of the search term decreased (by about 8), however the p value of .270 indicates this decrease was not significant (significant would be p < .05). Therefore, my conclusion is that I cannot say confidently that there has been a Trump effect on this search term.
Final Thoughts
- The data only includes 35 cases for trumpEffect = 1. This may not be enough to register a significant intervention. Time-series analysis typically requires a minimum of 50 observations. I certainly have enough for the pre-Trump data, but perhaps I need more to assess an intervention more accurately.
- If the downward trend continues, re-running this model in a year’s time may give a different result.
- It is possible I did not choose my models correctly. I ran a similar ARIMA model in SPSS using their point-and-click time-series tool (TSMODEL) which returned a different result. I believe the TSMODEL is making different calculations, but I’m not sure what that is.
- It is possible my model was correct, as were my findings. The predicted observations of my findings look like they match what actually occurred, which indicates I may have a good model after all.
- Correlation does not equal causation. This is not experimental data, so, even if a Trump effect were found, I can only suggest correlation, not causality. Statistics do not define causality, research design does. There are many confounding factors in this type of research that makes such cause-effect conclusions impossible.
- Time-series analysis is a bit mysterious, especially the ARIMA parameter identification. But it sure is fun!
Useful Resources
Adeleye, N. [CrunchEconometrix]. (2018, July 1). (EViews10): ARIMA Models (Estimation) [Video file]. Retrieved from https://www.youtube.com/watch?v=RhjqqessLqg.
Box, G. E. P., Jenkins, G. M., Reinsel, G. C., and Ljung, G. M. (2016). Time series analysis: Forecasting and control (5th ed.). New York: New York: Wiley.
Jebb, A. T., Tay, L., Wang, W., & Huang, Q. (2015). Time series analysis for psychological research: Examining and forecasting change. Frontiers in Psychology, 6, 727.
Koopmans, M. (2011). Time series in education: The analysis of daily attendance in two high schools. Paper presented at Annual Convention of the American Educational Research Association, New Orleans, LA. Retrieved from https://files.eric.ed.gov/fulltext/ED546476.pdf.
Linden, A., Adams, J. L., & Roberts, N. (2003). Evaluating disease management program effectiveness: an introduction to time-series analysis. Disease Management, 6(4), 243-255. doi: 10.1089/109350703322682559
Markowitz, A. J. (2018). Changes in school engagement as a function of No Child Left Behind: A comparative interrupted time series analysis. American Educational Research Journal, 55(4), 721-760. doi: 10.3102/0002831218755668.
Mark, M. M., Reichardt, C. S., and Sanna, L. J. (2000). Time-series designs and analyses. In Handbook of applied multivariate statistics and mathematical modeling (H. E. A. Tinsley and S. O. Brown Eds). New York, New York: Elsevier Science & Technology Books.
Marston, D. (1988). The effectiveness of special education: A time series analysis of reading performance in regular and special education settings. The Journal of Special Education, 21(4), 13-26. doi: 10.1177/002246698802100405
Nau. R. (2018). ARIMA models for time series forecasting. Retrieved from https://people.duke.edu/~rnau/411arim.htm.
Rock, S. M. (1996). Impact of the Illinois child passenger protection act: a retrospective look. Accident Analysis & Prevention, 28(4), 487-492. doi: 10.1016/S0001-4575(00)00098-1
Tabachnick, B. (2015). Not your grandma’s time-series analysis [PowerPoint Slides]. Retrieved from http://www.csun.edu/~vcpsybxt/Time%20Series%20Analysis.pdf.
Tabachnick, B. G and Fidell, L. S. (2016). Time series analysis. In Using multivariate statistics (6th ed.). New York, New York: Pearson. Retrieved from http://media.pearsoncmg.com/ab/ab_tabachnick_multistats_6/datafiles/M18_TABA9574_06_SE_C18.pdf.
The Pennsylvania State University. (2018). STAT 510: Applied time series analysis [Online course]. Retrieved from https://onlinecourses.science.psu.edu/stat510/node/33/.
Warren, A. R. (2009). Time-series analysis: assessing the effects of multiple educational interventions in a small-enrollment course. Paper presented at Physics Education Research Conference. doi: 10.1063/1.3266740.