Introduction


For this weeks assignment, I have decided to take a closer look into TSLA stock price, and see whether I can achieve some predicting power by using an ARIMA model. I will also compare this model to a traditional Holt’s Damped Method ETS model, and see which one preforms better.

Data <- read.csv("/Users/samuelsinger/Desktop/Time Series/Discussion 3/TSLA-4.csv")
# Convert Date variable to Date format
Data$Date <- as.Date(Data$Date, format = "%Y-%m-%d")
View(Data)

Data$Adj.Close <- as.numeric(Data$Adj.Close)

# Get the total number of observations in your dataset
num_observations <- nrow(Data)  # Assuming 'Data' is your dataset

# Create a sequence from 1 to the total number of observations
Data$Index <- seq(1, num_observations)

# Now 'new_variable' contains a sequence of numbers from 1 to the total number of observations


Data <- Data %>%
  mutate(TIME = yearmonth(Date)) %>%
  as_tsibble(index = Index)

Graphs

Data %>%
  autoplot(Adj.Close)+ 
   labs(title = "TSLA Closing Stock Price",
       subtitle = "All trading days between March 28th 2023 and March 28th 2024")

Data$DiffClose <- c(NA,diff(Data$Adj.Close))

Data %>%
  autoplot(DiffClose)+ 
   labs(title = "TSLA Closing Stock Price Delta",
       subtitle = "All trading days between March 28th 2023 and March 28th 2024")
## Warning: Removed 1 row containing missing values (`geom_line()`).


As we can see from the two above graphs, while TSLA looks stationary, an argument could be made that there is a cycle taking place. To demonstrate a graph that is stationary, I created a graph showing the daily delta between the price of TSLA at close. Fortunatly, I do not have to make this adjustment in my model, as ARIMA accounts for such things automatically.

Models

Model <- Data %>%
  model(ARIMA(Adj.Close))

report(Model)
## Series: Adj.Close 
## Model: ARIMA(0,1,0) 
## 
## sigma^2 estimated as 46.19:  log likelihood=-840.51
## AIC=1683.02   AICc=1683.03   BIC=1686.55
Data %>%
  filter(Index <= 200)%>%
  model(ARIMA(Adj.Close))%>%
  forecast(h = 60) %>%
  autoplot(Data %>%
             filter(Index <= 253))

Model2 <- Data %>%
  model("Damped Holt's Method" = ETS(Adj.Close ~ error("A") + trend("Ad") + season("N")))


report(Model2)
## Series: Adj.Close 
## Model: ETS(A,Ad,N) 
##   Smoothing parameters:
##     alpha = 0.9998997 
##     beta  = 0.02074272 
##     phi   = 0.8916343 
## 
##   Initial states:
##      l[0]      b[0]
##  199.3086 -3.058864
## 
##   sigma^2:  47.1479
## 
##      AIC     AICc      BIC 
## 2381.780 2382.121 2402.980
Data %>%
  filter(Index <= 200)%>%
  model("Damped Holt's Method" = ETS(Adj.Close ~ error("A") + trend("Ad") + season("N"))) %>%
  forecast(h = 60) %>%
  autoplot(Data %>%
             filter(Index <= 253))


The ARIMA model selected is the Random walk model with no drift. In simple terms, this model takes on the value of \(y_{t-1}\), and carries on with it.
The ETS model I selected is a traditional Damped Holt’s Method, which is an adjustment to the traditional naive forecasts, as it allows for a trend to be accounted for in the forecast. The dampening factor is useful because rather than simply continuing the trend, it “slows” the slope down.
Comparing the AIC, AICc, and BIC values clearly shows the dominance. of the ARIMA model over the ETS model.
Graphically, the forecasts seem fairly similar, however the downward sloping trend, as well as the dampening effect seems to be working against the fortunes of the ETS model.
Admittedly, TSLA is not a great time series to predict, as a lot of its fluctuations come from exogenous influences. However, if I were to choose, I would use the ARIMA model.