# https://stackoverflow.com/questions/72332262/forecasting-irregular-stock-data-with-arima-and-tsibblepacman::p_load("tidyquant", "tsibble", "fable", "feasts","tsibbledata", "fable.prophet", "tidyverse")# Set symbol and date rangesymbol <-"MCD"company <-"McDonald's"date_start <-"2020-01-01"date_end <-"2024-01-01"# Fetch stock prices (can be used to get new data)stock_df <-tq_get(symbol, from = date_start, to = date_end, get ="stock.prices")# Transform data into tibblestock_ts <- stock_df |>select(date, adjusted) |>rename(value = adjusted) |>tsibble(index = date, regular =TRUE) |>fill_gaps() |> tidyr::fill(value, .direction ="down") |>mutate(diff = value -lag(value))stock_ts |>ACF(var = value) |>autoplot()
stock_ts |>ACF(var = diff) |>autoplot()
# acf(stock_ts$value, plot=TRUE, type = "correlation", lag.max = 25)