## Figures

## Abstract

Data from the social-media site, Twitter, is used to study the fluctuations in tweet rates of brand names. The tweet rates are the result of a strongly correlated user behavior, which leads to bursty collective dynamics with a characteristic 1/f noise. Here we use the aggregated "user interest" in a brand name to model collective human dynamics by a stochastic differential equation with multiplicative noise. The model is supported by a detailed analysis of the tweet rate fluctuations and it reproduces both the exact bursty dynamics found in the data and the 1/f noise.

**Citation: **Mollgaard A, Mathiesen J (2015) Emergent User Behavior on Twitter Modelled by a Stochastic Differential Equation. PLoS ONE 10(5):
e0123876.
https://doi.org/10.1371/journal.pone.0123876

**Academic Editor: **Tobias Preis,
University of Warwick, UNITED KINGDOM

**Received: **August 19, 2014; **Accepted: **March 5, 2015; **Published: ** May 8, 2015

**Copyright: ** © 2015 Mollgaard, Mathiesen. This is an open access article distributed under the terms of the Creative Commons Attribution License, which permits unrestricted use, distribution, and reproduction in any medium, provided the original author and source are credited

**Data Availability: **Data is included in the Supporting Information files.

**Funding: **The study received funding through the UCPH 2016 Excellence Programme for Interdisciplinary Research. The funders had no role in study design, data collection and analysis, decision to publish, or preparation of the manuscript.

**Competing interests: ** The authors have declared that no competing interests exist.

## Introduction

In the online era, humans are connected in real time on global scales. Local or seemingly local information is instantaneously shared across geographical boundaries. In particular, social online media have become an important platform for the sharing of information and have allowed for detailed studies of the coherent behavior of humans on a global scale [1–6]. The popular microblogging platform Twitter is a good source for such studies for two reasons. First, Twitter is more about providing news updates than developing social networks [7, 8]. User behavior is therefore to a large extent influenced by information available via other information channels in society. Secondly, users respond to available information by submitting short public messages, “tweets”, of up to 140 characters that may be seen as proxies for the public interest. Recent research on Twitter has used the activity levels in forecasting real-world events including fluctuations of stock market prices [9], real-time detection of the location and spread of earthquakes hitting populated areas [10], and for sentiment analysis and opinion mining [11].

In a recent paper [4], fluctuations in the tweet rates of 92 brand names are shown to be distributed with a power law tail with an exponent of −2.9±0.4(SD). The broad tail of the distribution is characteristic for bursty activity levels. It is moreover found that the power spectral density of the tweet rate signals are described by a power law with an exponent of −1.0±0.4(SD). This so called, “1/f noise”, is found in a range of complex systems including heartbeats [12], DNA base sequences [13] and condensed matter systems [14], and it is interpreted as a sign of a pronounced memory in the systems [15]. We attribute the power spectral density and the broad distribution in the tweet rate fluctuations to a strong correlation on a global scale in the collective human dynamics.

In this paper we consider the global user interest in a brand, which in our definition is the likelihood for a tweet to mention the brand name. The global interest in a topic is expected to change in a continuous and random fashion as the result of many independent events in society. We shall therefore describe the global user interest by a stochastic differential equation (SDE), which we derive by analyzing the fluctuations in the tweet rate. The SDE predicts simultaneously the power law exponents of the tweet rate distribution and the strong memory in the temporal variation of the tweet rates.

The paper is organized as follows, first we briefly describe the data acquired from Twitter and explain how the data is turned into a tweet rate. Then we introduce a method for analyzing the fluctuations in the tweet rate and demonstrate how it works on a generic signal. Our method is applied to data and supports an SDE with multiplicative noise. Finally, we show that the noise term in the SDE reproduces the power law distribution of the tweet rate as well as the power spectral density of the temporal signal.

## Methods

### Data collection and time signals

