суббота, 13 апреля 2013 г.

Forecasting of Stock Financial Series Using Multivariate Vector Autoregressive Model

   The ARIMA model (e.g from  'forecast' package for R) is frequently used for forecasting univariate time series.  This model  uses a  previous behavior of only one time series.  Such an approach does not allow for possible relations between different time series. Taking into consideration such  relations, one can give more precise prediction and it can be performed using multivariate vector autoregressive model.

Let us consider an example. Download a historical date of four stock financial series:

then, using multivariate autoregressive model, we can forecast the time series for each stock symbol, taking into account possible relations between these series:

воскресенье, 7 апреля 2013 г.

Simple Tweets Miner for Stock Market

      I would like to present a simple R code which can load tweets timelines of specified users, then, in the loaded tweets, find frequent terms, some associations with specified terms and display the results as terms clouds. I think such visualization is more effective for sentiment analysis if compared with the calculation of positive and negative words, and it can give more intuitive tips for analytics. Users can use the following functions: gettweets(), freqterms(), assoc("term"), stock("symbol").
     The gettweets() function allows users to load the latest tweets from a specified list of twitter users, such as: CNN, WSJ, Reuters, Bloomberg, etc. Please, use this function only once per analysis, because if you load tweets too often, Twitter can block you IP. With the following command, you can specify the maximum number of latest tweets that can be loaded from each user's timeline:  gettweets(number), the default number is 100.  The function freqterms() will output more frequent terms.
    The function assoc("term") will display the terms that are correlated with some specified term, e.g. assoc("apple").
   The function stock("symbol") will display a stock chart for some specified symbol, a cloud of terms which are correlated with the specified symbols, and the forecasting, based on the ARIMA model. Each company has its own specified symbol, e.g.: Google - GOOG, Apple - AAPL, Yahoo - YHOO, Dell - DELL, Oracle - ORCL, Microsoft - MSFT, Cisco - CSCO, etc. For example, the function stock("GOOG") will display a stock chart fro Google.

Download R-code

To work with this program, you need to install R (more info at http://r-project.org). Before starting the program, you need to install the additional packages, you can do this using the following commands:
    install.packages ("forecast")
    install.packages ("quantmod")

             Our next step is going to be the use of multivariate forecasting algorithms based on the vector ARMA model. These algorithms  can include many time series into analyses, the time series describe both stock prices and quantitative characteristics of tweets. I think such an approach will give the narrower and more precise forecasting. To the effective tweets characteristics, we are planning to use the theory of semantic fields, frequent sets, associative rules, Galois lattice, the formal concepts analysis. Such an approach can be found in our previous investigations at

Please write your comments.

Printscreens of functions performing: