logo

Introduction

This project analyses historical trends in the NASDAQ Composite index using time series methods. The aim is to explore the behaviour of the index over time and apply Meta’s Prophet forecasting model to predict future values.

The Nasdaq Composite Index

The NASDAQ Composite is a stock market index that tracks the performance of more than 3,000 companies listed on the NASDAQ stock exchange in the United States. The index is heavily weighted towards technology and innovation driven firms, including many of the world’s largest companies in sectors such as software, semiconductors, biotechnology and internet services.

Unlike some other major indices, such as the Dow Jones Industrial Average which contains only a small number of firms, the NASDAQ Composite includes a very large set of companies and therefore provides a broad measure of the performance of growth oriented and technology focused businesses.

Because many technology firms have experienced rapid expansion over the past two decades, the NASDAQ Composite has shown strong long term growth compared with many traditional equity indices. At the same time, the index can also exhibit periods of volatility, as technology companies tend to be more sensitive to changes in interest rates, economic expectations and investor sentiment.

For this analysis, monthly historical values of the NASDAQ Composite are used to explore the behaviour of the index over time and to produce forecasts using the Prophet time series model.

Load the data

The monthly NASDAQ Composite data is imported from a CSV File. I first inspect the dataset to confirm its structure and variable means.

nasdaq<- read.csv("Data/nasdaq_monthly.csv")
head(nasdaq)
##         Date IXIC.Open IXIC.High IXIC.Low IXIC.Close IXIC.Volume
## 1 2015-01-31   4760.24   4777.01  4563.11    4635.24 38719030000
## 2 2015-02-28   4650.60   4989.25  4580.46    4963.53 35773090000
## 3 2015-03-31   4973.43   5042.14  4825.93    4900.88 41204240000
## 4 2015-04-30   4894.36   5119.83  4844.39    4941.42 37409760000
## 5 2015-05-31   4966.32   5111.54  4888.17    5070.03 35994540000
## 6 2015-06-30   5094.94   5164.36  4956.23    4986.87 41338820000
str(nasdaq)
## 'data.frame':    135 obs. of  6 variables:
##  $ Date       : chr  "2015-01-31" "2015-02-28" "2015-03-31" "2015-04-30" ...
##  $ IXIC.Open  : num  4760 4651 4973 4894 4966 ...
##  $ IXIC.High  : num  4777 4989 5042 5120 5112 ...
##  $ IXIC.Low   : num  4563 4580 4826 4844 4888 ...
##  $ IXIC.Close : num  4635 4964 4901 4941 5070 ...
##  $ IXIC.Volume: num  3.87e+10 3.58e+10 4.12e+10 3.74e+10 3.60e+10 ...

The dataset contains the date variable and closing value of the NASDAQ Composite index. These are the variables required for the analysis.

Prepare data for prophet

Prophet requires the data to be stored as a dataframe with two specific coloumns: ‘ds’ for the dates and ’y’for the vairable being the forecast. I therefore convert the original dataset into to the correct format below.

prophet_data<- data.frame(ds = as.Date(nasdaq$Date),y = nasdaq$IXIC.Close)
head(prophet_data)
##           ds       y
## 1 2015-01-31 4635.24
## 2 2015-02-28 4963.53
## 3 2015-03-31 4900.88
## 4 2015-04-30 4941.42
## 5 2015-05-31 5070.03
## 6 2015-06-30 4986.87

This creates a clean dataframe than can be passed directly into the prophet model.

Visualising the historical time series

Before fitting a forecasting model, it is important, it is important to examine the historical behavior of the time series. The plot below shows the NASDAQ Composite over the sample period.

plot(prophet_data$ds, prophet_data$y,
     type="l",
     main="NASDAQ Composite Index",
     xlab="Year",
     ylab="Index Level")

The figure above shows the historical behaviour of the NASDAQ Composite index from 2015 to 2026 using monthly data. The index displays a strong upward trend over the sample period, reflecting the rapid growth of technology and growth-oriented firms listed on the NASDAQ exchange.

There are also periods of volatility, particularly around 2020 and 2022, which correspond to market disruptions and changes in macroeconomic conditions. Despite these fluctuations, the long-term pattern suggests a clear growth trend.

Forecasting Method: Prophet

To forecast the Nasdaq composite, I use Metas prophet model.Prophet is designed for time series with trend and possible seasonal structure, and it is especially useful because it produces forecasts in a straightforward and interpretable way.

The Prophet package is loaded first, after which the model is fitted to the prepared dataframe.