We used the public REST API by Twitter to collect tweets containing one of seven brand names during a time period in the fall 2012 and the spring 2014 (see Supporting Information sections S1 Supporting Information and S2 Supporting Information for data and a description of time periods). The brand names considered are “Samsung”, “Pepsi”, “Heineken”, “Gucci”, “Starbucks”, “BMW”, and “Google”. In the analysis, we chose to use international brand names for a number of reasons. First, the brand names are used globally and the users posting tweets about the brands in general transcend local communities. Secondly, the brands are sufficiently popular that a continuous and robust stream of tweets exists.

From the tweets collected, we save the time *t*_{i} where a tweet is posted. The index *i* refers to the identification number of a given tweet. From the individual tweets, we form a time signal by summing over all tweets mentioning a given brand,
where *δ*(*t*−*t*_{i}) is the Dirac delta function. The time signal is turned into a tweet rate, *x*(*t*), by dividing the time axis into windows of length, Δ*T*, and summing the events in each window,
(1)
A plot of tweet rate signals is shown for a few brands in Fig 1, where both a regular daily variation and an irregular bursty behavior on top are distinctly visible. Burstiness is known to be inherent to individual human dynamics [16] and to have an impact on information spreading [17]. Here we see that bursts also appear in the aggregated interest level of many users in a large-scale social organization.

We show the number of tweets measured in a time window, Δ*T* = 10min, for a few brands. Note the regular daily variation and the irregular bursty behavior.

### The algorithm

We now introduce a method to uncover the underlying stochastic properties of a time signal [18]. The method is based on the assumption that a signal, *γ*(*t*), is generated by a stochastic differential equation (SDE) on the form
(2)

Here *dW* is a random Gaussian variable with mean, ⟨*dW*⟩ = 0, and variance, ⟨*dW*^{2}⟩ = *dt*. The first term in Eq (2) gives the deterministic drift, while the second term gives the random diffusion. The differential equation will here be handled using Ito calculus. Note that the above equation is assumed to describe the dynamics of the global user interest and not the observed tweet rates given in Eq (1). Below we shall relate the two quantities.

It may be shown in the Fokker-Planck formalism [19] that if the variable takes the value, *γ*_{0}, at time, *t*, then at some small time step, *dt*, later, it will be a random variable from a Gaussian distribution with mean, *γ*_{0}+*f*(*γ*_{0})*dt*, and spread, *g*(*γ*_{0})*dt*^{1/2} (see Fig 2). It is therefore possible to get an estimate of *f*(*γ*_{0}) and *g*(*γ*_{0}) by binning all the signal values close to *γ*_{0} and then construct the corresponding distribution of signal values one time step later. From this distribution one may read off the mean and the spread to get the estimates of *f*(*γ*_{0}) and *g*(*γ*_{0}). The procedure is then repeated over the whole range of realized signal values in order to estimate the functional forms of *f*(*γ*) and *g*(*γ*), respectively.

If the signal at some point takes the value *γ*_{0}, then a small time step, *dt*, later, its value will be realized from a Gaussian with a mean determined by *f*(*γ*_{0}) and a spread determined by *g*(*γ*_{0}). By performing statistics over many such realizations we may therefore obtain the drift and diffusion.

In Fig 3 we show the result of applying the analysis to a signal generated by
(3)
Comparing the analytical functions with the estimates, we get *R*^{2}-values of 0.98 and 0.97 for the drift and diffusion respectively. The functional form of the drift and diffusion used here are equivalent to the ones fitted for “Samsung” below, and to make the comparison complete, we have also used the same signal length, *N* = 74,646, and time step, *dt* = 1. Note that bins with less than 20 data points have not been included, due to the otherwise poor statistics, and therefore *γ* only assumes values between 0.26 and 2.35.

A time series generated according to Eq (3) is shown in (A) and below we show the analytic drift, (B), and diffusion, (C), along with the functional forms estimated by the algorithm.

## Results

### Model

