EDA:- Infosys stock prices

Infy Stock descriptives and charts

Row

Infy last closing price (Rs)

903.55

+/- (in Rs) since yesterday

3.65

Average monthly change

BUY or SELL ??

-0.23

Row

About_flexdashboard

This dashboard allows you to explore trends in Infosys stock prices from 2007 onwards. We will forecast Infy prices using many timeseries algorithms as well as ML models including deep learning frameworks.

summary

     Index             INFY.NS.Open     INFY.NS.High     INFY.NS.Low    
 Min.   :2007-01-02   Min.   : 434.0   Min.   : 440.5   Min.   : 419.0  
 1st Qu.:2009-09-09   1st Qu.: 807.8   1st Qu.: 819.1   1st Qu.: 797.1  
 Median :2012-05-16   Median : 951.9   Median : 962.5   Median : 941.1  
 Mean   :2012-05-16   Mean   : 929.1   Mean   : 940.2   Mean   : 917.4  
 3rd Qu.:2015-01-22   3rd Qu.:1054.9   3rd Qu.:1067.5   3rd Qu.:1044.6  
 Max.   :2017-10-03   Max.   :1315.4   Max.   :1328.1   Max.   :1309.2  
 INFY.NS.Close    INFY.NS.Volume     INFY.NS.Adjusted
 Min.   : 275.6   Min.   :       0   Min.   : 175.1  
 1st Qu.: 555.0   1st Qu.: 2960828   1st Qu.: 361.8  
 Median : 704.4   Median : 4089820   Median : 510.2  
 Mean   : 732.4   Mean   : 5076908   Mean   : 596.0  
 3rd Qu.: 944.8   3rd Qu.: 5903858   3rd Qu.: 905.4  
 Max.   :1267.6   Max.   :83160204   Max.   :1221.0  

tail

           INFY.NS.Open INFY.NS.High INFY.NS.Low INFY.NS.Close
2017-09-27        906.1        907.9       895.1        899.80
2017-09-28        896.1        903.9       894.3        896.00
2017-09-29        898.0        902.4       895.0        899.90
2017-10-03        899.9        912.0       899.9        903.55
           INFY.NS.Volume INFY.NS.Adjusted
2017-09-27        3000069           899.80
2017-09-28        8768633           896.00
2017-09-29        2852916           899.90
2017-10-03        2473761           903.55

Row

Closing Prices (Infy/TCS/Wipro)

90-Day Daily returns (Infy/TCS/Wipro)

Monthly-Log returns (Infy/TCS/Wipro)

Distribution (Monthly-Log returns)

Infosys

TCS

Wipro

Column

Infy_Chart

TS_plots

Infy_clPrice_ACF/PACF

TS_Decomposition

Data exploration

Infy Stock distribution exploration

Column

Density & Box plot

Box plot with outliers

 [1] "483"  "491"  "481"  "483"  "491"  "492"  "441"  "481"  "491"  "1953"
[11] "2617" "1549" "1486" "2618" "1057" "1302" "1550" "2348" "2620"

Univariate Timeseries Forecasting using exponential smoothing ets()-:Daily prices

Forecasting using exponential smoothing ets()-:Daily prices

Column

forecast plot-ets method

Point forecasts - 50 days ahead

Univariate Timeseries Forecasting using auto.arima-:Daily prices

Forecasting using auto.arima -:Daily prices

Column

forecast plot-auto.arima method

Point forecasts - 50 days ahead

forecast accuracy metrics

                    ME     RMSE    MAE          MPE    MAPE      MASE
Training set 0.1358915 13.34957 9.1323 -0.002223269 1.34826 0.9979284
                    ACF1
Training set 0.001346911

Univariate Timeseries Forecasting using auto.arima-:monthly mean prices

Forecasting using auto.arima -:monthly mean prices

Column

forecast plot-auto.arima method

Point forecasts - 50 days ahead

forecast accuracy metrics

                   ME     RMSE     MAE       MPE     MAPE      MASE
Training set 2.202779 40.08032 31.7189 0.1601666 4.710236 0.9772979
                    ACF1
Training set -0.01202659

Monthly Infy closing prices ts data view

           Jan       Feb       Mar       Apr       May       Jun       Jul
2007  558.2987  572.9821  518.9500  508.1606  494.7119  489.1524  491.3028
2008  386.8347  393.8399  354.1389  392.9494  460.6163  465.3851  410.6500
2009  307.9443  311.1526  318.8632  353.9819  393.1575  434.3733  466.5312
2010  646.3789  625.7762  675.6660  678.7342  660.3548  682.7285  697.8283
2011  827.0593  770.9951  765.9165  768.7936  712.8745  707.6319  707.8940
2012  679.3702  710.9774  712.5227  635.0066  597.3460  614.4011  573.6090
2013  657.7043  704.3888  724.7099  636.0119  588.7472  609.2107  676.2684
2014  910.7843  916.0874  869.3532  806.2467  782.0739  789.5845  821.7146
2015 1045.5171 1126.5053 1114.3838 1062.2660  994.0945 1001.2077 1018.7848
2016 1106.9750 1123.9119 1172.5550 1210.0528 1209.1523 1205.4477 1122.6025
2017  965.2643  975.3026 1026.7250  946.6000  957.2818  949.3119  974.2048
           Aug       Sep       Oct       Nov       Dec
