IMPACT OF SOCIAL MEDIA ON THE STOCK MARKET: EVIDENCE FROM TWEETS

The paper deals with the impact of the economic agent sentiment on the return for Apple and Microsoft stocks. We employed text mining procedures to analyze Twitter messages with either negative or positive sentiment towards the chosen stock titles. Those sentiments were identified by developed algorithms which are capable of identifying sentiment towards companies and also counting the numbers of tweets in the same group. This resulted in counts of tweets with positive and negative sentiment. Then we ran analysis in order to find causality between sentiment levels and the stock price of companies. To identify causal effects we applied Granger causality tests. We found bilateral causality between the risk premium and the amount of news distributed by Twitter messages.


INTRODUCTION
The objective of this paper is to identify causal links and their directions between the stock returns and the economic agent sentiment. The main focus will be placed on the social networks, especially messages sent via Twitter. We hypothesize that those messages -tweets, provide quantifiable information about the sentiment. Therefore we apply text mining algorithms to identify positive and negative tweets relating to the analysed companies (Apple and Microsoft).
This paper continues the work of predecessors in this field, mainly Bollen, Mao and Zeng (2011). They have shown that there is a causal link between sentiment on Twitter and the stock market and therefore they were able to predict movements of the Dow Jones index (DJIA) with 87.6% accuracy. Kuleshov (2011) was, on the other hand, not able to reproduce their results with the same procedure and thus questioned the research. No researcher has been able to archive similar results even with different methods, neither with the whole market nor with specific stock titles.
Apart from the majority of its predecessors this paper does not deal with causal links between sentiment and the whole market, which was represented by e.g. the Dow Jones index (Bollen, Mao and Zeng, 2011). It tries to find causality between sentiment and the price of specific stock titles. In order to accomplish that, it employs special algorithms which were not needed in previous research. The purpose of those is on one hand to identify tweets which are in some relationship with the chosen companies and on the other hand, to evaluate the level of sentiment of those tweets and to count them. Algorithms were created to be able to operate with tweets so they also respect some specifics of colloquial language. One of the most important parts is the analysis of causal links. There we employed Granger causality like Bollen, Mao and Zeng (2011).

THEORETICAL BACKGROUND
There is a large and rapidly growing literature examining the impact of investors' sentiment on financial markets, especially the predictive power of internet message postings. The empirical studies commonly employ distinct classifier machine learning algorithms to extract sentiment proxies from the huge quantity of text messages published in the news, in social media or on internet message boards (Antweiler and Frank, 2004;Arias, Arratia andXuriguera, 2013 or Kim andKim, 2014). These sentiment proxies are associated with specific words or expressions identified by rules or lexicons.
According to the efficient market hypothesis (EFM), the prices of securities are close to fundamental values (Fama, 1970;1991). Markets are efficient because investors are rational and there are no limits on conducting arbitrage. Any dislocations in asset prices are quickly eliminated by rational investors (Friedman, 1953;Fama 1965), who understand Bayes' law and process all available information when forming expectations. However, empirical observations of capital markets contradict the EFM because the existence of anomalies and excess volatility cannot be explained by changes in fundamentals (LeRoy and Porter, 1981;Shiller, 1981;2003).
This work is based on the fact that, according to Dolan (2002), human emotions have a large influence on decision making in general and also, as Gilbert (2010) states, on decision making and behaviour on financial markets. It is expected that with a better or more positive overall mood of investors they will be more prone to buying rather than selling in expectation of following growth of the price and vice versa. Those influences of public mood are then able to explain changes of asset prices which are unexplainable by fundaments. Gilbert and Karahalios (2010) showed that it is possible to abstract those sentiment (emotion) levels from social media. Those levels have aggregate character and expresses public mood. Based on that we suppose that if the sentiment influences decisions on the financial markets it also influences stock prices, which is the same assumption as used by similar research by Bollen, Mao andZeng (2011), Kuleshov (2011) or Chung and Liu (2011). We also suppose that if this aggregate or general mood influences stock prices in general, mood towards one company influences stock prices of that company, as used by Chung and Liu (2011).
Different social media were used in past research in order to identify both overall sentiment levels and sentiment levels in relationship with one object (e.g. company). The social network Twitter was used with success by Bollen, Mao andZeng (2011), Zhang, Fuehres andGloor (2011), especially for its consistency and information value. The desired information is captured in tweets -unique authors' messages which are collectible via Twitter API.

METHODOLOGICAL BACKGROUND
In the beginning we had to choose companies with which to run analysis. We chose Microsoft Corporation and Apple Inc., mainly because of two elements. Stocks needed to be publicly traded, so we could run analysis and companies had to be popular. This popularity is for the purpose of research expressed by the combination of elements of market capitalization, average volume of stared stocks, business to consumer character of product and overall popularity of companies. We assumed that popular companies or their products will be mentioned more on Twitter than less popular ones and thus it will boost the importance of sentiment on Twitter in explaining changes in stock price.
The empirical strategy combines text mining algorithms and econometric modelling. First, we used Twitter streaming API in order to extract tweets from Twitter. We extracted tweets during the period from 1.3.2014 to 18.5.2014. We applied a filter to obtain tweets in the English language and keywords filter, which identified tweets with some relationship with the chosen companies. Those words were selected by analysis of companies and their products and with Google Trends which shows the popularity of words in google searches. Words were divided into two groups which identified Apple (M A ) and Microsoft (M M ).
After we created algorithms which were able to identify towards which company tweet carries sentiment, the level of sentiment itself and which also respects some features of colloquial English language. Those algorithms consisted of groups of words with different functions. In order to be counted as negative or positive, a tweet had to contain none or at least one word from each group in the algorithm. Which words the tweet must and must not contain is described by logical math connectors (conjunction ∧, disjunction ∨ and negation ¬). Formula 1 represents the algorithm for identification of the number of tweets carrying positive sentiment towards Apple, formula 2 negative sentiment towards Apple, formula 3 positive sentiment towards Microsoft and formula 4 negative sentiment towards Microsoft: where Ngram tools. Groups of words V A and V M were selected after thorough analysis of fundamental aspects of companies, products and especially competitive environment. Words in group V all were selected in order to enable algorithms to identify specifics of colloquial English. After we established algorithms we standardized data from Twitter. The process of standardization consisted of deletion of tweets of artificial origin (e.g. made by bots or applications) and limiting the number of tweets at 200,000 per day. Then we applied algorithms 5 to 8 which resulted in counts of both positive and negative tweets in relationship to either Apple or Microsoft by days.
With the counts of tweets needed, we applied Arbitrage Pricing Theory (APT) to obtain a basic model describing the relation between the stock returns and other factors (Ross, 1976). To explain stock returns we started with the simple Capital Asset Pricing Model (CAPM): where ER i is the expected return of the specific capital asset i, RF is the risk-free interest rate on the market (usually government bonds), ER m is the expected return of the market and β i is the sensitivity of the expected excess of the specific asset return to the expected excess market returns calculated as The formula (5) is extended to the multifactor model as the special case of the APT: where R i and R m are returns calculated from historical data as a rate of return over a single period on a daily basis, S i represents sentiment, δ is intercept and ϵ i is the idiosyncratic component of the stock's return which is minimized by the process of arbitrage. The vector autoregressive model of the order k, VAR(k), can be rewritten in matrix form: where all variables have the same lag length of order k. We applied Akaike and Bayesian information criteria to determine the minimal appropriate number of required lags.
To identify the causal relation between the news and the stock returns we applied Granger causality tests (Granger, 1969 andSims, 1972). The causality is inferred when the lagged values of a variable X t have explanatory power in a regression of a variable Y t on lagged values Y t and X t . If lagged values of a variable X t have no explanatory power of any of the variables in a system, then we would view X as weakly exogenous to the system. With respect to the direction of causality we can distinguish two cases: (1) unidirectional causality when X t is caused Y t but Y t does not cause X t and (2) bilateral causality when variables X t and Y t are jointly determined. This causality can be identified using the Granger test (1969) based on the premise that the future cannot cause the present or the past, utilising the concept of the VAR approach. In our analysis we assume a VAR(k) model with three variables X t , Y t and Z t : where X t represents risk premium of the specific stock (R i − RF), Y t is risk premium of the specific market (R m − RF) and Z t represents sentiment (number of bad and/or good news sent by Twitter on a daily basis). To test causality in the formula (8) we used the Wald test with the defined W statistic (Wald, 1943): and Lagrange multiplier with the defined LM statistic (Aitchison and Silvey, 1958;Silvey, 1959): where RSS u is the sum of squared residuals from the unrestricted equation and RSS r is the sum of squared residuals from the equation under the assumption that a set of variables is redundant (restricted). Both test statistics are distributed as χ 2 under the null hypothesis with the same degrees of freedom (same number of restrictions). Berndt and Savin (1977) showed that the both tests are first-order equivalent and asymptotically optimal but they differ in second-order properties, when the null hypothesis is false, but erroneously fails to be rejected.
In order to proceed we obtained daily close stock prices abstracted from splits and dividends and daily Dow Jones Index close prices from Yahoo! Finance. Risk free interest rate is represented by daily treasury real yield curve rates of 5-year bonds provided by U.S. Department of the Treasury. The dataset contains data in the period March 3, 2014 to May 18, 2014.

