# Using Epidemiological Models to Predict the Spread of Information on Twitter
## 3 Data Acquisition and Parameter Estimation  
In order to analyze the diffusion of information on social media, as a first step, we collected real data. Unlike other scientific fields, where there datasets are organized and directly available on the Web, in this case, we obtained these data from a chosen social network; in particular, we focused our work on Twitter. The motivation of this choice relies on the fact that it is possible to collect data by using tools such as the official Twitter portal called the _\"Twitter Developer Option\"_[34] and Python data scraper _\"Tweepy\"_[35]. In this way, we obtained information of different kinds about Twitter users who shared the searched news item, such as Twitter ID, mentions, Twitter username, the number of followers, etc. In particular, for the work that we describe herein, we needed the date of creation of the tweet in which we were interested and the username of the users who posted it. We analyzed the diffusion of a news item by following the trends of a \"hashtag\". Data analysis was performed by searching for news with a specific hashtag or with a specific group of keywords. This aspect can be improved, as in some cases, there are tweets with a particular hashtag whose topic is not related to the hashtag itself. After collecting data, starting from the algorithm described in [11; 12], we wrote an algorithm, which is reported as Algorithm 1, that allowed us to classify individuals as ignorants, spreaders or recovered.  
```
1:\(I\gets Ignorant\ Population\)
2:\(S\gets Spreader\ Population\)
3:\(R\gets Recovered\ Population\)
4:\(t\gets First\ Data\ of\ dataset\)
5:\(t_{end}\gets Last\ Data\ of\ dataset\)
6:\(t_{exit}\gets Time\ to\ pass\ from\ spreaders\ to\ recovered\)
7:for each user do
8:\(t_{0}\gets first\ time\ this\ user\ tweeted\)
9:\(t_{1}\gets last\ time\ this\ user\ tweeted\)
10:endfor
11: loop
12:if\(t\leq t_{0}\)then
13:\(I\gets I+1\)
14:\(t\gets t+t_{exit}\)
15: go to loop
16:\(t_{1}\leq t\leq t_{end}+t_{exit}\)then
17:\(R\gets R+1\)
18:\(t\gets t+t_{exit}\)
19:\(t\gets t+t_{exit}\)
20: go to loop
21:else
22:if\(t_{1}\leq t\leq t_{end}+t_{exit}\)then
23:\(R\gets R+1\)
24:\(t\gets t+t_{exit}\)
25: go to loop
26:else
27: close loop
28:endif
29:endif
30:endif
```  
**Algorithm 1** Constructing ISR vectors from Twitter data.  
In particular, the algorithm puts each user is in the ignorant class before the time instant (\(t_{0}\)) in which he publishes his first tweet. At this point, the user becomes part of the class of spreaders. \(t_{1}\) denotes the time instant at which the user publishes their last tweet relating to the news under consideration. The user passes into the recovered class at time instant \(t_{1}+t_{exit}\). As readers can imagine, the time required to pass from one compartmentto another (\(t_{exit}\)) depends on the news that we are following. To build the dataset, it is necessary to organize data using different transition times from the state of spreader to recovered.  
For our research purposes, \(t_{exit}\) was empirically selected through a series of tests by taking the following factors into account:  
1. News popularity: the degree of popularity or attention received by the news;
2. Time range: the duration of time taken into consideration;
3. Number of tweets posted within the selected time range;
4. The level of influence or popularity of users within the network who share the analyzed news.