The stochastic differential equation, Eq (2) is formulated in the probability, *γ*(*t*), for a random tweet to mention a specific brand and not in the tweet rate. We call *γ*(*t*) for the “global user interest”. In fact, the expected number of tweets on a given topic, ⟨*x*(*t*)⟩_{P}, in a time window, Δ*t*, is given by the full number of tweets posted on Twitter within this time window, *A*(*t*), times the probability for any such tweet to mention the given topic *γ*(*t*),
(4)
Here the expectation value, ⟨⋅⟩_{P}, refers to the Poisson weighted average of all the possible realizations of the tweet rate. The actual tweet rate signal is one such realization drawn from a Poisson distribution
(5)
The above equation summarizes the basic structure of our model: the observed signal, *x*(*t*), is realized from a Poissonian with a mean given by the product between the user interest, *γ*(*t*), and the activity, *A*(*t*).

Within the activity, *A*(*t*), we also include any factors depending on regional differences, since the global composition of active users is changing during a daily cycle. We will assume that *A*(*t*) may be approximated as a deterministic and periodic function of time and that *γ*(*t*) is reasonably described by the SDE in Eq (2). The goal of the following data analysis is to find the functional form of the drift, *f*(*γ*), and diffusion, *g*(*γ*), of the SDE.

### Data analysis

It is problematic to apply the algorithm introduced in the methods section to the tweet rate signals, *x*(*t*), since we only expect it to apply to the underlying tweet probability, *γ*(*t*). We may reduce noise from the Poisson statistics by increasing the time window, Δ*t*, thereby increasing the expected number of tweets and reducing the relative size of the Poisson noise. However, if we increase the time window too much, then we enter the domain of the mean field theory, where the time resolution is too low to see the dynamics of the *γ*(*t*)-fluctuations since they for larger times are dampened by the drift term. Also, for a limited time series we do not want to lower the time resolution, since it reduces the number of data points available for the analysis. In the following, we have chosen a time window of 30 seconds giving us approximately 80,000 data points for each brand. Unfortunately, this window size does not allow us to ignore the Poisson noise for any of the brands. We do however expect the time window to be small enough to resolve the important dynamics of the user interest.

The second problem that we face by applying the algorithm is the presence of the activity, *A*(*t*), relating the observed signal, *x*(*t*), to the signal of interest, *γ*(*t*). In the following analysis we will assume that the activity is a deterministic function of time with a daily period. One would naturally expect it to also have a weekly variation along with a variation on slower time scales, but here we will be interested in time scales below the resolution of a day, why it makes sense to approximate the activity by a daily period.

We may estimate the daily variation by averaging *x*(*t*) over many days to obtain a variable that is proportional to the activity
(6)
Here we introduced two more expectation values: ⟨⋅⟩_{D} is the average of repeated measurements at the same time of day and ⟨⋅⟩_{T} is the general time average. We have used that Poissonians sum to a Poissonian with an expectation value that is the sum of the individual expectation values. We have also used that *A*(*t*) and *γ*(*t*) are uncorrelated in our model, that *γ*(*t*) is independent of absolute time and that *A*(*t*) is a periodic function. In practice, the average is performed over 20 to 62 days of measurements and by smoothening data to a time resolution of 15 minutes. Using the obtained information, we may construct the variable
(7)
which is proportional to *γ*(*t*) if one averages out the Poisson noise
(8)

The variable $\tilde{\gamma}(t)$ is the closest approximation we get of *γ*(*t*) by our analysis. To see the effect of the Poisson statistics on our analysis, we have also generated the signal
(9)
and applied the algorithm to both $\tilde{\gamma}(t)$ and $\tilde{x}(t)$. The variable $\tilde{x}(t)$ is equivalent to $\tilde{\gamma}(t)$, but with the dynamics of *γ*(*t*) replaced by the mean value ⟨*γ*⟩_{T} (compare Eqs (7) and (8)). By applying the algorithm to both $\tilde{\gamma}(t)$ and $\tilde{x}(t)$, we hope to be able to separate the effect of the daily variation and the Poisson statistics from the actual dynamics of *γ*(*t*).

