For this discussion I looked at the MU stock. Mu is the ticker for Micron Techonology, a manufacture of memory and storage products. It is a USA based technology supplier. We will only look at the closing price in the past 2 years.
Stock <- read.csv("../Downloads/Mu.csv")
stockprice <- ts(Stock[,5], start = decimal_date(as.Date("2018-10-24")), frequency = 252)
Stock price of MU from 2018 october to 2020 october. There is a general upward trend
Do not see seasonality in the stock price
Polar seasonal price also does not show seasonaility price change
Using lag 1 shows more correlation
#using bias ajdusted forecast (forecast median)
fc2 <- rwf(stockprice, drift=TRUE, lambda=0, h=30, level=80,
biasadj=TRUE)
res2 <- residuals(rwf(stockprice, drift=TRUE, lambda=0, h=30, level=80,
biasadj=TRUE))
res3 <- residuals(forecast(stockprice, h=30))
Using the drift model and bias adjusted model we see an upward trend. However, the residual shows a sign of correlation and left skew.
##
## Ljung-Box test
##
## data: Residuals from Random walk with drift
## Q* = 163.29, df = 100, p-value = 6.66e-05
##
## Model df: 1. Total lags used: 101
##
## Ljung-Box test
##
## data: Residuals from Random walk with drift
## Q* = 152.53, df = 100, p-value = 0.0005641
##
## Model df: 1. Total lags used: 101
forecast(stockprice, h=30)
## Point Forecast Lo 80 Hi 80 Lo 95 Hi 95
## 2020.815 52.19304 50.88693 53.49915 50.19552 54.19056
## 2020.819 51.17596 49.38020 52.97171 48.42958 53.92233
## 2020.823 50.65286 48.47488 52.83083 47.32193 53.98378
## 2020.827 51.11714 48.61466 53.61962 47.28993 54.94435
## 2020.831 52.34421 49.55472 55.13369 48.07805 56.61036
## 2020.835 54.10519 51.05559 57.15479 49.44123 58.76915
## 2020.839 53.71275 50.42354 57.00196 48.68234 58.74316
## 2020.843 52.97708 49.46457 56.48959 47.60516 58.34900
## 2020.847 53.24642 49.52398 56.96886 47.55344 58.93940
## 2020.851 53.16469 49.24354 57.08583 47.16781 59.16156
## 2020.855 52.41957 48.30931 56.52983 46.13347 58.70566
## 2020.859 52.04784 47.75680 56.33888 45.48526 58.61042
## 2020.863 50.88298 46.41846 55.34749 44.05509 57.71086
## 2020.867 51.30470 46.67321 55.93619 44.22145 58.38796
## 2020.870 51.81866 47.02600 56.61131 44.48893 59.14839
## 2020.874 52.77391 47.82534 57.72249 45.20573 60.34210
## 2020.878 51.88265 46.78292 56.98237 44.08329 59.68200
## 2020.882 50.04463 44.79811 55.29116 42.02076 58.06850
## 2020.886 49.64845 44.25912 55.03777 41.40618 57.89071
## 2020.890 49.90507 44.37663 55.43351 41.45005 58.36009
## 2020.894 50.71216 45.04801 56.37630 42.04960 59.37472
## 2020.898 50.36019 44.56353 56.15686 41.49496 59.22543
## 2020.902 51.26512 45.33890 57.19135 42.20174 60.32851
## 2020.906 51.75332 45.70031 57.80634 42.49603 61.01061
## 2020.910 50.75862 44.58142 56.93583 41.31141 60.20584
## 2020.914 50.46374 44.16480 56.76268 40.83034 60.09714
## 2020.918 51.69876 45.28039 58.11713 41.88271 61.51481
## 2020.922 50.26225 43.72663 56.79787 40.26689 60.25762
## 2020.926 51.28048 44.62967 57.93128 41.10895 61.45200
## 2020.930 49.32995 42.56593 56.09397 38.98528 59.67463
Using the forecast function above returns automatic ETS algorithm The residual plot shows no sign of correlation and normally distributed
## Warning in modeldf.default(object): Could not find appropriate degrees of
## freedom for this model.
```