In the past years, there has been an emerging number of studies on estimating the passen- ger demand in urban environments based on social media and cellular data. However, the study of the travel behavior at the individual level and the relation between social media activity and the activity/mobility patterns of users has received limited attention. To rec- tify this, this study examines Twitter data for unveiling the relations between geo-tagged Tweets and Twitter user sentiments, and the respective activity types performed in the real-world. In this work we try to nd common patterns between users' Twitter activity and their actual mobility/activity patterns with the aim to provide some generalizations that can help to understand and model the travel behavior of users. This is achieved with the development of educated rules and probabilistic models that can predict the mobility transfers of users between di erent activities based solely on social media data. The valid- ity of our generalizations is validated with the use of 4-month Twitter data from London. Only active Twitter users have been selected to study in deep the relations between social media activities/sentiments and the activity types performed in the real-world. Although our generalizations are case study-speci c, they demonstrate that it is possible to extract the activity and mobility behavior of users with the use of social media and o er a rst step in this direction. Keywords: Twitter; sentiment analysis; travel behavior; mobility patterns; activity-based modeling. 1. Introduction Since the 1970s the travel travel behavior of individuals is investigated using travel surveys (Maat et al. (2004), Stopher and Collins (2005)). Travel surveys have been exten- sively used for the development of Trip-based Models (TBM) and Activity-based Models (ABM) for travel demand prediction (Axhausen and G arling, 1992; Dong et al., 2006; Rasouli and Timmermans, 2014). Over the years though, conducting a travel survey at a city level has become an expensive and labor intensive task. As a result, more and more surveys are conducted via telephone interviews and cover only a small portion of Corresponding author Email addresses: k.gkiotsalitis@utwente.nl (K. Gkiotsalitis), francesco.alesiani@neclab.eu (K. Gkiotsalitis) 1Tel.: +31 534 891 870 travelers that is typically less than 3% of the city population (Stopher, 1996). In addition, the information from travel surveys is static and fails to capture the new travel trends because city-wide travel surveys are typically conducted every 2-10 years (Stopher and Greaves, 2007; Flyvbjerg, 2005; Flyvbjerg et al., 2006). Apart from the small sample sizes and the static information, the information from travel surveys is only useful for understanding the mobility patterns within the area that they are conducted (Gkiotsalitis and Stathopoulos, 2015b). As a result, even if some cities with budget limitations attempt to borrow surveys from other cities with similar characteristics, there is no guarantee that the information from those surveys is portable and they cannot be used to build reliable mobility demand prediction (Gkiotsalitis and Stathopoulos, 2015a; Gkiotsalitis et al., 2018). Considering the aforementioned ineciencies of survey-based methods, the potential of understanding the travel (and activity) behavior of users with the use of social media data is examined. The speci c focus of this study is on investigating whether social media can be used for identifying the travel behavior of individuals. Unlike the vast majority of past studies (i.e., Carrasco et al. (2008); Calabrese et al. (2011a)) that use social media or cellular data to estimate the passenger demand in one area based on the transmitted locations of individuals, our work has a more deep focus on investigating the potential of social media data to understand the travel behavior of individual users. That is to say, we do not use social media to estimate the current status of passenger demand but we try to investigate the link between the social media activity of a user and his/her travel behavior including the performed activities in the real-world. In this pursue, we do not consider only the location information from the social media data. Instead, we explore qualitative information such as the sentiments of users when they Tweet, the frequency of posting messages, the changes of locations when posting subsequent messages, and the spatio-temporal variation of the posted messages of each single individual. This user-focused exploration aims to investigate the link between the social media activity and the individual mobility patterns. This can be bene cial for the development of travel behavior models that do not require qualitative data from labor- intensive, revealed preference travel surveys (Flyvbjerg et al., 2006). In the remainder of this paper, we study the link between social media activity and travel behavior at the level of individual users. The paper is structured as follows: in section 2, the related literature and the motivation of this work are presented. In sec- tion 3, the notion of states that contain information about the individual's mobility and behavioral status is introduced. Moreover, the format of input data and the examined types of interaction are discussed. In section 4, the relation between the sentiments of individuals when posting messages on Twitter and their performed activities in the real- world is investigated. In section 5, we explore the potential of estimating the evolution of activity and travel states of individuals with the use of social media data. Furthermore, a Monte Carlo-based method for the simulation of the individuals daily travel schedules is provided. Additionally, a probabilistic state model which describes comprehensively the mobility patterns, the general behavior, and the high-level characteristics of one in- dividual is presented. In section 6, we explore the accuracy of our techniques that try to identify the travel and activity behavior of individuals based on social media data. For this, we perform a validation with the use of four months of Twitter data from London that is kept for testing purposes and is not used in our initial exploration. Finally, in 2 section 7 we provide some concluding remarks and propose future research directions. 2. Related Work Mobility demand is estimated by using either trip-based, activity-based or agent-based models (Kitamura, 1988; Bowman and Ben-Akiva, 2001; Zhang and Levinson, 2004; Lin et al., 2008). Activity-based and agent-based models are oftentimes used instead of the traditional trip-based models and allow the modeling of soft policies (i.e., implementing congestion charging schemes or modifying the oce hours in cities (Algers et al., 2005; Zheng et al., 2012)). Nevertheless, both activity-based and trip-based models are tailored towards survey-based data and they need to be adjusted for accommodating other sources of data. In a comprehensive review on travel surveys, Stopher and Greaves (2007) concluded that, due to the small samples and the static data provided from travels surveys, it is bene cial to use new sources of data to enriching the available information. Several other works such as Van Der Zijpp (1997); White and Wells (2002); Pan et al. (2006); Zhou and Mahmassani (2006); Gonz alez et al. (2008); Zhang et al. (2010); Baek et al. (2010); Calabrese et al. (2011b) and Shang et al. (2012) have also explored the use of continuously updated data, such as Floating Car Data (FCD), Automated Vehicle Identi cation (AVL) data, Inductive Loop Detector (ILD) data, and cellular data to predict the mobility of people. A special category is Smart Card (SC) data that can be used for estimating the spatio-temporal density of public transport passengers (Pelletier et al., 2011; Munizaga and Palma, 2012; Sun et al., 2012; Gkiotsalitis et al., 2019). The aforementioned data types cannot substitute the travel surveys' detailed insights with regards to the travel behavior of individuals because they provide information only about the location of individuals and not about the actual reasons behind traveling. Hence, they are mostly used for predicting the passenger demand and the trajectories of individuals, and not the travel behavior. This research gap motivates our work. In more detail, the above-mentioned weakness related to data types that provide only information about the locations of individuals can be potentially addressed with the use of data that is both continuously updated and information rich. One data candidate is social media data that includes posted messages with additional information. Regarding social media data, Twitter data has been used for a range of applications such as the validation of travel demand models (Lee et al., 2015), the understanding of human mobility (Jurdak et al., 2015), and the exploration of mobility patterns (Hawelka et al., 2014). Foursquare has been notably used for capturing the mobility and activity transitions of travelers (Wu et al., 2014) and for supplementing the travel demand survey data (Chaniotakis et al., 2016). However, there is little attention to the exploration of the link between social media data and the underlying reasons behind mobility and activity choices. For this reason, this study explores the potential of using social media data to un- derstand the travel behavior of individual travelers. More speci cally, attention is given to the correlation between the individuals' Twitter posts (i.e., the interaction types, the time of tweeting, the recurrency and duration of interactions, the individuals' sentiments during the interaction) and their travel decisions. It is worth noting that, besides Twit- ter and Foursquare, user information can be received by city-released Apps and other message-posting platforms. The main requirement is that the individual does not merely 3 share information about his/her location but also about his/her activity and mobility status, sentiments, and device type from which the message is posted. As a nal remark, we should note that past works have studied at a theoretical level the e ects of social relations on mobility decisions (see Musolesi and Mascolo (2007); Arentze and Timmermans (2008); Carrasco et al. (2008) and Nguyen and Szymanski (2012)). Notwithstanding this, the e ect of one individual's social relations to his/her travel decisions is not addressed in our work because, in most cases, the social media data of the close network of a user is not available given that not all individuals have an active Twitter account. Summarizing, our work is one of the rst that investigates the link between posted messages on social media and the travel behavior of users expressed in performed activities and travel choices. Its main contributions are the investigation of the relationship between the users' sentiments and their activity/travel behavior, the development of a transition model that tries to estimate the activity and mobility changes of an individual based on Twitter information, and the assessment of the ability of social media data to reveal information regarding the travel behavior of individuals. 3. De nition of States and Interaction Activities 3.1. De nition of States The notion of states is introduced to describe the mobility patterns of an individual by associating mobility decisions with parameters such as location, activity types and time of day. The location/activity of an individual at any given time ft;kg, wheretis the time of day and kis the date (i.e., day, month, year) is described by his/her state: qt;k i=fLt;k i;At;k jg (1) All possible visited locations of an individual are included to the set of his/her visited locations:Lt;k i2 =fL1;L2;:::;LNg8t;8k. In addition, each activity At;k jis included in the set of all possible activities: At;k j2A=fA1;A2;:::;AMg8t;8k. Finally, all states are included in the set of possible states: qt;k i2Q=fq1;q2;:::;qNg8t;8k. We assume that an individual participates in one activity when visiting a prede ned location. For facilitating the analysis the following set of activities is introduced: A=8 >>>< >>>:A1: Home A2: Work A3: Fixed Activity A4: Flexible Activity Furthermore, each location is described by the associated coordinates as they are retrieved from geo-tagged data. In order to reduce the total number of locations and minimize the e ects of positioning errors, we group all locations which lay within a circle with a representative location as center and 300 meters distance as radius. 4 3.2. Input Data The provision of public data from social networking websites and other sources grows fast and techniques for data analysis are required for exploiting the potential of using public data for mobility prediction. Since data from social networking websites can be highly heterogeneous, e orts have been made to minimize the data requirements for our techniques in order to enhance interoperability and facilitate the use of as many data- sources as possible. Therefore, only a ve-parameter dataset is considered after omitting irrelevant information in order to allow the future integration of information from multiple sources (even if at the current state, this study uses only Twitter data as input). Po- tential future data sources can include other social networking websites (i.e, Foursquare, Facebook, Google+) and mobile phone Short Message Service (SMS) data. The ve-value dataset can be described in the form of a matrix Sv j[t;k],j= 1;:::;5, wheretis the exact time (sec., min., hour) and kthe exact date (day, month, year) at which the individual generated content via social media. Furthermore, v, is the individ- ual's ID (i.e., username) and jis the set of the ve predetermined values that are provided at each interaction, j, where:j=f1: latitude, 2: longitude, 3: source of interaction (i.e., mobile internet, web), 4: recipient of the interaction (if any), 5: purpose of interaction (i.e., simple text, photo upload, video upload) g. in addition, individuals' socio-demographic information can be obtained manually from their public account pro les including their age category, gender, employment status, marital status and more. Table .5 in the appendix presents the format of the Twitter data after it is mined using the Twitter API. The small sample in table .5 presents all related elds which are considered in the analysis and from which the above-mentioned ve-value datasets is derived. 3.3. Interaction Activities Three di erent interaction types are de ned (the chatting activity, the continuous interacting activity and the reply activity), after the temporal analysis of data-exchange over time. "Chatting activity" at a location Liat timetand datekdescribes the situation when the individual exchanges text messages continuously with another individual over a prede ned time period. Therefore: Ct;k i=8 < :1 if a chatting activity was occured at location Liat timetand dayk 0 otherwise The "continuous interacting activity" refers to the occasion at which the individual composes messages, uploads photos or videos or shares information continuously over a predetermined time period. Continuous interacting describes the way of interacting from di erent locations. Ot;k i=8 < :1 if a continuous interacting was occured at location Liat time tand dayk 0 otherwise Finally, the "reply activity" refers to the occasion when the individual replies to a composed message sent by another individual and the disengages from the conversation (Rt;k i= 1 if the individual replies to a message from location Li, timetand day type k). 5 4. Educated Rules for Allocating Activities to Locations As we discussed previously, four di erent activity types are introduced: A=8 >>>< >>>:A1: Home A2: Work A3: Fixed Activity A4: Flexible Activity For the assignment of representative locations to speci c activities the embedded con- tent of messages is used only for capturing the sentiments of individuals, without per- forming a comprehensive textual analysis on the embedded text. In addition, locations are not associated with activity types by using information regarding the main Points of Interest (POI) near to locations where a message was posted since we aim at developing techniques without external requirements that can comprehend the obtained data from a study area (i.e., city) and remain scalable. Thus, the developed educated rules are mainly based on continuous spatio-temporal and interaction analysis of the input data. 4.1. Associating Activities with User Sentiments In contrast to cellular data that provides only information about the approximate position of an individual, the more detailed input from social media datasets can facilitate the study of individuals' sentiments when they participate in di erent activity types. In order to derive the sentiments of individuals, we extracted subjective information from embedded text messages by applying sentimental analysis. As we stated previously, we do not perform a comprehensive textual analysis but we are focusing on selected keywords that could reveal the sentiments of the individual. For determining sentiment a scaling system is adopted whereby words commonly associated with having a negative, neutral or positive sentiment are given an associated weight factor on a 10 to +10 scale. Nevertheless, regardless the used method, there are cases where individuals might comment on something allegorically or ironically and use words with negative meaning while they refer to something positive and vice versa. Therefore, there is a small chance that, in some cases, messages are assigned incorrectly to the wrong category. After the analysis of a four-month sample of published data on social networks the observed sentiments of individuals while participating in di erent activity types are pre- sented in table 1. Table 1: Summary results of sentiment analysis for di erent activity types Activity type Positive sentiment Negative sentiment Home 26% 74% Work 48% 52% Fixed 54% 46% Flexible 70% 30% The observations from table 1 are indicative since they are based on individuals that reside in a speci c metropolis; thus results might di er for di erent data samples from other cities. 6 4.2. Home Activity Type In order to associate a location with the home activity type, let xt;k=( 1 if individual's location and activity at time tand daykis known 0 otherwise (i.e., no data) Let alsoY=fyt;k 1;yt;k 2;:::;yt;k Ng, where yt;k i=8 < :1 if the examined individual is at location Liat timetand day k 0 otherwise Moreover, let wt;k=( 1 ifkis a weekday 0 ifkis weekend day By examining individuals' data exchange we observed that each individual has a time periodfMaxT!MinTgat which he/she does not undertake any interaction activity (i.e., message composure, photo upload etc.). That period will be called from now on "inaction period" since the individual does not interact with social media over a signi cant time frame (i.e., one month) (see Fig. 1). During that time we assume that the individual is located at home as it is also proposed by other studies (Noulas et al. (2011)). The lower bound MaxTis the latest time at which the examined individual interacted with social media and is derived after examining his/her interactions over at least one month's period. Furthermore, MinTde nes the upper bound and it is the earliest time in the morning at which an interaction is observed. After examining the temporal character- istics of individuals interactions we set 04:00 am as a threshold for dividing the night and morning periods; thus, interactions before 04:00 am are considered as night interactions and vice versa. In a rst attempt to associate a location with the home activity (rule I) it is assumed that home is the location with the more interactions over a signi cant time period (i.e., at least one month). Therefore, a location Liis associated with the home activity type, A1, if: k=DMX k=D1t=tNX t=t0yt;k iwt;kk=DMX k=D1t=tNX t=t0yt;k lwt;k8Ll2 (2) In a second method (rule II) that was introduced in the work of Gkiotsalitis and Stathopoulos (2015b), the home activity might not be the location with the most inter- actions during a signi cant time period but the location which satis es several criteria as they derived from the temporal analysis of the data and the analysis of individuals' sentiments while interacting. In summary, it is assumed that individuals interact more from home early in the morning and late at night and the possibility of being in a neg- ative emotional state is higher while interacting from home - as it is observed from the 7 Version February 28, 2018 submitted to Informatics 6 of 17 02468101214161820220510152025 Max T Min TInaction Time Time of Day (hr)Noof Interactions Figure 1. Temporal analysis of the number of tweets ("interactions") from a selected individual over a two-month period Let also Y=fyt,k 1,yt,k 2, ...,yt,k Ng, where yt,k i=( 1 if the examined individual is at location Liat time tand day k 0 otherwise Moreover, let 164 wt,k=( 1 if kis a weekday 0 if kis weekend day By examining individuals’ data exchange we observed that each individual has a time period 165 fMax T!Min Tgat which he/she does not undertake any interaction activity (i.e., message 166 composure, photo upload etc.). That period will be called from now on "inaction period" since 167 the individual does not interact with social media over a signiﬁcant time frame (i.e., one month) (see 168 Fig. 1). During that time we assume that the individual is located at home as it is also proposed by 169 other studies (Noulas et al. [29]). 170 The lower bound Max Tis the latest time at which the examined individual interacted with 171 social media and is derived after examining his/her interactions over at least one month’s period. 172 Furthermore, Min Tdeﬁnes the upper bound and it is the earliest time in the morning at which an 173 interaction is observed. After examining the temporal characteristics of individuals interactions we set 174 04:00 am as a threshold for dividing the night and morning periods; thus, interactions before 04:00 am 175 are considered as night interactions and vice versa. 176 In a ﬁrst attempt to associate a location with the home activity (rule I) it is assumed that home is the location with the more interactions over a signiﬁcant time period (i.e., at least one month). Therefore, a location Liis associated with the home activity type, A1, if: k=DM å k=D1t=tN å t=t0yt,k iwt,kk=DM å k=D1t=tN å t=t0yt,k lwt,k8Ll2L (2) 177 In a second method (rule II), the home activity might not be the location with the most interactions during a signiﬁcant time period but the location which satisﬁes several criteria as they derived fromFigure 1: Temporal analysis of the number of tweets ("interactions") from a selected individual over a two-month period emotion/activity type analysis presented in table 1. The following expressions formalize the three criteria of the empirical rule II. k=DMX k=D1t=Min T+2hrX t=Min Tyt;k iwt;k+k=DMX k=D1t=Max TX t=Max T3hryt;k iwt;k k=DMX k=D1t=Min T+2hrX t=Min Tyt;k lwt;k+k=DMX k=D1t=Max TX t=Max T3hryt;k lwt;k8Ll2(3) and k=DMX k=D1t=Min T+2hrX t=Min Tyt;k iwt;k+k=DMX k=D1t=Max TX t=Max T3hryt;k iwt;k0:3k=DMX k=D1t=tnX t=t0xt;k(4) and k=DMX k=D1t=tNX t=t0yt;k ilt;k0 (5) wherelt;kis a weight factor on a -10 to +10 scale that indicates the negative, neutral or positive anity/mood of an individual after performing a sentiment analysis on the embedded text of the associated message. To calculate the distance of other locations from home we use the Haversine formula which returns the shortest distance between any two geographic coordinates. Therefore, the distance between a location Liand the Home location,Lh, is set asFi(in km) after calculating it with the Haversine formula. 4.3. Work Locations Work activity is a special activity accumulating a number of speci c attributes re- garding its duration, starting time and day type. In a rst empirical rule it is assumed 8 that the location associated with the work activity is the one with the most interactions during day time (08:00 - 17:00). Nevertheless, after observing individuals' interactions we concluded that there are a number of criteria that should also be considered for im- proving the accuracy of the estimation. For instance, individuals interact from locations associated with the work activity type during daytime over weekdays and with a variance of more than six hours. In addition, interaction activities that reveal information about the duration of staying in a particular place such as chatting and continuous interacting are mainly observed at work location during day times. LetTLi=ft1;t2;:::;tgbe a set of day times at which the individual was at location Liafter considering the observed data from all dates. In a next step we sort the observed time set,TLi, in ascending order T0 Li=ft0 1;t0 2;:::;t0 g, where,t0 1t0 2:::t0 . We also de ne the 1stand the 3rdquartile,Q25;iandQ75;i, where: Q25;i=t0 bn25;ic+ (n25;ibn25;ic)(t0 bn25;ic+1t0 bn25;ic) (6) and Q75;i=t0 bn75;ic+ (n75;ibn75;ic)(t0 bn75;ic+1t0 bn75;ic) (7) The values of n25;iandn75;iare calculated from the equations: n25;i=25 100(1 +k=DMX k=D1t=tNX t=t0yt;k i) + 1 (8) and n75;i=75 100(1 +k=DMX k=D1t=tNX t=t0yt;k i) + 1 (9) Then, a location Liis a work location, A2, if the three following criteria of the above- mentioned empirical rule are satis ed: k=DMX k=D1t=tNX t=t0yt;k iwt;k0:75(k=DMX k=D1t=tNX t=t0yt;k ik=DMX k=D1t=tNX t=t0yt;k iwt;k) (10) and Q75;iQ25;i360 minutes (11) and k=DMX k=D1t=tNX t=t0(Ct;k iwt;k+Ot;k iwt;k)0:75(k=DMX k=D1t=tNX t=t0(Ct;k iwt;k+Ot;k iwt;k) ) (12) 4.4. Locations of Fixed Activities A location Liis the location of a xed activity, A3, if: k=DMX k=D1t=tNX t=t0yt;k i0:05k=DMX k=D1t=tNX t=t0xt;k(13) 9 Fixed activities, A3, is a general term that is used for describing several real-world activities such as visiting a shopping mall, a park, a restaurant, the school/university's premises and more. Fixed activities are more important than exible activities since they are recurrent and in some cases is useful to know the exact type of a xed activity. To capture the actual types of xed activities we introduce di erent categories which divide further the xed activities into subgroups and link them to real-world activities. In the remaining of this section, we provide a rule-set for dividing further the xed activities into six subcategories with respect to the input from the ve-value dataset that is used in this study. Each category is linked to a number of real-world activities as they are derived after analyzing four-month data from published information on Twitter. For the calibration phase only, we adjusted the results of our rule-set to the real-world activities of individuals which were derived by using textual analysis and data from Geographic Information Systems (GIS) together with regional POIs. One of the criteria for dividing xed activities into di erent categories is their distance from the home location. After calculating the distance between the locations of xed activities and the home location we introduce the following categories together with their associated real-world activities as presented in table 2. The real-world activities are assigned to di erent categories according to their likeli- hood of occurrence as it is derived from the analysis of the four-month sample. 10 Table 2: Categories of Fixed Activities Criteria Category Observed Visited Locations Q75;iQ25;i<4hr I: Local activities Shopping Mall, Park, Sport Sta- dium, Restaurant/Bar, Gym, Language Class,University Lecture Theater, Children's School, Bus or Train Station Fi<3:5km Q75;iQ25;i< 4hrII: Short-term, Long Distance ActivitiesHotel, Business Trip Meeting Place, External Oce, Home of a family member Fi3:5km 4hrQ75;iQ25;i<4hrIII: Recurrent Non-Scheduled ActivitiesHotel, Business Trip Meeting Place, External Oce,Home of a family member 0:05kmFi<15km 4hrQ75;iQ25;i<4hrIV: Medium Variance Activities, Long DistanceHotel, Business Trip Meeting Place, External Oce, Home of a family member Fi15km Q75;iQ25;i7hr V: Recurrent Non-Scheduled Activities near HomeWorking Place near Home, Local Shopping Center, Local Bus Stop 0:1kmFi<1km Q75;iQ25;i7hr VI: Large Variance, Long Distance ActivitiesFamily's member house, Hotel, Va- cation Place Fi>1km 5. Probabilistic Mobility Prediction Model 5.1. Educated Rules for Missing Data Imputation Having allocated an activity to each representative location, we estimate the individ- ual's travel schedule by establishing a set of rules. The rules are introduced to estimate the current states of individuals when data is not available and are particularly useful for datasets from social networking websites since, in most cases, individuals share informa- tion sparsely (see Fig. 2). In general, the educated rules combine information from the pre-allocation of activi- 11 0246810121416246810121416182022240246 Fi (km)Time (hr) Interactions 2468101214Figure 2: Spatio-temporal analysis of the interactions of a randomly selected individual over a two-month period ties to representative locations with information about locations at which the individual generated content throughout a daily period to estimate his/her daily trajectory. First, we assume that the individual stays at home during the inactive time period fMaxT!MinTg; thus, he/she is at the representative location which is associated with the home activity. When the user generates content from a di erent location than the location associated with the home activity for the rst time t1;lat a day,Dl, we know that the user is at another representative location and participates in a xed, A3, a exible, A4, or work activity, A2, at timet1;l. The transfer time, ts;l, when the user travels from A1to another representative location depends on the type of activity at the destination and is estimated as follows: ts;l=8 >>< >>:minfQ15;i;t1;lgif a xed or work activity is performed at the destination location Li t1;l if a exible activity is performed at the des- tination location Li Since we have identi ed the duration and starting times of work and other xed activities from the rst processing of the individual's data, we adjust the transfer time from home to work or another xed activity by considering not only the time at which the individual generated content from a di erent location but also the starting time and the duration of those activities. For performing such task, the 15th percentile of the activity duration is selected due to its better performance compared to the 25th percentile and the 5th percentile. For exible activities we consider only their starting time since we do not collect information about their duration. The location and activity values of the individual's state are changed only if he/she generates content from a di erent representative location than the one he/she was before. 12 If the user generates content at a location Ljat timeth;land before he was at location Li6=Ljat timeth1;l, then we assume that the user stayed at location Liuntil time t=ts;land changed locations at time ts;l. The transfer time depends on the interaction times th1;l,th;land the type of the activities at locations Li;Lj. For exible activities we consider only the time at which the individual generated content. However, for a xed or work activity we consider also the duration, the starting and ending times as we discussed above. In summary, after testing di erent scenarios the transfer times are set as: ts;l=8 >>>>>>>>>>>>>>>>>>>>>>< >>>>>>>>>>>>>>>>>>>>>>:maxfQ15;j;th1;lgif the origin is a exible activity and the destination is work or a xed activity (th1;l+th;l)=2 if the origin is a exible activity and the destination is home or a exible activity (th1;l+th;l)=2 if the origin is home and the destination is a exible activity maxfQ15;j;th1;lgif the origin is home and the destination is work or a xed activity minfQ85;i;th;lg if the origin activity is work or a xed activity and the destination home or a exible activity (th1;l+th;l)=2 if the origin activity is work or a xed ac- tivity and the destination work or a xed activity In the case where the last daily interaction was at time ty;lfrom a di erent representa- tive location than the one which is associated to home, we assume that the user returned to home at transfer time: ts;l=8 >>< >>:minfMaxT;ty;l+ 2hrgif the last interaction is from a exible activity type location maxfQ85;j;ty;lg if the last interaction is from work or a xed activity type location The educated rule-set for imputing the daily missing data returns the results of Fig. 3. 5.2. Modeling the choice of Activity Timing In the previous section we estimated the timing, tl;sat which the individual transfers between consecutive activities on a deterministic way by using a set of educated rules. The estimated transfer times can be also adjusted with the use of theoretical models on top of our educated rules. Models for modeling the timing of activities are based upon basic assumptions such as: individuals aim at optimizing the utility of their daily activity patterns (Meloni et al. (2004)), individuals derive a certain utility depending on the duration and the time of day they participate in activities and there is a disutility associated with the cost and the time spent while traveling (Akiva and Lerman (1985), Ettema et al. (2007)). 13 gkiotsalitis et al. 12 02468101214161820220510 A4 A1A2A2A2A2 A4Daily Interactions Time (h)Distance from Home (km) 02468101214161820220510 A4 A1A2A2A2A2 A4Q15;iQ85;i ty;l+ 2hTransition Time (h)Distance from Home (km) FIGURE 3 Estimating States Evolution by Imputing Missing Data The switching time depends on the interaction times th1;l,th;land the type of the activities at locationsLi;Lj. For ﬂexible activities we consider only the time at which the individual generated content. However, for a ﬁxed or work activity we consider also the duration, the starting and ending times as we discussed above. In summary, after testing different scenarios the switching times are set as: ts;l=8 >>>>>>>>>>>>>>>>>>< >>>>>>>>>>>>>>>>>>:maxfQ15;j;th1;lgif the origin is a ﬂexible activity and the des- tination is work or a ﬁxed activity (th1;l+th;l)=2 if the origin is a ﬂexible activity and the des- tination is home or a ﬂexible activity (th1;l+th;l)=2 if the origin is home and the destination is a ﬂexible activity maxfQ15;j;th1;lgif the origin is home and the destination is work or a ﬁxed activity minfQ85;i;th;lg if the origin activity is work or a ﬁxed activity and the destination home or a ﬂexible activity (th1;l+th;l)=2 if the origin activity is work or a ﬁxed activity and the destination work or a ﬁxed activity In the case where the last daily interaction was at time ty;lfrom a different representative location than the one which is associated to home, we assume that the user returned to home at switching time: ts;l=8 >>< >>:minfMaxT;ty;l+ 2hrgif the last interaction is from a ﬂexible activ- ity type location maxfQ85;j;ty;lg if the last interaction is from work or a ﬁxed activity type location The educated rule-set for imputing the daily missing data returns the results of Fig. 3.Figure 3: Estimating states evolution by imputing missing data Assuming that tl;sis the ideal time when the next activity should start, we can use the notion of early and late schedule delay de ned by Hess et al. (2007): SDEs= max(0;(stl;s)) (14) SDLs= max(0;(tl;ss)) (15) wheresis the actual arrival time at the next activity. The arrival time scan be discretized to represent 5-minute wide intervals of arriving at the activity over a predetermined period (i.e., s2tl;s30;tl;s25;:::;tl;s+ 30). Then, the utility of arriving at time scan be de ned as: Us= 1SDEs+ 2SDLs+ 3+"(s) (16) The parameters 1; 2; 3capture the trade-o between changes in the timing of arrival and scheduling costs. Furthermore, by assuming that the error term "(s) is independently and identically distributed according to a type 1 extreme value distribution, then the choice of arriving time is calculated from the following multinomial logit model: P(s) =e 1SDE s+ 2SDL s+ 3 l=tl;s+30X l=tl;s30e 1SDE l+ 2SDL l+ 3(17) 5.3. Simulating Individual's Daily Schedules All dateskare divided into two main groups: w1which includes all weekdays and w2 which contains all weekend days. The transition probability between two states can be de ned as: at;k2w1 i;j =number of times being at state qjat timet+ 1 while being at state qiat timetand day type w1 number of times being at state qiat timetand day typew1(18) 14 and at;k2w2 i;j =number of times being at state qjat timet+ 1 while being at state qiat timetand day type w2 number of times being at state qiat timetand day typew2(19) These probabilities can be used for estimating the daily schedule of an individual for a day type k2w1. The daily schedule is described by the evolution of di erent states during that day and is derived from the probability of being at state qiat timeMinw1 T: PMinw1 T(qi) =PMinw1 T(AjjLi)PMinw1 T(Li) =k=DMX k=D1yMinw1 T iwMinw1 T;k k=DMX k=D1xMinw1 TwMinw1 T;k(20) whereMinw1 Tis the earliest time at which the individual posts a message on Twitter for day type k2w1. The daily schedule of the individual is estimated via an iterative simulation by knowing the initial probability of being at a state qiat timeMinw1 Tand the transition probabilities at;k2w1 i;j . From the simulation, the probability of being at a state jat timetand day type k2w1is given as: t;w1 j=X it1;w1 iat1;w1 i;j (21) The output is the estimation of the individual's daily schedule (Fig. 4) as a sequence of states:fqMinw1 T;qMinw1 T+1;:::;qNg 15 08:00 08:10 09:00 17:00 18:10 18:50 19:40 20:30 Work Fixed Activity Daily Activity Transitions Flexible Activity Home Figure 4: Simulating the daily evolution of states over a weekday [map source: Google maps] 6. Validating the Educated Rules for Allocating Activities to Locations The rule-set for allocating activities to representative locations has been validated with the use of real data from Twitter (4-month sample from a metropolis in north Europe). The data includes information for the development of the ve-value dataset. The validation phase examines the accuracy of the developed techniques on interpreting social media data and associating geo-tagged locations to activities. The results of allocating activities to locations (i.e., home activity, work activity, xed activity, exible activity) are compared with real data derived manually from GIS, data from POIs and the outcome of textual analysis on the content of users' messages. By using the sample, 3572 activities were assigned to representative locations. To evaluate the performance of our techniques we introduce the following metrics: Eh=0 BBBBB@z=SX z=1k=DMX k=D1t=tNX t=t0rt;k i;z k=DMX k=D1t=tNX t=t0yt;k i;z1 CCCCCA=S (22) whereEhis the error of assigning the home activity to the wrong location, rt;k i;z= 1 if the corresponding location Li;zis assigned inappropriately to activity A1andrt;k i;z= 0 otherwise. In addition, Sis the total number of individuals in the sample. The second metric is: Ew=0 BBBBB@z=SX z=1k=DMX k=D1t=tNX t=t0Rt;k i;z k=DMX k=D1t=tNX t=t0yt;k i;z1 CCCCCA=S (23) 16 Table 3: Errors in associating home and work-related activities of individuals to the right locations using the educated rules Activity Type Sample Size Errors Home - using Rule I 1664 Eh=34.735% Fh=29.931% Home - using Rule II 1664 Eh=13.747% Fh=11.765% Work 552 Ew=39.1347% Fw=317.432% Table 4: Errors in associating xed and exible activities of individuals to the right locations Activity Type Error Flexible (Failures: 138 | Sample Size: 1354) 9.845% Fixed - Category 1 (Shopping Mall, Park, Sport Stadium, Restaurant/Bar, Gym, Language Class,University Lecture Theater, Children's School, Bus or Train Station)1.312% Fixed - Category 2 (Hotel, Business Trip Meeting Place, Ex- ternal Oce, Home of a family member)7.256% Fixed - Category 3 (Hotel, Business Trip Meeting Place, Ex- ternal Oce,Home of a family member)12.526% Fixed - Category 4 (Hotel, Business Trip Meeting Place, Ex- ternal Oce, Home of a family member)2.136% Fixed - Category 5 (Working Place near Home, Local Shopping Center, Local Bus Stop)9.254% Fixed - Category 6 (Family's member house, Hotel, Vacation Place)8.233% whereEwis the error of assigning the work activity to the wrong location, Rt;k i;z= 1 if the corresponding location Li;zis assigned inappropriately to activity A2andRt;k i;z= 0 otherwise. Similarly, Ef, is the error associated with assigning representative locations to exible activities. In addition, Fh=z=SX z=1#z SandFw=z=SX z=1$z S(24) are errors associated with the total failure of assigning home and work activities to rep- resentative locations where #z= 1 and$z= 1 if the home and work activity of the zth individual are not assigned to the appropriate representative location and #z= 0;$z= 0 otherwise. The associated errors of the proposed techniques are presented in table 3 and table 4. 17 7. Concluding Remarks and Future Work In this work we introduced educated rules that process information about the type, the timing, the duration and the recurrence of interactions together with the sentiments of individuals while interacting. The scope of this study was to associate representative locations to di erent activity types after processing Twitter data and develop a general framework that can be used for processing datasets from social media and SMS applica- tions in order to automate the extraction of mobility-related information. In addition, we introduced educated rules for imputing missing data which are par- ticularly useful when social media are the only source of information due to the data sparsity. Finally, we proposed a Monte Carlo-based simulation method for estimating the evolution of daily states and transfers of the users over a weekday or a weekend day taking as input the outcome from the proposed techniques. After validating our educated rules against a four-month sample the results were promising and the accuracy of allocating activities to locations was more than 85% with only exception the assignment of the work activity of users to the right location (82.67% accuracy). Thus, the study showed that it is possible to use social media as a standalone or supplementary method for surveying the population and -more importantly- for esti- mating the activities and the mobility behavior of individuals even if the data from social media is more sparse compared to the cellular data from mobile phones (Gkiotsalitis and Stathopoulos (2016)). Given the already promising results, we propose a detailed textual analysis in the content of the embedded text messages in order to leverage on the publicly shared content for improving the accuracy of activity allocations. In future research, we envision the development of a mobility demand prediction model which uses the mobility patterns of individuals as they are estimated after applying our educated rules. Finally, we propose the integration of survey data with social media data in order to study potential accuracy improvements on predicting the mobility demand as another future research topic.