In Fig 4A we show $\tilde{\gamma}(t)$ and the corresponding instance of $\tilde{x}(t)$ for “Samsung”. Note that the Poisson noise of $\tilde{x}(t)$ is not enough to explain the bursty behavior observed for the tweet rates. The resulting drift (Fig 4B) and diffusion (Fig 4C) terms are estimated using our algorithm on the two signals shown below. The drift of $\tilde{\gamma}(t)$ has been fitted with a function on the form
(10)
A best fit yields the coefficients *a*_{f} = 0.47 and *b*_{f} = 0.43. Similarly, the diffusion has been fitted using a function on the form
(11)
with *a*_{g} = 0.31 and *b*_{g} = 0.23. The analysis has been performed in dimensionless time, *t* → *t*/Δ*t*, such that *dt* = 1. We have been unable to estimate the error bars in the presence of the Poisson statistics.

The two signals are shown in A and below we see the drift terms, B, and diffusion terms, C, estimated by the algorithm. Also shown are the fits of the functions in Eqs (10) and (11) to the estimated drift and diffusion of $\tilde{\gamma}(t)$.

Our algorithm estimates a linear drift term for both the data, $\tilde{\gamma}(t)$, and for the synthetic signal, $\tilde{x}(t)$. For $\tilde{x}(t)$, we find a coefficient *b*_{f} = 1, which is expected from a Poisson process. The fact that we find *b*_{f} = 0.43 for $\tilde{\gamma}(t)$ shows that the data is more rich than a simple homogeneous or a weakly inhomogeneous Poisson process. In other words, the fluctuations of *γ*(*t*) are comparable or stronger than the fluctuations generated by the superimposed Poisson process. While we cannot quantify the influence of the Poisson process on the linear drift, we are confident that $\tilde{\gamma}$ = 1 is the only stationary point of $\tilde{\gamma}$, corresponding to a potential, *V*(*γ*) = ∫_{γ} *f*(*γ*′)*dγ*′, with just a single minimum. Furthermore, we do not expect the drift to depart significantly from a linear form around and above the fix point. A drift term of this form limits the signal and allows bursts to be generated by the multiplicative diffusion term.

In the plot showing the diffusion terms, we find that the effect of the Poisson statistics is very distinctly visible as a constant background noise. It indeed matches the size of the coefficient *a*_{g} pretty well. We therefore propose that the this first term is due Poisson noise and therefore that the underlying variable *γ*(*t*) is described solely by the second term, *g*(*γ*) = *bγ*^{3/2}.

We apply the same analysis to the other brand names and provide in Table 1 the length of the fitted data series, *N*_{data}, the mean tweet rate, ⟨*x*⟩, the ratio between the maximum and minimum of the daily variation, DV ≡ max[⟨*x*⟩_{D}(*t*)]/min[⟨*x*⟩_{D}(*t*)], and the goodness-of-fit values for the diffusion term, *R*^{2}. We find that the fit captures the observed diffusion well for 4 of the 7 brand names, but it performs poorly for the last 3. We believe that this is the result of applying the algorithm to a limited time series under the effects of daily variation and Poisson noise. As an example of this, we show in Fig 5 the result of applying the algorithm to the tweet rate signal of “Starbucks”. We see that a Poisson process captures most of the fluctuations found in the dynamical signal, i.e. the diffusion terms of $\tilde{\gamma}$ and $\tilde{x}$ are approximately equal. We therefore conclude that the average interest, ⟨*γ*⟩, the big daily variation, *A*(*t*), and the Poisson noise is enough to explain most of the signal for “Starbucks”. This leaves very little room in the analysis to capture the dynamics of *γ*(*t*) (compare with Fig 4) and may explain the poor performance of the fit.

Note that the diffusion estimated for the two signals is almost equal for this brand name, therefore making it hard to filter out the effect of the dynamical interest *γ*(*t*) present in the signal of $\tilde{\gamma}(t)$.