library(prophet)
## Loading required package: Rcpp
## Loading required package: rlang
nasdaq_model <- prophet(prophet_data)
## Disabling weekly seasonality. Run prophet with weekly.seasonality=TRUE to override this.
## Disabling daily seasonality. Run prophet with daily.seasonality=TRUE to override this.
nasdaq_model
## $growth
## [1] "linear"
## 
## $changepoints
##  [1] "2015-05-31 GMT" "2015-10-31 GMT" "2016-02-29 GMT" "2016-06-30 GMT"
##  [5] "2016-10-31 GMT" "2017-03-31 GMT" "2017-07-31 GMT" "2017-11-30 GMT"
##  [9] "2018-04-30 GMT" "2018-08-31 GMT" "2018-12-31 GMT" "2019-04-30 GMT"
## [13] "2019-09-30 GMT" "2020-01-31 GMT" "2020-05-31 GMT" "2020-09-30 GMT"
## [17] "2021-02-28 GMT" "2021-06-30 GMT" "2021-10-31 GMT" "2022-03-31 GMT"
## [21] "2022-07-31 GMT" "2022-11-30 GMT" "2023-03-31 GMT" "2023-08-31 GMT"
## [25] "2023-12-31 GMT"
## 
## $n.changepoints
## [1] 25
## 
## $changepoint.range
## [1] 0.8
## 
## $yearly.seasonality
## [1] "auto"
## 
## $weekly.seasonality
## [1] "auto"
## 
## $daily.seasonality
## [1] "auto"
## 
## $holidays
## NULL
## 
## $seasonality.mode
## [1] "additive"
## 
## $seasonality.prior.scale
## [1] 10
## 
## $changepoint.prior.scale
## [1] 0.05
## 
## $holidays.prior.scale
## [1] 10
## 
## $mcmc.samples
## [1] 0
## 
## $interval.width
## [1] 0.8
## 
## $uncertainty.samples
## [1] 1000
## 
## $backend
## [1] "rstan"
## 
## $specified.changepoints
## [1] FALSE
## 
## $start
## [1] "2015-01-31 GMT"
## 
## $y.scale
## [1] 23724.96
## 
## $logistic.floor
## [1] FALSE
## 
## $t.scale
## [1] 352252800
## 
## $changepoints.t
##  [1] 0.02943341 0.06696100 0.09663969 0.12656365 0.15673289 0.19376993
##  [7] 0.22369389 0.25361786 0.29065489 0.32082414 0.35074810 0.38018151
## [13] 0.41770910 0.44787834 0.47755703 0.50748099 0.54451803 0.57444199
## [19] 0.60461123 0.64164827 0.67157223 0.70149620 0.73117488 0.76870248
## [25] 0.79862644
## 
## $seasonalities
## $seasonalities$yearly
## $seasonalities$yearly$period
## [1] 365.25
## 
## $seasonalities$yearly$fourier.order
## [1] 10
## 
## $seasonalities$yearly$prior.scale
## [1] 10
## 
## $seasonalities$yearly$mode
## [1] "additive"
## 
## $seasonalities$yearly$condition.name
## NULL
## 
## 
## 
## $extra_regressors
## list()
## 
## $country_holidays
## NULL
## 
## $stan.fit
## $stan.fit$par
## $stan.fit$par$k
## [1] 0.5489922
## 
## $stan.fit$par$m
## [1] 0.1498381
## 
## $stan.fit$par$delta
##  [1]  1.463386e-08  2.742171e-09  7.537582e-09  1.524370e-09  5.355375e-07
##  [6]  1.926091e-04  1.404195e-04  4.908082e-04  7.644307e-03  3.711055e-02
## [11]  2.947143e-02  8.442359e-03  1.027719e-05  1.770116e-09  8.787396e-09
## [16] -2.115607e-09 -2.454071e-09 -4.968998e-09 -9.469884e-11  1.769042e-09
## [21]  3.027419e-09  1.419116e-01  2.072966e-01  2.091034e-01  1.611047e-01
## 
## $stan.fit$par$sigma_obs
## [1] 0.05651217
## 
## $stan.fit$par$beta
##  [1] -0.012828483 -0.004776658  0.057443641  0.014308063  0.021137118
##  [6] -0.044380877  0.005264196 -0.008867674 -0.012901534 -0.011959696
## [11] -0.008061714 -0.001283544 -0.017631537  0.005099914  0.004354757
## [16]  0.010328985  0.008728126  0.050146254  0.058267574  0.012964233
## 
## $stan.fit$par$trend
##   [1] 0.1498381 0.1536085 0.1577828 0.1618225 0.1659968 0.1700365 0.1742108
##   [8] 0.1783852 0.1824248 0.1865992 0.1906389 0.1948132 0.1989875 0.2028926
##  [15] 0.2070669 0.2111066 0.2152809 0.2193206 0.2234949 0.2276692 0.2317089
##  [22] 0.2358833 0.2399229 0.2440973 0.2482716 0.2520420 0.2562163 0.2602574
##  [29] 0.2644332 0.2684743 0.2726501 0.2768270 0.2808691 0.2850460 0.2890881
##  [36] 0.2932687 0.2974493 0.3012254 0.3054060 0.3094517 0.3136904 0.3177924
##  [43] 0.3220312 0.3262699 0.3306449 0.3351658 0.3395409 0.3440618 0.3488068
##  [50] 0.3530926 0.3578376 0.3624295 0.3672387 0.3718928 0.3767019 0.3815111
##  [57] 0.3861652 0.3909744 0.3956286 0.4004378 0.4052471 0.4097461 0.4145553
##  [64] 0.4192095 0.4240187 0.4286728 0.4334821 0.4382914 0.4429455 0.4477548
##  [71] 0.4524089 0.4572181 0.4620274 0.4663713 0.4711805 0.4758346 0.4806439
##  [78] 0.4852980 0.4901073 0.4949166 0.4995707 0.5043799 0.5090341 0.5138433
##  [85] 0.5186526 0.5229964 0.5278057 0.5324598 0.5372691 0.5419232 0.5467325
##  [92] 0.5515417 0.5561959 0.5610051 0.5656592 0.5715476 0.5774359 0.5827543
##  [99] 0.5886426 0.5958664 0.6033309 0.6105546 0.6180191 0.6254836 0.6342460
## [106] 0.6433004 0.6520628 0.6611173 0.6713967 0.6810130 0.6912924 0.7012402
## [113] 0.7115197 0.7214675 0.7317470 0.7420264 0.7519742 0.7622537 0.7722015
## [120] 0.7824810 0.7927604 0.8020451 0.8123245 0.8222723 0.8325518 0.8424996
## [127] 0.8527790 0.8630585 0.8730063 0.8832858 0.8932336 0.9035130 0.9137925
## [134] 0.9230771 0.9333566
## 
## 
## $stan.fit$value
## [1] 304.8103
## 
## $stan.fit$return_code
## [1] 0
## 
## $stan.fit$theta_tilde
##              k         m     delta[1]     delta[2]     delta[3]    delta[4]
## [1,] 0.5489922 0.1498381 1.463386e-08 2.742171e-09 7.537582e-09 1.52437e-09
##          delta[5]     delta[6]     delta[7]     delta[8]    delta[9]  delta[10]
## [1,] 5.355375e-07 0.0001926091 0.0001404195 0.0004908082 0.007644307 0.03711055
##       delta[11]   delta[12]    delta[13]    delta[14]    delta[15]
## [1,] 0.02947143 0.008442359 1.027719e-05 1.770116e-09 8.787396e-09
##          delta[16]     delta[17]     delta[18]     delta[19]    delta[20]
## [1,] -2.115607e-09 -2.454071e-09 -4.968998e-09 -9.469884e-11 1.769042e-09
##         delta[21] delta[22] delta[23] delta[24] delta[25]  sigma_obs
## [1,] 3.027419e-09 0.1419116 0.2072966 0.2091034 0.1611047 0.05651217
##          beta[1]      beta[2]    beta[3]    beta[4]    beta[5]     beta[6]
## [1,] -0.01282848 -0.004776658 0.05744364 0.01430806 0.02113712 -0.04438088
##          beta[7]      beta[8]     beta[9]   beta[10]     beta[11]     beta[12]
## [1,] 0.005264196 -0.008867674 -0.01290153 -0.0119597 -0.008061714 -0.001283544
##         beta[13]    beta[14]    beta[15]   beta[16]    beta[17]   beta[18]
## [1,] -0.01763154 0.005099914 0.004354757 0.01032899 0.008728126 0.05014625
##        beta[19]   beta[20]  trend[1]  trend[2]  trend[3]  trend[4]  trend[5]
## [1,] 0.05826757 0.01296423 0.1498381 0.1536085 0.1577828 0.1618225 0.1659968
##       trend[6]  trend[7]  trend[8]  trend[9] trend[10] trend[11] trend[12]
## [1,] 0.1700365 0.1742108 0.1783852 0.1824248 0.1865992 0.1906389 0.1948132
##      trend[13] trend[14] trend[15] trend[16] trend[17] trend[18] trend[19]
## [1,] 0.1989875 0.2028926 0.2070669 0.2111066 0.2152809 0.2193206 0.2234949
##      trend[20] trend[21] trend[22] trend[23] trend[24] trend[25] trend[26]
## [1,] 0.2276692 0.2317089 0.2358833 0.2399229 0.2440973 0.2482716  0.252042
##      trend[27] trend[28] trend[29] trend[30] trend[31] trend[32] trend[33]
## [1,] 0.2562163 0.2602574 0.2644332 0.2684743 0.2726501  0.276827 0.2808691
##      trend[34] trend[35] trend[36] trend[37] trend[38] trend[39] trend[40]
## [1,]  0.285046 0.2890881 0.2932687 0.2974493 0.3012254  0.305406 0.3094517
##      trend[41] trend[42] trend[43] trend[44] trend[45] trend[46] trend[47]
## [1,] 0.3136904 0.3177924 0.3220312 0.3262699 0.3306449 0.3351658 0.3395409
##      trend[48] trend[49] trend[50] trend[51] trend[52] trend[53] trend[54]
## [1,] 0.3440618 0.3488068 0.3530926 0.3578376 0.3624295 0.3672387 0.3718928
##      trend[55] trend[56] trend[57] trend[58] trend[59] trend[60] trend[61]
## [1,] 0.3767019 0.3815111 0.3861652 0.3909744 0.3956286 0.4004378 0.4052471
##      trend[62] trend[63] trend[64] trend[65] trend[66] trend[67] trend[68]
## [1,] 0.4097461 0.4145553 0.4192095 0.4240187 0.4286728 0.4334821 0.4382914
##      trend[69] trend[70] trend[71] trend[72] trend[73] trend[74] trend[75]
## [1,] 0.4429455 0.4477548 0.4524089 0.4572181 0.4620274 0.4663713 0.4711805
##      trend[76] trend[77] trend[78] trend[79] trend[80] trend[81] trend[82]
## [1,] 0.4758346 0.4806439  0.485298 0.4901073 0.4949166 0.4995707 0.5043799
##      trend[83] trend[84] trend[85] trend[86] trend[87] trend[88] trend[89]
## [1,] 0.5090341 0.5138433 0.5186526 0.5229964 0.5278057 0.5324598 0.5372691
##      trend[90] trend[91] trend[92] trend[93] trend[94] trend[95] trend[96]
## [1,] 0.5419232 0.5467325 0.5515417 0.5561959 0.5610051 0.5656592 0.5715476
##      trend[97] trend[98] trend[99] trend[100] trend[101] trend[102] trend[103]
## [1,] 0.5774359 0.5827543 0.5886426  0.5958664  0.6033309  0.6105546  0.6180191
##      trend[104] trend[105] trend[106] trend[107] trend[108] trend[109]
## [1,]  0.6254836   0.634246  0.6433004  0.6520628  0.6611173  0.6713967
##      trend[110] trend[111] trend[112] trend[113] trend[114] trend[115]
## [1,]   0.681013  0.6912924  0.7012402  0.7115197  0.7214675   0.731747
##      trend[116] trend[117] trend[118] trend[119] trend[120] trend[121]
## [1,]  0.7420264  0.7519742  0.7622537  0.7722015   0.782481  0.7927604
##      trend[122] trend[123] trend[124] trend[125] trend[126] trend[127]
## [1,]  0.8020451  0.8123245  0.8222723  0.8325518  0.8424996   0.852779
##      trend[128] trend[129] trend[130] trend[131] trend[132] trend[133]
## [1,]  0.8630585  0.8730063  0.8832858  0.8932336   0.903513  0.9137925
##      trend[134] trend[135]
## [1,]  0.9230771  0.9333566
## 
## 
## $params
## $params$k
## [1] 0.5489922
## 
## $params$m
## [1] 0.1498381
## 
## $params$delta
##              [,1]         [,2]         [,3]        [,4]         [,5]
## [1,] 1.463386e-08 2.742171e-09 7.537582e-09 1.52437e-09 5.355375e-07
##              [,6]         [,7]         [,8]        [,9]      [,10]      [,11]
## [1,] 0.0001926091 0.0001404195 0.0004908082 0.007644307 0.03711055 0.02947143
##            [,12]        [,13]        [,14]        [,15]         [,16]
## [1,] 0.008442359 1.027719e-05 1.770116e-09 8.787396e-09 -2.115607e-09
##              [,17]         [,18]         [,19]        [,20]        [,21]
## [1,] -2.454071e-09 -4.968998e-09 -9.469884e-11 1.769042e-09 3.027419e-09
##          [,22]     [,23]     [,24]     [,25]
## [1,] 0.1419116 0.2072966 0.2091034 0.1611047
## 
## $params$sigma_obs
## [1] 0.05651217
## 
## $params$beta
##             [,1]         [,2]       [,3]       [,4]       [,5]        [,6]
## [1,] -0.01282848 -0.004776658 0.05744364 0.01430806 0.02113712 -0.04438088
##             [,7]         [,8]        [,9]      [,10]        [,11]        [,12]
## [1,] 0.005264196 -0.008867674 -0.01290153 -0.0119597 -0.008061714 -0.001283544
##            [,13]       [,14]       [,15]      [,16]       [,17]      [,18]
## [1,] -0.01763154 0.005099914 0.004354757 0.01032899 0.008728126 0.05014625
##           [,19]      [,20]
## [1,] 0.05826757 0.01296423
## 
## $params$trend
##   [1] 0.1498381 0.1536085 0.1577828 0.1618225 0.1659968 0.1700365 0.1742108
##   [8] 0.1783852 0.1824248 0.1865992 0.1906389 0.1948132 0.1989875 0.2028926
##  [15] 0.2070669 0.2111066 0.2152809 0.2193206 0.2234949 0.2276692 0.2317089
##  [22] 0.2358833 0.2399229 0.2440973 0.2482716 0.2520420 0.2562163 0.2602574
##  [29] 0.2644332 0.2684743 0.2726501 0.2768270 0.2808691 0.2850460 0.2890881
##  [36] 0.2932687 0.2974493 0.3012254 0.3054060 0.3094517 0.3136904 0.3177924
##  [43] 0.3220312 0.3262699 0.3306449 0.3351658 0.3395409 0.3440618 0.3488068
##  [50] 0.3530926 0.3578376 0.3624295 0.3672387 0.3718928 0.3767019 0.3815111
##  [57] 0.3861652 0.3909744 0.3956286 0.4004378 0.4052471 0.4097461 0.4145553
##  [64] 0.4192095 0.4240187 0.4286728 0.4334821 0.4382914 0.4429455 0.4477548
##  [71] 0.4524089 0.4572181 0.4620274 0.4663713 0.4711805 0.4758346 0.4806439
##  [78] 0.4852980 0.4901073 0.4949166 0.4995707 0.5043799 0.5090341 0.5138433
##  [85] 0.5186526 0.5229964 0.5278057 0.5324598 0.5372691 0.5419232 0.5467325
##  [92] 0.5515417 0.5561959 0.5610051 0.5656592 0.5715476 0.5774359 0.5827543
##  [99] 0.5886426 0.5958664 0.6033309 0.6105546 0.6180191 0.6254836 0.6342460
## [106] 0.6433004 0.6520628 0.6611173 0.6713967 0.6810130 0.6912924 0.7012402
## [113] 0.7115197 0.7214675 0.7317470 0.7420264 0.7519742 0.7622537 0.7722015
## [120] 0.7824810 0.7927604 0.8020451 0.8123245 0.8222723 0.8325518 0.8424996
## [127] 0.8527790 0.8630585 0.8730063 0.8832858 0.8932336 0.9035130 0.9137925
## [134] 0.9230771 0.9333566
## 
## 
## $history
##             ds        y floor           t  y_scaled
## 1   2015-01-31  4635.24     0 0.000000000 0.1953740
## 2   2015-02-28  4963.53     0 0.006867795 0.2092113
## 3   2015-03-31  4900.88     0 0.014471425 0.2065706
## 4   2015-04-30  4941.42     0 0.021829777 0.2082794
## 5   2015-05-31  5070.03     0 0.029433407 0.2137002
## 6   2015-06-30  4986.87     0 0.036791759 0.2101951
## 7   2015-07-31  5128.28     0 0.044395389 0.2161555
## 8   2015-08-31  4776.51     0 0.051999019 0.2013285
## 9   2015-09-30  4620.16     0 0.059357371 0.1947384
## 10  2015-10-31  5053.75     0 0.066961001 0.2130140
## 11  2015-11-30  5108.67     0 0.074319352 0.2153289
## 12  2015-12-31  5007.41     0 0.081922983 0.2110608
## 13  2016-01-31  4613.95     0 0.089526613 0.1944766
## 14  2016-02-29  4557.95     0 0.096639686 0.1921162
## 15  2016-03-31  4869.85     0 0.104243316 0.2052627
## 16  2016-04-30  4775.36     0 0.111601668 0.2012800
## 17  2016-05-31  4948.05     0 0.119205298 0.2085588
## 18  2016-06-30  4842.67     0 0.126563650 0.2041171
## 19  2016-07-31  5162.13     0 0.134167280 0.2175822
## 20  2016-08-31  5213.22     0 0.141770910 0.2197357
## 21  2016-09-30  5312.00     0 0.149129262 0.2238992
## 22  2016-10-31  5189.14     0 0.156732892 0.2187207
## 23  2016-11-30  5323.68     0 0.164091244 0.2243915
## 24  2016-12-31  5383.12     0 0.171694874 0.2268969
## 25  2017-01-31  5614.79     0 0.179298504 0.2366617
## 26  2017-02-28  5825.44     0 0.186166299 0.2455405
## 27  2017-03-31  5911.74     0 0.193769929 0.2491781
## 28  2017-04-30  6047.61     0 0.201128281 0.2549049
## 29  2017-05-31  6198.52     0 0.208731911 0.2612658
## 30  2017-06-30  6140.42     0 0.216090262 0.2588169
## 31  2017-07-31  6348.12     0 0.223693893 0.2675714
## 32  2017-08-31  6428.66     0 0.231297523 0.2709661
## 33  2017-09-30  6495.96     0 0.238655874 0.2738028
## 34  2017-10-31  6727.67     0 0.246259505 0.2835693
## 35  2017-11-30  6873.97     0 0.253617856 0.2897358
## 36  2017-12-31  6903.39     0 0.261221486 0.2909758
## 37  2018-01-31  7411.48     0 0.268825117 0.3123917
## 38  2018-02-28  7273.01     0 0.275692911 0.3065552
## 39  2018-03-31  7063.45     0 0.283296542 0.2977223
## 40  2018-04-30  7066.27     0 0.290654893 0.2978412
## 41  2018-05-31  7442.12     0 0.298258523 0.3136831
## 42  2018-06-30  7510.30     0 0.305616875 0.3165569
## 43  2018-07-31  7671.79     0 0.313220505 0.3233637
## 44  2018-08-31  8109.54     0 0.320824135 0.3418147
## 45  2018-09-30  8046.35     0 0.328182487 0.3391512
## 46  2018-10-31  7305.90     0 0.335786117 0.3079415
## 47  2018-11-30  7330.54     0 0.343144469 0.3089801
## 48  2018-12-31  6635.28     0 0.350748099 0.2796751
## 49  2019-01-31  7281.74     0 0.358351729 0.3069232
## 50  2019-02-28  7532.53     0 0.365219524 0.3174939
## 51  2019-03-31  7729.32     0 0.372823154 0.3257885
## 52  2019-04-30  8095.39     0 0.380181506 0.3412183
## 53  2019-05-31  7453.15     0 0.387785136 0.3141480
## 54  2019-06-30  8006.24     0 0.395143488 0.3374606
## 55  2019-07-31  8175.42     0 0.402747118 0.3445915
## 56  2019-08-31  7962.88     0 0.410350748 0.3356330
## 57  2019-09-30  7999.34     0 0.417709100 0.3371698
## 58  2019-10-31  8292.36     0 0.425312730 0.3495205
## 59  2019-11-30  8665.47     0 0.432671082 0.3652470
## 60  2019-12-31  8972.60     0 0.440274712 0.3781924
## 61  2020-01-31  9150.94     0 0.447878342 0.3857094
## 62  2020-02-29  8567.37     0 0.454991415 0.3611121
## 63  2020-03-31  7700.10     0 0.462595045 0.3245569
## 64  2020-04-30  8889.55     0 0.469953397 0.3746919
## 65  2020-05-31  9489.87     0 0.477557027 0.3999952
## 66  2020-06-30 10058.77     0 0.484915379 0.4239741
## 67  2020-07-31 10745.27     0 0.492519009 0.4529099
## 68  2020-08-31 11775.46     0 0.500122639 0.4963321
## 69  2020-09-30 11167.51     0 0.507480991 0.4707072
## 70  2020-10-31 10911.59     0 0.515084621 0.4599202
## 71  2020-11-30 12198.74     0 0.522442973 0.5141732
## 72  2020-12-31 12888.28     0 0.530046603 0.5432372
## 73  2021-01-31 13070.69     0 0.537650233 0.5509257
## 74  2021-02-28 13192.35     0 0.544518028 0.5560536
## 75  2021-03-31 13246.87     0 0.552121658 0.5583516
## 76  2021-04-30 13962.68     0 0.559480010 0.5885228
## 77  2021-05-31 13748.74     0 0.567083640 0.5795053
## 78  2021-06-30 14503.95     0 0.574441992 0.6113372
## 79  2021-07-31 14672.68     0 0.582045622 0.6184491
## 80  2021-08-31 15259.24     0 0.589649252 0.6431724
## 81  2021-09-30 14448.58     0 0.597007604 0.6090033
## 82  2021-10-31 15498.39     0 0.604611234 0.6532525
## 83  2021-11-30 15537.69     0 0.611969585 0.6549090
## 84  2021-12-31 15644.97     0 0.619573216 0.6594308
## 85  2022-01-31 14239.88     0 0.627176846 0.6002067
## 86  2022-02-28 13751.40     0 0.634044641 0.5796174
## 87  2022-03-31 14220.52     0 0.641648271 0.5993906
## 88  2022-04-30 12334.64     0 0.649006623 0.5199014
## 89  2022-05-31 12081.39     0 0.656610253 0.5092270
## 90  2022-06-30 11028.74     0 0.663968604 0.4648581
## 91  2022-07-31 12390.69     0 0.671572234 0.5222639
## 92  2022-08-31 11816.20     0 0.679175865 0.4980493
## 93  2022-09-30 10575.62     0 0.686534216 0.4457592
## 94  2022-10-31 10988.15     0 0.694137846 0.4631472
## 95  2022-11-30 11468.00     0 0.701496198 0.4833728
## 96  2022-12-31 10466.48     0 0.709099828 0.4411590
## 97  2023-01-31 11584.55     0 0.716703458 0.4882853
## 98  2023-02-28 11455.54     0 0.723571253 0.4828476
## 99  2023-03-31 12221.91     0 0.731174883 0.5151499
## 100 2023-04-30 12226.58     0 0.738533235 0.5153467
## 101 2023-05-31 12935.29     0 0.746136865 0.5452186
## 102 2023-06-30 13787.92     0 0.753495217 0.5811567
## 103 2023-07-31 14346.02     0 0.761098847 0.6046804
## 104 2023-08-31 14034.97     0 0.768702477 0.5915698
## 105 2023-09-30 13219.32     0 0.776060829 0.5571904
## 106 2023-10-31 12851.24     0 0.783664459 0.5416759
## 107 2023-11-30 14226.22     0 0.791022811 0.5996309
## 108 2023-12-31 15011.35     0 0.798626441 0.6327239
## 109 2024-01-31 15164.01     0 0.806230071 0.6391585
## 110 2024-02-29 16091.92     0 0.813343144 0.6782696
## 111 2024-03-31 16379.46     0 0.820946775 0.6903893
## 112 2024-04-30 15657.82     0 0.828305126 0.6599724
## 113 2024-05-31 16735.02     0 0.835908756 0.7053761
## 114 2024-06-30 17732.60     0 0.843267108 0.7474238
## 115 2024-07-31 17599.40     0 0.850870738 0.7418095
## 116 2024-08-31 17713.62     0 0.858474368 0.7466237
## 117 2024-09-30 18189.17     0 0.865832720 0.7666681
## 118 2024-10-31 18095.15     0 0.873436350 0.7627052
## 119 2024-11-30 19218.17     0 0.880794702 0.8100401
## 120 2024-12-31 19310.79     0 0.888398332 0.8139440
## 121 2025-01-31 19627.44     0 0.896001962 0.8272907
## 122 2025-02-28 18847.28     0 0.902869757 0.7944072
## 123 2025-03-31 17299.29     0 0.910473387 0.7291599
## 124 2025-04-30 17446.34     0 0.917831739 0.7353580
## 125 2025-05-31 19113.77     0 0.925435369 0.8056397
## 126 2025-06-30 20369.73     0 0.932793721 0.8585780
## 127 2025-07-31 21122.45     0 0.940397351 0.8903049
## 128 2025-08-31 21455.55     0 0.948000981 0.9043450
## 129 2025-09-30 22660.01     0 0.955359333 0.9551126
## 130 2025-10-31 23724.96     0 0.962962963 1.0000000
## 131 2025-11-30 23365.69     0 0.970321315 0.9848568
## 132 2025-12-31 23241.99     0 0.977924945 0.9796429
## 133 2026-01-31 23461.82     0 0.985528575 0.9889087
## 134 2026-02-28 22668.21     0 0.992396370 0.9554583
## 135 2026-03-31 22716.13     0 1.000000000 0.9574781
## 
## $history.dates
##   [1] "2015-01-31 GMT" "2015-02-28 GMT" "2015-03-31 GMT" "2015-04-30 GMT"
##   [5] "2015-05-31 GMT" "2015-06-30 GMT" "2015-07-31 GMT" "2015-08-31 GMT"
##   [9] "2015-09-30 GMT" "2015-10-31 GMT" "2015-11-30 GMT" "2015-12-31 GMT"
##  [13] "2016-01-31 GMT" "2016-02-29 GMT" "2016-03-31 GMT" "2016-04-30 GMT"
##  [17] "2016-05-31 GMT" "2016-06-30 GMT" "2016-07-31 GMT" "2016-08-31 GMT"
##  [21] "2016-09-30 GMT" "2016-10-31 GMT" "2016-11-30 GMT" "2016-12-31 GMT"
##  [25] "2017-01-31 GMT" "2017-02-28 GMT" "2017-03-31 GMT" "2017-04-30 GMT"
##  [29] "2017-05-31 GMT" "2017-06-30 GMT" "2017-07-31 GMT" "2017-08-31 GMT"
##  [33] "2017-09-30 GMT" "2017-10-31 GMT" "2017-11-30 GMT" "2017-12-31 GMT"
##  [37] "2018-01-31 GMT" "2018-02-28 GMT" "2018-03-31 GMT" "2018-04-30 GMT"
##  [41] "2018-05-31 GMT" "2018-06-30 GMT" "2018-07-31 GMT" "2018-08-31 GMT"
##  [45] "2018-09-30 GMT" "2018-10-31 GMT" "2018-11-30 GMT" "2018-12-31 GMT"
##  [49] "2019-01-31 GMT" "2019-02-28 GMT" "2019-03-31 GMT" "2019-04-30 GMT"
##  [53] "2019-05-31 GMT" "2019-06-30 GMT" "2019-07-31 GMT" "2019-08-31 GMT"
##  [57] "2019-09-30 GMT" "2019-10-31 GMT" "2019-11-30 GMT" "2019-12-31 GMT"
##  [61] "2020-01-31 GMT" "2020-02-29 GMT" "2020-03-31 GMT" "2020-04-30 GMT"
##  [65] "2020-05-31 GMT" "2020-06-30 GMT" "2020-07-31 GMT" "2020-08-31 GMT"
##  [69] "2020-09-30 GMT" "2020-10-31 GMT" "2020-11-30 GMT" "2020-12-31 GMT"
##  [73] "2021-01-31 GMT" "2021-02-28 GMT" "2021-03-31 GMT" "2021-04-30 GMT"
##  [77] "2021-05-31 GMT" "2021-06-30 GMT" "2021-07-31 GMT" "2021-08-31 GMT"
##  [81] "2021-09-30 GMT" "2021-10-31 GMT" "2021-11-30 GMT" "2021-12-31 GMT"
##  [85] "2022-01-31 GMT" "2022-02-28 GMT" "2022-03-31 GMT" "2022-04-30 GMT"
##  [89] "2022-05-31 GMT" "2022-06-30 GMT" "2022-07-31 GMT" "2022-08-31 GMT"
##  [93] "2022-09-30 GMT" "2022-10-31 GMT" "2022-11-30 GMT" "2022-12-31 GMT"
##  [97] "2023-01-31 GMT" "2023-02-28 GMT" "2023-03-31 GMT" "2023-04-30 GMT"
## [101] "2023-05-31 GMT" "2023-06-30 GMT" "2023-07-31 GMT" "2023-08-31 GMT"
## [105] "2023-09-30 GMT" "2023-10-31 GMT" "2023-11-30 GMT" "2023-12-31 GMT"
## [109] "2024-01-31 GMT" "2024-02-29 GMT" "2024-03-31 GMT" "2024-04-30 GMT"
## [113] "2024-05-31 GMT" "2024-06-30 GMT" "2024-07-31 GMT" "2024-08-31 GMT"
## [117] "2024-09-30 GMT" "2024-10-31 GMT" "2024-11-30 GMT" "2024-12-31 GMT"
## [121] "2025-01-31 GMT" "2025-02-28 GMT" "2025-03-31 GMT" "2025-04-30 GMT"
## [125] "2025-05-31 GMT" "2025-06-30 GMT" "2025-07-31 GMT" "2025-08-31 GMT"
## [129] "2025-09-30 GMT" "2025-10-31 GMT" "2025-11-30 GMT" "2025-12-31 GMT"
## [133] "2026-01-31 GMT" "2026-02-28 GMT" "2026-03-31 GMT"
## 
## $train.holiday.names
## NULL
## 
## $train.component.cols
##    additive_terms yearly multiplicative_terms
## 1               1      1                    0
## 2               1      1                    0
## 3               1      1                    0
## 4               1      1                    0
## 5               1      1                    0
## 6               1      1                    0
## 7               1      1                    0
## 8               1      1                    0
## 9               1      1                    0
## 10              1      1                    0
## 11              1      1                    0
## 12              1      1                    0
## 13              1      1                    0
## 14              1      1                    0
## 15              1      1                    0
## 16              1      1                    0
## 17              1      1                    0
## 18              1      1                    0
## 19              1      1                    0
## 20              1      1                    0
## 
## $component.modes
## $component.modes$additive
## [1] "yearly"                    "additive_terms"           
## [3] "extra_regressors_additive" "holidays"                 
## 
## $component.modes$multiplicative
## [1] "multiplicative_terms"            "extra_regressors_multiplicative"
## 
## 
## $fit.kwargs
## list()
## 
## attr(,"class")
## [1] "prophet" "list"