2007  469.6000  461.2576  480.7693  415.7005  424.1519
2008  421.1399  404.4155  327.3013  309.8617  288.5054
2009  517.0624  566.1762  560.2101  583.3049  623.0953
2010  697.4584  737.6648  764.7868  757.2856  813.9697
2011  605.7332  591.0481  667.9529  684.8181  681.5196
2012  583.7840  631.4592  609.2525  594.7803  579.7919
2013  755.6194  759.5175  807.5530  835.6731  857.2150
2014  888.8205  921.9239  961.2804 1051.3144  997.0936
2015 1111.8548 1100.1250 1135.7875 1087.6306 1076.5545
2016 1053.4477 1044.6075 1027.8882  951.6024  988.5500
2017  952.4571  899.2238  903.5500                    

Monthly Infy closing prices

Univariate Timeseries Forecasting using Neural Networks model:Daily prices

Forecasting using Neural Networks model:Daily prices

Column

Neural networks for timeseries forecasting

Neural Network Time Series Forecasts

  • Feed-forward neural networks with a single hidden layer and lagged inputs for forecasting univariate time series.

Neural network autoregression (NNAR) models

  • Lagged values of the time series can be used as inputs to a neural network.
  • NNAR(p;k): p lagged inputs and k nodes in the single hidden layer.
  • NNAR(p;0) model is equivalent to an ARIMA(p;0;0) model but without stationarity restrictions.
  • Seasonal NNAR(p;P ;k): inputs (yt-1,yt-2,…..yt-p,yt-m,yt-2m,yt-pm)and k neurons in the hidden layer.
  • NNAR(p;P ;0)m model is equivalent to an ARIMA(p;0;0)(P ,0,0)m model but without stationarity restrictions.

NNAR models in R

  • The nnetar() function fits an NNAR(p;P ;k)m model.
  • If p and P are not specified, they are automatically selected.
  • For non-seasonal time series, default p = optimal number of lags (according to the AIC) for a linear AR(p) model.
  • For seasonal time series, defaults are P = 1 and p is chosen from the optimal linear model fitted to the seasonally adjusted data.
  • Default k = (p + P + 1)=2 (rounded to the nearest integer).

nnetar function from forecast v7.3 by Rob Hyndman

nnetar:rdocumentation.org

Neural networks Model:Forecasting: principles and practice-Rob Hyndman

forecast plot-Neural Networks method

Point forecasts - 50 days ahead

Univariate Timeseries Forecasting using Neural Networks model:monthly mean prices

Forecasting using Neural Networks model:monthly mean prices

Column

forecast plot-Neural Networks method

Point forecasts - 50 days ahead

Univariate Timeseries Forecasting using Support vector regression (SVR)-:Daily prices

Forecasting using Support vector regression (SVR)-:Daily prices

Column

forecast plot-Support vector regression (SVR) method

Point forecasts - 20 days ahead

Univariate Timeseries Forecasting using extreme gradient boosting-:Daily prices

Forecasting using extreme gradient boosting-:Daily prices

Column

Extreme gradient boosting for forecasting

In the last few years there have been more attempts at a fresh approach to statistical timeseries forecasting using the increasingly accessible tools of machine learning. This means methods like neural networks (http://www.neural-forecasting-competition.com/index.htm) and extreme gradient boosting (https://en.wikipedia.org/wiki/Gradient_boosting), as supplements or even replacements of the more traditional tools like auto-regressive integrated moving average (ARIMA) models.

The forecastxgb package aims to provide time series modelling and forecasting functions that combine the machine learning approach of Chen, He and Benesty’s xgboost (https://CRAN.R-project.org/package=xgboost) with the convenient handling of time series and familiar API of Rob Hyndman’s forecast (http://github.com/robjhyndman/forecast). It applies to time series the Extreme Gradient Boosting proposed in Greedy Function Approximation: A Gradient Boosting Machine, by Jerome Friedman in 2001 (http://www.jstor.org/stable/2699986). xgboost has become an important machine learning algorithm; nicely explained in this accessible documentation (http://xgboost.readthedocs.io/en/latest/model.html).

R package forecastxgb (https://github.com/ellisp/forecastxgb-r-package/) & from the forecastxgb vignette (https://github.com/ellisp/forecastxgb-r-package/blob/master/pkg/vignettes/xgbts.Rmd)

forecast plot-Extreme gradient boosting method

Point forecasts - 12 days ahead

Comparing xgboost with arima nnet & theta

ARIMAX-Forecasting stock returns using ARIMA model with exogenous variable in R

Forecasting using ARIMAX-:Daily prices

Column

forecast plot-ARIMAX method

Point forecasts - 25 days ahead