In general, however, we find that the analysis of $\tilde{\gamma}(t)$ provides support to the hypothesized noise exponent of 3/2. We therefore propose that the global user interest is described by the following model
(12)
where *f*(*γ*) is a slowly decreasing drift term derived from a single well potential. We emphasize that in order to derive this result, we assume that *γ*(*t*) is described by the stochastic differential equation, Eq (2), and that *A*(*t*) can be approximated by a periodic function with a daily period. Finally, our method works best when the Poisson fluctuations are not too strong.

In the next section we show that if the single well potential defining *f*(*γ*) is approximated by an infinite well, we obtain a probability distribution with a power law exponent of -3 and a power spectrum with a power law exponent of -1. This is in agreement with the characteristic behavior of the brand name signals analyzed in [4].

## Distribution and power spectrum from model

To derive the probability distribution and power spectrum for the model proposed in Eq (12) we switch from the Langevin equation to the corresponding Fokker-Planck formulation
(13)
Here we have approximated the drift potential by an infinite well. This yields a vanishing drift in the region *γ* ∈ [*γ*_{min}, *γ*_{max}] and reflective boundaries at the effective potential walls *γ*_{min} and *γ*_{max}. One finds the stationary distribution
(14)
where *N* is the normalization constant. The same asymptotic power law is found in the case of a linear drift, which is promising since it matches the behavior of the data.

Eq (13) may be solved using the method of eigenfunctions as explained in [20]. One finds that for an intermediate range of frequencies the power spectrum scales as (15) which is also the case for the data.