Creating Future dates

To produce forecasts,Prophet needs a dataframe containing future dates. Here, I extend the series by twelve monthly periods.

future_dates<-make_future_dataframe(nasdaq_model,periods = 12,freq="month")
head(future_dates)
##           ds
## 1 2015-01-31
## 2 2015-02-28
## 3 2015-03-31
## 4 2015-04-30
## 5 2015-05-31
## 6 2015-06-30
nasdaq_forecast <- predict(nasdaq_model, future_dates)
head(nasdaq_forecast)
##           ds    trend additive_terms additive_terms_lower additive_terms_upper
## 1 2015-01-31 3554.903      210.57700            210.57700            210.57700
## 2 2015-02-28 3644.355      232.97340            232.97340            232.97340
## 3 2015-03-31 3743.391       22.64675             22.64675             22.64675
## 4 2015-04-30 3839.232     -349.43626           -349.43626           -349.43626
## 5 2015-05-31 3938.268     -261.72277           -261.72277           -261.72277
## 6 2015-06-30 4034.109      -26.50933            -26.50933            -26.50933
##       yearly yearly_lower yearly_upper multiplicative_terms
## 1  210.57700    210.57700    210.57700                    0
## 2  232.97340    232.97340    232.97340                    0
## 3   22.64675     22.64675     22.64675                    0
## 4 -349.43626   -349.43626   -349.43626                    0
## 5 -261.72277   -261.72277   -261.72277                    0
## 6  -26.50933    -26.50933    -26.50933                    0
##   multiplicative_terms_lower multiplicative_terms_upper yhat_lower yhat_upper
## 1                          0                          0   2095.179   5551.908
## 2                          0                          0   2142.821   5497.126
## 3                          0                          0   2014.284   5442.408
## 4                          0                          0   1728.687   5191.970
## 5                          0                          0   1959.119   5392.570
## 6                          0                          0   2282.175   5713.470
##   trend_lower trend_upper     yhat
## 1    3554.903    3554.903 3765.480
## 2    3644.355    3644.355 3877.329
## 3    3743.391    3743.391 3766.038
## 4    3839.232    3839.232 3489.796
## 5    3938.268    3938.268 3676.545
## 6    4034.109    4034.109 4007.600

