st<- read.csv("C:\\Users\\sebastian\\Downloads\\entretainment_stocks.csv")
st
## Date Disney_Adj_Close Netflix_Adj_Close Nintendo_Adj_Close
## 1 1/1/2007 29.12 3.26 37.10
## 2 2/1/2007 28.36 3.22 33.10
## 3 3/1/2007 28.51 3.31 36.30
## 4 4/1/2007 28.96 3.17 40.05
## 5 5/1/2007 29.34 3.13 43.65
## 6 6/1/2007 28.65 2.77 45.85
## 7 7/1/2007 27.70 2.46 61.25
## 8 8/1/2007 28.20 2.50 58.15
## 9 9/1/2007 28.86 2.96 64.85
## 10 10/1/2007 29.07 3.78 78.50
## 11 11/1/2007 27.82 3.30 76.10
## 12 12/1/2007 27.09 3.80 74.05
## 13 1/1/2008 25.32 3.59 61.75
## 14 2/1/2008 27.50 4.51 62.40
## 15 3/1/2008 26.62 4.95 64.85
## 16 4/1/2008 27.51 4.57 68.69
## 17 5/1/2008 28.51 4.34 68.95
## 18 6/1/2008 26.47 3.72 69.85
## 19 7/1/2008 25.75 4.41 57.75
## 20 8/1/2008 27.45 4.41 61.10
## 21 9/1/2008 26.04 4.41 53.07
## 22 10/1/2008 21.98 3.54 39.00
## 23 11/1/2008 19.11 3.28 38.84
## 24 12/1/2008 19.25 4.27 47.75
## 25 1/1/2009 17.81 5.16 36.40
## 26 2/1/2009 14.44 5.18 35.25
## 27 3/1/2009 15.64 6.13 36.50
## 28 4/1/2009 18.86 6.47 33.65
## 29 5/1/2009 20.86 5.63 33.68
## 30 6/1/2009 20.09 5.91 34.47
## 31 7/1/2009 21.63 6.28 33.12
## 32 8/1/2009 22.42 6.23 33.55
## 33 9/1/2009 23.65 6.60 31.57
## 34 10/1/2009 23.57 7.64 31.41
## 35 11/1/2009 26.02 8.38 30.78
## 36 12/1/2009 27.77 7.87 29.82
## 37 1/1/2010 25.74 8.89 34.90
## 38 2/1/2010 27.21 9.44 33.87
## 39 3/1/2010 30.41 10.53 41.65
## 40 4/1/2010 32.09 14.13 41.90
## 41 5/1/2010 29.11 15.88 36.45
## 42 6/1/2010 27.44 15.52 37.27
## 43 7/1/2010 29.35 14.65 35.21
## 44 8/1/2010 28.34 17.93 34.75
## 45 9/1/2010 28.83 23.17 31.20
## 46 10/1/2010 31.47 24.80 32.15
## 47 11/1/2010 31.80 29.41 34.10
## 48 12/1/2010 32.67 25.10 36.33
## 49 1/1/2011 34.23 30.58 34.10
## 50 2/1/2011 38.52 29.52 36.65
## 51 3/1/2011 37.94 33.97 33.74
## 52 4/1/2011 37.95 33.24 29.79
## 53 5/1/2011 36.66 38.69 28.90
## 54 6/1/2011 34.38 37.53 23.30
## 55 7/1/2011 34.01 38.00 19.95
## 56 8/1/2011 29.99 33.57 21.98
## 57 9/1/2011 26.56 16.18 18.15
## 58 10/1/2011 30.71 11.73 18.90
## 59 11/1/2011 31.57 9.22 19.05
## 60 12/1/2011 33.02 9.90 16.94
## 61 1/1/2012 34.83 17.17 16.94
## 62 2/1/2012 37.60 15.82 18.51
## 63 3/1/2012 39.20 16.43 18.96
## 64 4/1/2012 38.60 11.45 16.72
## 65 5/1/2012 40.93 9.06 14.32
## 66 6/1/2012 43.42 9.78 14.52
## 67 7/1/2012 44.00 8.12 13.80
## 68 8/1/2012 44.29 8.53 13.93
## 69 9/1/2012 46.81 7.78 15.87
## 70 10/1/2012 43.98 11.32 16.15
## 71 11/1/2012 44.46 11.67 15.10
## 72 12/1/2012 44.58 13.23 13.31
## 73 1/1/2013 48.98 23.61 12.16
## 74 2/1/2013 49.63 26.87 12.06
## 75 3/1/2013 51.64 27.04 13.44
## 76 4/1/2013 57.13 30.87 13.75
## 77 5/1/2013 57.35 32.32 12.47
## 78 6/1/2013 57.41 30.16 14.67
## 79 7/1/2013 58.77 34.93 15.80
## 80 8/1/2013 55.30 40.56 14.09
## 81 9/1/2013 58.63 44.17 14.12
## 82 10/1/2013 62.36 46.07 14.01
## 83 11/1/2013 64.13 52.26 16.08
## 84 12/1/2013 69.46 52.60 16.68
## 85 1/1/2014 66.82 58.48 14.63
## 86 2/1/2014 74.37 63.66 15.40
## 87 3/1/2014 73.69 50.29 14.89
## 88 4/1/2014 73.02 46.01 13.08
## 89 5/1/2014 77.32 59.69 14.56
## 90 6/1/2014 78.91 62.94 14.95
## 91 7/1/2014 79.04 60.39 13.83
## 92 8/1/2014 82.72 68.23 13.89
## 93 9/1/2014 81.94 64.45 13.59
## 94 10/1/2014 84.10 56.11 13.67
## 95 11/1/2014 85.14 49.51 14.50
## 96 12/1/2014 86.69 48.80 12.95
## 97 1/1/2015 84.78 63.11 12.04
## 98 2/1/2015 97.00 67.84 13.34
## 99 3/1/2015 97.76 59.53 18.43
## 100 4/1/2015 101.33 79.50 21.04
## 101 5/1/2015 102.87 89.15 21.16
## 102 6/1/2015 106.38 93.85 20.98
## 103 7/1/2015 111.84 114.31 22.01
## 104 8/1/2015 95.51 115.03 25.62
## 105 9/1/2015 95.81 103.26 20.97
## 106 10/1/2015 106.62 108.38 20.22
## 107 11/1/2015 106.37 123.33 19.13
## 108 12/1/2015 98.51 114.38 17.26
## 109 1/1/2016 90.40 91.84 17.57
## 110 2/1/2016 90.12 93.41 17.39
## 111 3/1/2016 93.69 102.23 17.75
## 112 4/1/2016 97.42 90.03 17.06
## 113 5/1/2016 93.61 102.57 18.34
## 114 6/1/2016 92.29 91.48 17.78
## 115 7/1/2016 90.52 91.25 25.78
## 116 8/1/2016 89.77 97.45 27.28
## 117 9/1/2016 88.25 98.55 32.98
## 118 10/1/2016 88.08 124.87 30.09
## 119 11/1/2016 94.19 117.00 30.83
## 120 12/1/2016 99.04 123.80 25.95
## 121 1/1/2017 105.96 140.71 24.73
## 122 2/1/2017 105.42 142.13 26.11
## 123 3/1/2017 108.59 147.81 29.02
## 124 4/1/2017 110.70 152.20 31.68
## 125 5/1/2017 103.37 163.07 37.83
## 126 6/1/2017 101.75 149.41 41.82
## 127 7/1/2017 105.27 181.66 42.46
## 128 8/1/2017 97.63 174.71 41.63
## 129 9/1/2017 95.10 181.35 45.95
## 130 10/1/2017 94.36 196.43 48.65
## 131 11/1/2017 101.12 187.58 50.98
## 132 12/1/2017 103.72 191.96 45.07
## 133 1/1/2018 105.68 270.30 57.08
## 134 2/1/2018 100.32 291.38 57.05
## 135 3/1/2018 97.68 295.35 55.51
## 136 4/1/2018 97.57 312.46 52.48
## 137 5/1/2018 96.74 351.60 51.04
## 138 6/1/2018 101.93 391.43 40.79
## 139 7/1/2018 110.44 337.45 42.67
## 140 8/1/2018 109.82 367.68 44.95
## 141 9/1/2018 114.64 374.13 45.47
## 142 10/1/2018 112.57 301.78 39.13
## 143 11/1/2018 113.22 286.13 37.87
## 144 12/1/2018 107.49 267.66 33.10
## 145 1/1/2019 110.17 339.50 37.24
## 146 2/1/2019 111.48 358.10 34.25
## 147 3/1/2019 109.69 356.56 35.87
## 148 4/1/2019 135.32 370.54 43.08
## 149 5/1/2019 130.45 343.28 44.14
## 150 6/1/2019 137.95 367.32 45.77
## 151 7/1/2019 141.28 322.99 46.19
## 152 8/1/2019 136.44 293.75 47.25
## 153 9/1/2019 129.54 267.62 46.60
## 154 10/1/2019 129.15 287.41 46.52
## 155 11/1/2019 150.68 314.66 48.39
## 156 12/1/2019 143.77 323.57 49.90
## 157 1/1/2020 138.31 345.09 45.90
## 158 2/1/2020 117.65 369.03 41.98
## 159 3/1/2020 96.60 375.50 48.28
## 160 4/1/2020 108.15 419.85 51.44
## 161 5/1/2020 117.30 419.73 50.84
## 162 6/1/2020 111.51 455.04 55.90
## 163 7/1/2020 116.94 488.88 55.01
## 164 8/1/2020 131.87 529.56 67.37
## 165 9/1/2020 124.08 500.03 70.90
## 166 10/1/2020 121.25 475.74 67.73
## 167 11/1/2020 148.01 490.70 70.95
## 168 12/1/2020 181.18 540.73 80.52
## 169 1/1/2021 168.17 532.39 72.27
## 170 2/1/2021 189.04 538.85 77.12
## 171 3/1/2021 184.52 521.66 70.80
## 172 4/1/2021 186.02 513.47 71.89
## 173 5/1/2021 178.65 502.81 77.32
## 174 6/1/2021 175.77 528.21 72.53
## 175 7/1/2021 176.02 517.57 64.25
## 176 8/1/2021 181.30 569.19 60.08
## 177 9/1/2021 169.17 610.34 59.25
## 178 10/1/2021 169.07 690.31 55.25
## 179 11/1/2021 144.90 641.90 55.08
## 180 12/1/2021 154.89 602.44 58.37
## 181 1/1/2022 142.97 427.14 12.22
## 182 2/1/2022 148.46 394.52 12.71
## 183 3/1/2022 137.16 374.59 12.58
## 184 4/1/2022 111.63 190.36 11.40
## 185 5/1/2022 110.44 197.44 11.12
## 186 6/1/2022 94.40 174.87 10.76
## 187 7/1/2022 106.10 224.90 11.20
## 188 8/1/2022 112.08 223.56 10.22
## 189 9/1/2022 94.33 235.44 10.19
## 190 10/1/2022 106.54 291.88 10.12
## 191 11/1/2022 97.87 305.53 10.73
## 192 12/1/2022 86.88 294.88 10.42
## WBD_Adj_Close EA_Adj_Close Paramount_Adj_Close
## 1 8.47 49.48 22.05
## 2 8.21 49.90 21.48
## 3 9.78 49.84 21.64
## 4 11.11 49.89 22.64
## 5 11.95 48.36 23.70
## 6 11.75 46.83 23.90
## 7 12.12 48.13 22.75
## 8 12.84 52.39 22.60
## 9 14.74 55.41 22.60
## 10 14.57 60.48 20.75
## 11 12.50 55.61 19.84
## 12 12.85 57.80 19.89
## 13 11.87 46.88 18.40
## 14 11.53 46.80 16.66
## 15 10.84 49.40 16.29
## 16 11.83 50.93 17.02
## 17 13.38 49.68 15.92
## 18 11.22 43.97 14.56
## 19 10.16 42.73 12.22
## 20 10.34 48.30 12.08
## 21 7.28 36.61 11.07
## 22 6.97 22.54 7.37
## 23 7.67 18.86 5.06
## 24 7.24 15.87 6.22
## 25 7.41 15.28 4.55
## 26 7.93 16.14 3.40
## 27 8.19 18.00 3.06
## 28 9.70 20.14 5.69
## 29 11.47 22.75 5.96
## 30 11.50 21.49 5.59
## 31 12.52 21.25 6.66
## 32 13.25 18.03 8.41
## 33 14.76 18.85 9.79
## 34 14.05 18.05 9.61
## 35 16.33 16.71 10.46
## 36 15.67 17.57 11.47
## 37 15.16 16.11 10.60
## 38 15.92 16.41 10.64
## 39 17.27 18.47 11.42
## 40 19.79 19.17 13.33
## 41 19.24 16.34 11.97
## 42 18.25 14.25 10.63
## 43 19.73 15.76 12.20
## 44 19.29 15.07 11.41
## 45 22.25 16.28 13.09
## 46 22.83 15.67 14.02
## 47 20.84 14.76 13.95
## 48 21.31 16.21 15.78
## 49 19.93 15.43 16.47
## 50 22.03 18.60 19.81
## 51 20.39 19.33 20.79
## 52 22.62 19.97 20.99
## 53 22.26 24.16 23.26
## 54 20.93 23.35 23.71
## 55 20.34 22.02 22.86
## 56 21.60 22.35 20.93
## 57 19.22 20.24 17.02
## 58 22.21 23.11 21.65
## 59 21.45 22.95 21.85
## 60 20.94 20.39 22.77
## 61 21.91 18.39 23.99
## 62 23.84 16.17 25.18
## 63 25.86 16.32 28.56
## 64 27.81 15.22 28.21
## 65 25.60 13.48 26.97
## 66 27.59 12.22 27.70
## 67 25.87 10.91 28.36
## 68 28.02 13.19 30.80
## 69 30.46 12.56 30.80
## 70 30.16 12.22 27.56
## 71 30.87 14.66 30.60
## 72 32.44 14.37 32.36
## 73 35.45 15.57 35.60
## 74 37.48 17.35 37.03
## 75 40.24 17.52 39.85
## 76 40.28 17.43 39.17
## 77 40.30 22.75 42.36
## 78 39.47 22.75 41.82
## 79 40.74 25.85 45.33
## 80 39.61 26.36 43.84
## 81 43.14 25.28 47.32
## 82 45.41 25.98 50.85
## 83 44.59 21.94 50.35
## 84 46.20 22.70 54.80
## 85 40.77 26.13 50.59
## 86 42.58 28.29 57.79
## 87 42.26 28.71 53.24
## 88 38.78 28.01 49.85
## 89 39.33 34.76 51.45
## 90 37.96 35.50 53.63
## 91 43.54 33.25 49.14
## 92 43.72 37.45 51.27
## 93 37.80 35.24 46.27
## 94 35.35 40.54 47.01
## 95 34.90 43.47 47.58
## 96 34.45 46.53 47.98
## 97 28.99 54.29 47.65
## 98 32.30 56.59 51.38
## 99 30.76 58.21 52.71
## 100 32.36 57.49 54.15
## 101 33.94 62.11 53.79
## 102 33.26 65.81 48.37
## 103 33.02 70.81 46.72
## 104 26.60 65.46 39.53
## 105 26.03 67.05 34.86
## 106 29.44 71.32 40.79
## 107 31.14 67.08 44.26
## 108 26.68 68.01 41.32
## 109 27.59 63.88 41.77
## 110 25.00 63.57 42.55
## 111 28.63 65.42 48.45
## 112 27.31 61.21 49.31
## 113 27.85 75.95 48.69
## 114 25.23 74.97 48.01
## 115 25.09 75.53 46.19
## 116 25.51 80.38 45.13
## 117 26.92 84.51 48.42
## 118 26.11 77.70 50.25
## 119 27.09 78.42 53.89
## 120 27.41 77.94 56.47
## 121 28.35 82.56 57.41
## 122 28.76 85.60 58.68
## 123 29.09 88.59 61.74
## 124 28.78 93.83 59.41
## 125 26.50 112.15 54.54
## 126 25.83 104.62 56.93
## 127 24.60 115.53 58.93
## 128 22.21 120.24 57.35
## 129 21.29 116.83 51.92
## 130 18.88 118.36 50.38
## 131 19.02 105.24 50.33
## 132 22.38 103.97 52.97
## 133 25.07 125.64 51.88
## 134 24.32 122.41 47.71
## 135 21.43 119.98 46.28
## 136 23.65 116.75 44.46
## 137 21.09 129.55 45.52
## 138 27.50 139.55 50.81
## 139 26.58 127.41 47.77
## 140 27.83 112.23 48.09
## 141 32.00 119.24 52.11
## 142 32.39 90.03 52.19
## 143 30.72 83.20 49.30
## 144 24.74 78.09 39.78
## 145 28.38 91.28 45.17
## 146 28.90 94.78 45.85
## 147 27.02 100.57 43.40
## 148 30.90 93.67 46.99
## 149 27.26 92.11 44.25
## 150 30.70 100.21 45.74
## 151 30.31 91.54 47.39
## 152 27.60 92.71 38.69
## 153 26.63 96.80 37.14
## 154 26.96 95.40 33.29
## 155 32.94 99.96 37.30
## 156 32.74 106.39 38.77
## 157 29.26 106.80 31.53
## 158 25.70 100.32 22.73
## 159 19.44 99.13 12.94
## 160 22.42 113.07 16.19
## 161 21.75 121.60 19.45
## 162 21.10 130.68 21.87
## 163 21.10 140.15 24.70
## 164 22.07 138.02 26.38
## 165 21.77 129.05 26.54
## 166 20.24 118.58 27.29
## 167 26.91 126.42 33.70
## 168 30.09 142.11 35.59
## 169 41.42 141.90 46.64
## 170 53.03 132.75 62.02
## 171 43.46 134.14 43.37
## 172 37.66 140.96 39.56
## 173 32.11 141.81 40.91
## 174 30.68 142.70 43.59
## 175 29.01 143.00 39.70
## 176 28.84 144.24 40.20
## 177 25.38 141.47 38.32
## 178 23.44 139.48 35.34
## 179 23.27 123.54 30.20
## 180 23.54 131.17 29.45
## 181 27.91 131.28 31.67
## 182 28.05 128.74 28.98
## 183 24.92 125.20 35.79
## 184 18.15 116.98 27.77
## 185 18.45 137.40 32.74
## 186 13.42 120.55 23.54
## 187 15.00 130.22 22.77
## 188 13.24 125.89 22.52
## 189 11.50 114.99 18.33
## 190 13.00 125.17 17.83
## 191 11.40 129.96 19.54
## 192 9.48 121.60 16.42
#Installing libraries
library(readxl)
library(tidyverse)
library(ggplot2)
library(corrplot)
library(gmodels)
library(effects)
library(stargazer)
library(olsrr)
library(jtools)
library(fastmap)
library(Hmisc)
library(naniar)
library(glmnet)
library(caret)
library(car)
library(lmtest)
library(dplyr)
library(xts)
library(zoo)
library(tseries)
library(stats)
library(forecast)
library(astsa)
library(corrplot)
library(AER)
library(dynlm)
library(vars)
library(TSstudio)
library(tidyverse)
library(sarima)
library(stargazer)
library(forecast)
# setting time series format
st$date_y <- as.yearmon(st$Date, format="%m/%d/%Y")
Netflix <- ts(st$Netflix_Adj_Close,start=c(2007,1),end=c(2022,12),frequency=12)
plot(st$date_y,st$Netflix_Adj_Close,type="l",col="green",lwd=2,xlab="Time Period",ylab="Stock price",main="Netflix_Stock_Price")
Netflix_d<-decompose(Netflix)
plot(Netflix_d)
- Briefly comment on the following components: i. Do the time series
data show a trend? Based on the graph, if a positive trend can be seen
between the periods from 2015 to mid-2022, this tells us that the stock
had a good performance over time since, unlike each year, its increase
was maintained. We can infer that the drastic increase that occurred
during the periods was a consequence of COVID19, due to the total
confinement where people could not leave their homes to prevent the
virus from spreading through the respiratory tract. This allowed people
to be completely at home, which many streaming companies increased their
numbers due to the high demand for series, movies, documentaries, among
others, to pass the time during the pandemic. This positive increase had
an expiration date because in the graph at the beginning of 2023 we can
see a decline in the stock due to the incentive of people vaccinated by
the COVID vaccine, thus favoring face-to-face social interaction.
# Stationary Test
adf.test(st$Netflix_Adj_Close)
##
## Augmented Dickey-Fuller Test
##
## data: st$Netflix_Adj_Close
## Dickey-Fuller = -2.9019, Lag order = 5, p-value = 0.1987
## alternative hypothesis: stationary
# P-Value > 0.05. Fail to reject the H0. The time series data is non-stationary.
# Serial Autocorrelation
acf(st$Netflix_Adj_Close,main="Significant Autocorrelations")
# There is high serial autocorrelation despite the number of lags of the variable
plot(st$date_y,st$Netflix,type="l",col="red",lwd=2,xlab="Time Period",ylab="Netflix_Adj_Close",main="Netflix Stock Price")
plot(st$date_y,log(st$Netflix_Adj_Close),type="l",col="red",lwd=2,xlab="Time Period",ylab="Netflix_Adj_Close",main="Netflix Stock Price")
plot(diff(log(st$Netflix_Adj_Close)),type="l",ylab="First Order Difference",main = "Difference- Netflix Stock Price")
adf.test(log(st$Netflix_Adj_Close))
##
## Augmented Dickey-Fuller Test
##
## data: log(st$Netflix_Adj_Close)
## Dickey-Fuller = -2.314, Lag order = 5, p-value = 0.4447
## alternative hypothesis: stationary
# The p-value is 0.44, is smaller than 0.05 which this means is H0, stationary.
adf.test(diff(log(st$Netflix_Adj_Close)))
## Warning in adf.test(diff(log(st$Netflix_Adj_Close))): p-value smaller than
## printed p-value
##
## Augmented Dickey-Fuller Test
##
## data: diff(log(st$Netflix_Adj_Close))
## Dickey-Fuller = -6.0954, Lag order = 5, p-value = 0.01
## alternative hypothesis: stationary
# The p value is still smaller than 0.05 which this means is stationary.
# Estimate 3* different time series regression models.
# You might want to consider ARMA (p,q) and / or ARIMA (p,d,q).
# Model 1
Net_arima <- Arima(log(st$Netflix_Adj_Close), order = c(1, 1, 1))
print(Net_arima)
## Series: log(st$Netflix_Adj_Close)
## ARIMA(1,1,1)
##
## Coefficients:
## ar1 ma1
## 0.4445 -0.2920
## s.e. 0.3021 0.3205
##
## sigma^2 = 0.02406: log likelihood = 85.92
## AIC=-165.84 AICc=-165.71 BIC=-156.09
plot(Net_arima$residuals, main = "Arima (1,1,1) - Netflix Stock Price")
acf(Net_arima$residuals, main = "ACF - ARIMA (1,1,1) ")
Box.test(Net_arima$residuals, lag = 1, type = "Ljung-Box")
##
## Box-Ljung test
##
## data: Net_arima$residuals
## X-squared = 0.072524, df = 1, p-value = 0.7877
adf.test(Net_arima$residuals)
## Warning in adf.test(Net_arima$residuals): p-value smaller than printed p-value
##
## Augmented Dickey-Fuller Test
##
## data: Net_arima$residuals
## Dickey-Fuller = -6.4478, Lag order = 5, p-value = 0.01
## alternative hypothesis: stationary
# p-value is 0.1 being less than .05 so its stationary
# Model 2 ARIMA
Net_arima2<- Arima(st$Netflix_Adj_Clos, order = c(1, 1, 2))
print(Net_arima2)
## Series: st$Netflix_Adj_Clos
## ARIMA(1,1,2)
##
## Coefficients:
## ar1 ma1 ma2
## 0.4686 -0.3441 0.1161
## s.e. 0.2016 0.2085 0.0762
##
## sigma^2 = 700.9: log likelihood = -895.3
## AIC=1798.6 AICc=1798.81 BIC=1811.61
plot(Net_arima2$residuals, main = "ARIMA (1,1,2) - Netflix Stock Price")
acf(Net_arima2$residuals, main = "ACF - ARIMA (1,1,2) ")
Box.test(Net_arima2$residuals, lag = 1, type = "Ljung-Box")
##
## Box-Ljung test
##
## data: Net_arima2$residuals
## X-squared = 0.0026119, df = 1, p-value = 0.9592
adf.test(Net_arima2$residuals)
## Warning in adf.test(Net_arima2$residuals): p-value smaller than printed p-value
##
## Augmented Dickey-Fuller Test
##
## data: Net_arima2$residuals
## Dickey-Fuller = -7.3869, Lag order = 5, p-value = 0.01
## alternative hypothesis: stationary
# p-value is 0.01 meaning is still small for .05 is stationary
# Model 3 ARMA
summary(Net_arma<-arma(log(st$Netflix_Adj_Close),order=c(1,1)))
##
## Call:
## arma(x = log(st$Netflix_Adj_Close), order = c(1, 1))
##
## Model:
## ARMA(1,1)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.73942 -0.07764 0.01083 0.08273 0.52979
##
## Coefficient(s):
## Estimate Std. Error t value Pr(>|t|)
## ar1 0.990021 0.007347 134.746 <2e-16 ***
## ma1 0.125387 0.068350 1.834 0.0666 .
## intercept 0.063487 0.031922 1.989 0.0467 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Fit:
## sigma^2 estimated as 0.02343, Conditional Sum-of-Squares = 4.45, AIC = -169.81
## Profe, lo agregue como nota, porque tardaba muhco en ejecutar y alentaba mi computadora y dure 2 horas y no tuve exito en mostrarlo
## plot(Net_arma)
Exnetflix<-exp(Net_arma$fitted.values)
plot(Exnetflix)
Net_arma_residuals<-Net_arma$residuals
Box.test(Net_arma_residuals,lag=5,type="Ljung-Box")
##
## Box-Ljung test
##
## data: Net_arma_residuals
## X-squared = 4.11, df = 5, p-value = 0.5337
Net_arma$residuals <- na.omit(Net_arma$residuals)
adf.test(Net_arma$residuals)
## Warning in adf.test(Net_arma$residuals): p-value smaller than printed p-value
##
## Augmented Dickey-Fuller Test
##
## data: Net_arma$residuals
## Dickey-Fuller = -6.1715, Lag order = 5, p-value = 0.01
## alternative hypothesis: stationary
summary(Net_arma)
##
## Call:
## arma(x = log(st$Netflix_Adj_Close), order = c(1, 1))
##
## Model:
## ARMA(1,1)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.73942 -0.07764 0.01083 0.08273 0.52979
##
## Coefficient(s):
## Estimate Std. Error t value Pr(>|t|)
## ar1 0.990021 0.007347 134.746 <2e-16 ***
## ma1 0.125387 0.068350 1.834 0.0666 .
## intercept 0.063487 0.031922 1.989 0.0467 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Fit:
## sigma^2 estimated as 0.02343, Conditional Sum-of-Squares = 4.45, AIC = -169.81
Box.test(Net_arma_residuals, lag = 5, type = "Ljung-Box")
##
## Box-Ljung test
##
## data: Net_arma_residuals
## X-squared = 4.11, df = 5, p-value = 0.5337
adf.test(Net_arma$residuals)
## Warning in adf.test(Net_arma$residuals): p-value smaller than printed p-value
##
## Augmented Dickey-Fuller Test
##
## data: Net_arma$residuals
## Dickey-Fuller = -6.1715, Lag order = 5, p-value = 0.01
## alternative hypothesis: stationary
The p-value of Ljung box is 0.5337 this havng a grader result than 0.05, means that it does not have serial autocorrelation. ADF is telling us that ARMA is stationary since the p-value is 0.01 and its lower than 0.05.
AIC(Net_arima)
## [1] -165.843
fit_v_a1 <- fitted(Net_arima)
nr_arima1 <- sqrt(mean((fit_v_a1 - st$Netflix_Adj_Close)^2))
print(nr_arima1)
## [1] 230.8619
AIC(Net_arima2)
## [1] 1798.597
fit_v_a2 <- fitted(Net_arima2)
nr_arima2 <- sqrt(mean((fit_v_a2 - st$Netflix_Adj_Close)^2))
print(nr_arima2)
## [1] 26.19737
arma_a <- arima(log(st$Netflix_Adj_Close), order = c(1, 1, 1))
AICA <- AIC(arma_a)
AICA
## [1] -165.843
arma_a <- arima(log(st$Netflix_Adj_Close), order = c(1, 1, 1))
residual_arma <- arma_a$residuals
r_arma <- sqrt(mean((log(st$Netflix_Adj_Close) - residual_arma)^2))
print(r_arma)
## [1] 4.341687
AIC(Net_arima)
## [1] -165.843
AIC(Net_arima2)
## [1] 1798.597
Through the evaluation, 3 proposed models were analyzed, for the ARMA model the least AIC was -165.843 and in addition there were low RMSE values, these tell us that the model fits the information in a more precise way. With this model and information we generate a projection of the forecast 5 years into the future.
Netflix_Model_forecast<-forecast(Exnetflix,h=5)
## Warning in ets(object, lambda = lambda, biasadj = biasadj,
## allow.multiplicative.trend = allow.multiplicative.trend, : Missing values
## encountered. Using longest contiguous portion of time series
Netflix_Model_forecast
## Point Forecast Lo 80 Hi 80 Lo 95 Hi 95
## 193 308.3285 238.9173 377.7396 202.17325 414.4837
## 194 308.6563 209.8291 407.4835 157.51312 459.7995
## 195 308.9842 187.0056 430.9628 122.43399 495.5343
## 196 309.3120 167.3302 451.2938 92.16958 526.4544
## 197 309.6399 149.6018 469.6779 64.88276 554.3970
plot(Netflix_Model_forecast)
autoplot(Netflix_Model_forecast)
For the next 5 years, Netflix’s stock is expected to increase over time
because it has an upward increase, as the model expects the stock price
to continue increasing. This forecast helps us make decisions in a
financial sector since we can learn the behavior of a variable and thus
make supported investment decisions. The estimate of the share will be
constant with an increasing value starting its first year 308.3285, as
each year an increase in its value is expected.