The model proposed for the dynamics of interest, Eq (12), is therefore successful at simultaneously explaining the scaling exponents of the signal distribution and the corresponding power spectrum. To show the validity of the infinite well approximation, we conclude the paper with a simulation of the model with a linear drift
(16)
An efficient and accurate numerical integration may be performed by considering the inverse variable, *τ* = 1/*γ*, which may be integrated using the splitting up method [21]. In Fig 6 we show the distribution and power spectrum for the simulated signal, and we observe that the linear drift is consistent with the power laws observed in the data. The exponent of the distribution is fitted to *α*_{1} = −2.961±0.002 using the maximum likelihood routine introduced in [5]. The exponent of the power spectrum is found to be *α*_{2} = −0.98±0.03 using a logarithmic binning and a least squares fit. The corresponding errorbars are estimated by bootstrapping.

Note that the power law exponents of -1 and -3 match those of the data.

## Conclusion

In this paper we have studied the dynamics of interest in global brands by analyzing tweet rates on the online social media site Twitter. As a result of the correlations in the user behavior, the rates are found to be bursty and distributed as a power law with an exponent of -3 and have a power spectrum inversely proportional to the frequency. Since the global interest in a brand name is the result of many random events, we have proposed to model it by a stochastic differential equation with a simple drift and a diffusion like term. By analyzing the fluctuations in the tweet rate signals, we find that the diffusion term scales like a power with an exponent of 3/2. The derived diffusion term may explain the pronounced burstiness and the 1/f noise observed for the tweet rate signals.

It remains an open question whether the dynamics observed for the brand names on Twitter can also be observed for the occurrence of other keywords or even in other large social organizations? Another interesting question, which we have not addressed with our model is, what is the detailed behavior of individual humans that leads to correlated behavior given by our model? In general, the growing information available on human behavior in global-scale social organizations has helped answer parts of these questions and further analysis along the lines of this paper might provide a more complete picture.

## Supporting Information

### S1 Supporting Information. Information on the data collection.

https://doi.org/10.1371/journal.pone.0123876.s001

(PDF)

### S2 Supporting Information. Timestamp data for tweets.

https://doi.org/10.1371/journal.pone.0123876.s002

(GZ)

## Author Contributions

Conceived and designed the experiments: AM JM. Performed the experiments: AM JM. Analyzed the data: AM JM. Contributed reagents/materials/analysis tools: AM JM. Wrote the paper: AM JM.

## References

- 1. King G. Ensuring the data-rich future of the social sciences. Science(Washington). 2011;331(6018):719–721.
- 2.
Osborne M, Dredze M. Facebook, Twitter and Google Plus for Breaking News: Is There a Winner? In: Proceedings of the International Conference on Weblogs and Social Media; 2014.
- 3. Hermida A, Lewis SC, Zamith R. Sourcing the Arab Spring: A case study of Andy Carvinś sources on Twitter during the Tunisian and Egyptian Revolutions. Journal of Computer-Mediated Communication. 2014;19(3):479–499.
- 4. Mathiesen J, Angheluta L, Ahlgren PT, Jensen MH. Excitable human dynamics driven by extrinsic events in massive communities. Proceedings of the National Academy of Sciences. 2013;110(43):17259–17262.
- 5. Alstott J, Bullmore E, Plenz D. powerlaw: a Python package for analysis of heavy-tailed distributions. PloS one. 2014;9(1):e85777. pmid:24489671
- 6. Garas A, Garcia D, Skowron M, Schweitzer F. Emotional persistence in online chatting communities. Scientific Reports. 2012;2. pmid:22577512
- 7.
Kwak H, Lee C, Park H, Moon S. What is Twitter, a social network or a news media? In: Proceedings of the 19th international conference on World wide web. ACM; 2010. p. 591–600.
- 8.
Myers SA, Sharma A, Gupta P, Lin J. Information network or social network?: the structure of the twitter follow graph. In: Proceedings of the companion publication of the 23rd international conference on World wide web companion. International World Wide Web Conferences Steering Committee; 2014. p. 493–498.
- 9.
Sakaki T, Okazaki M, Matsuo Y. Earthquake Shakes Twitter Users: Real-time Event Detection by Social Sensors. In: Proceedings of the 19th International Conference on World Wide Web. WWW ’10. New York, NY, USA: ACM; 2010. p. 851–860. Available from: http://doi.acm.org/10.1145/1772690.1772777.
- 10.
Bollen J, Mao H, Zeng XJ. Twitter mood predicts the stock market. CoRR. 2010;abs/1010.3003.
- 11.
Asur S, Huberman BA. Predicting the Future with Social Media. CoRR. 2010;abs/1003.5699.
- 12. Kobayashi M, Musha T. 1/f fluctuation of heartbeat period. Biomedical Engineering, IEEE Transactions on. 1982;(6):456–457.
- 13. Voss RF. Evolution of long-range fractal correlations and 1/f noise in DNA base sequences. Physical review letters. 1992;68(25):3805. pmid:10045801
- 14. Weissman M. 1/f noise and other slow, nonexponential kinetics in condensed matter. Reviews of modern physics. 1988;60(2):537.
- 15. Keshner MS. 1/f noise. Proceedings of the IEEE. 1982;70(3):212–218.
- 16. Barabasi AL. The origin of bursts and heavy tails in human dynamics. Nature. 2005;435:207. Available from: http://www.citebase.org/abstract?id = oai:arXiv.org:cond-mat/0505371. pmid:15889093
- 17. Horváth DX, Kertész J. Spreading dynamics on networks: the role of burstiness, topology and non-stationarity. New Journal of Physics. 2014;16(7):073037.
- 18. Siegert S, Friedrich R, Peinke J. Analysis of data sets of stochastic systems. Physics Letters A. 1998;243(5):275–280.
- 19.
Gardiner C. Stochastic Methods: A Handbook for the Natural and Social Sciences. Springer Series in Synergetics. Springer; 2009. Available from: http://books.google.de/books?id = otg3PQAACAAJ.
- 20. Ruseckas J, Kaulakys B. 1/f noise from nonlinear stochastic differential equations. Phys Rev E. 2010 Mar;81:031105. Available from: http://link.aps.org/doi/10.1103/PhysRevE.81.031105.
- 21. Bensoussan A, Glowinski R, Raşcanu A. Approximation of some stochastic di erential equations by the splitting up method. Applied Mathematics and Optimization. 1992;25(1):81–106.