Forecast results

The plot below shows the fitted model and the forecasted path for the NASDAQ Composite.

plot(nasdaq_model, nasdaq_forecast)

prophet_plot_components(nasdaq_model, nasdaq_forecast)
## Warning: `aes_string()` was deprecated in ggplot2 3.0.0.
## ℹ Please use tidy evaluation idioms with `aes()`.
## ℹ See also `vignette("ggplot2-in-packages")` for more information.
## ℹ The deprecated feature was likely used in the prophet package.
##   Please report the issue at <https://github.com/facebook/prophet/issues>.
## This warning is displayed once per session.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.

The figure above shows the forecast generated by the Prophet model. The black points represent the observed historical NASDAQ values, while the blue line represents the model’s fitted values and forecast. The shaded area around the forecast represents the uncertainty interval.

The model captures the strong upward trend observed in the NASDAQ Composite index over the sample period. The forecast suggests that the index may continue to increase over the next twelve months, although the widening uncertainty interval reflects the difficulty of predicting financial markets with precision.

Explanation

The components plot decomposes the Prophet model into its main elements. The trend component shows a strong upward movement in the NASDAQ Composite index over the sample period. This reflects the sustained growth of technology and innovation-driven firms listed on the NASDAQ exchange.

The yearly seasonality component captures small recurring fluctuations within each year. These seasonal patterns are relatively minor compared to the dominant long term upward trend in the index. This suggests that the NASDAQ is mainly driven by structural growth rather than strong seasonal effects.

Conclusion

This project analysed the NASDAQ Composite index using monthly historical data and Meta’s Prophet forecasting model. The time series analysis revealed a strong long term upward trend in the index, with some periods of volatility. The Prophet model successfully captured this trend and produced forecasts for the following year. While the model provides useful insights into the behaviour of the index, financial markets remain difficult to predict due to macroeconomic events, policy changes and investor sentiment.

limitations

Although Prophet provides a useful forecast, stock market indices are influenced by unexpected macroeconomic shocks, policy decisions and changes in investor sentiment. This means the model should be interpreted as a simplified projection rather than a precise prediction.

References

Yahoo Finance. NASDAQ Composite (^IXIC) historical data.