RESULTS
Firstly, we calculated beta from the sample period using the formula The parameter β is 0.6025 for Apple and 1.3721 for Microsoft. Using the adjusted closing price, the parameter β is 0.6093 for Apple and 1.3712 for Microsoft. The results showed that the Microsoft stock returns are much more sensitive to market movements as opposed to idiosyncratic factors. However, the key question is if the CAPM provides appropriate results and estimations of the asset prices and risks. Therefore we apply the simple version of the CAPM (formula 1) to calculate different betas referring to actual stock returns. The identified relations between the systematic risk (beta) and stock returns are presented in Fig. 1.
Obviously, there are too many situations when stocks do not lie on the SML (Security Market Line). Moreover, the results confirmed limitation of the simple CAPM without other idiosyncratic factors.
Regarding the results provided by the simple CAPM we included sentiment of the economic agents. Thus, we assume that economic agents incorporate and reflect all relevant information, including all idiosyncratic factors related to the specific stock returns. We assume that this information is contained in all news related to the companies and its typical products sent by Twitter as well. The results of the Granger causality tests are presented in Tab. 1 to 4. Tab. 1-2 present Wald statistics of variables within the identified VAR(k) models. In the case of Apple (AAPL) we estimated VAR models with k in the range 1-3. The lag was higher in the models of Microsoft stock (MSFT). The maximal lag of the estimated VAR model with significant relationship between the risk premium and news was 8 days.
However, the identified unilateral causality confirmed that risk premium of the specific stocks is affected only by market premium at the 1% and 5% significance level. We also found that the news sent via Twitter is affected by both risk premium of the specific stocks and risk premium of the market. Thus, the news reacts to the capital market movements, capital markets do not react to the news sent via Twitter. Especially in the case of Apple, we identified causal effects of risk premium of the stock and market on the bad news sent via Twitter at 1% significance level and lag of 2 days. On the contrary, changes in risk premium of the stocks and market affect the good news related to the company Microsoft and its products with the lag of 3 days. The only identified causality effect with direction from news to capital markets was identified in the case of Apple stock and the news which combines the names of both analysed companies and their products. This causality was identified in the model VAR(3) at 10% significance level.
Adjusted closing prices of the stocks showed similar results ( Table 2). The employed Wald test identified causality only in the direction from capital market to the news sent by Twitter. Especially bad news related to both companies Apple and Microsoft and its products, and bad news related to Apple and its products, react to the changes of the stock and market returns. The causality was identified at 1% significance level and lag of 2 days. On the contrary, good news related to the company Microsoft and its products are sent 3 days after the changes of the appropriate stock returns or market returns.
Bilateral causality between the news and capital markets, as well as the unilateral causality in direction from capital markets to news  3-4). The results presented in Tab. 3 confirmed that market risk affect stocks in all the identified models at 1% significance level. The effects of the news on the stocks were confirmed only in the model of Microsoft stocks and good news at 1% significance level, and in the case of the other 4 models at 5% significance level and in two models at 10% significance level. The reverse causal effects in direction from the markets to the news was identified in the case of bad and good news related to the company Apple and it products, and in the case of good news related to the company Microsoft and its products. Bilateral causality was identified in the case of good and bad news related to Apple and good news related to both the analysed companies. Obviously, the results are totally different in comparison with the Wald test. The reason is not only the possible error of the second-order mentioned in the methodological part of this paper but also different VAR models selected for the Granger causality tests. The resulted models, especially the lags, were selected according to the number of significant causal relations (under the assumption of the condition for the minimal required lag given by Akaike and Bayesian information criteria). Summarily, we can assume that the results in Tab. 1-2 may be biased by the error of the second-order. This means that the results may fail to reject a false null hypothesis, thus the results may fail to detect the effects of the news on the capital markets that are present.
Tab. 4 provides results where stock prices are adjusted by any distributions and corporate actions that occurred at any time prior to the next day's opening. These results better record the historical performance and confirmed the effect of the news on the capital markets. However, we can identify much fewer links in comparison with the results presented in Tab. 3. There is significant causal effect of the good news related to the company Microsoft and its products on the stock returns at 1% significance level with the lag of 1 day. In the same model we identified also effects of this news on the market risk premium. The causal effect in the direction from the news to capital markets at 5% significance level was identified in the case of Microsoft stocks and bad news related to both companies. On the contrary, capital markets affected news sent via Twitter in the four models. Three of these four models are VAR(2). Thus, the effects of the news on the capital markets may be slightly faster in several cases than the effects in the direction from the capital markets to the news sent via Twitter.
The section should contain an evaluation and exact description of the achieved results. If the nature of a paper allows it, also state the statistical significance of the results.

DISCUSSION AND CONCLUSIONS
In this paper we employed Granger causality to identify causal links between users' content on the social network Twitter -tweets and price of stocks of Apple Inc. and Microsoft Corporation on the New York Stock Exchange. The Wald test which was used proved causality from the direction of the market to the sentiment on Twitter. LM statistics on the other hand showed the existence of both one directional and two directional causal links. The causality of stock markets on the sentiment of tweets was proven mostly in models with positive sentiment tweets, which is a similar result as in the research of Chung and Liu (2011). In both tests causality of sentiment on the premium of Apple and Microsoft was proven, which may for example indicate that some Twitter users are owners of the stocks in question and opinion leaders such as news agencies are informing about the performance of markets. There were also identified causal links from the direction of the whole market (in this case the DJIA) to Twitter.
This research has also proven that simple CAMP is not enough to describe stock price creation and that the factor of feelings and emotions plays its role as is described by behavioural economics.
Possible limitations of our results originate in two causes. It is possible that the methodology of finding the causality between Twitter and specific stocks was creating limitations and research of causality between Twitter and whole market would resulted in proving even more significant causality (e.g. in all the models) as happened in the case of Bollen, Mao and Zeng (2011). The second limitation comes from identifying the sentiment of the tweets. The algorithms that we used were more complex than in previous research, which means that we were able to recognize sentiment and companies with more precision. On the other hand, specifics of colloquial language are far more complicated than the algorithms used could capture.