รายงานการศึกษาค่าคาดการณ์อัตราการว่างงานของประเทศไทย
86 fit_train |> gg_tsresiduals() augment(fit_train) |> features(.innov, ljung_box, dof = 4 , lag = 20) #Forecast Test Data ( 2020 Q 1 - 2022 Q 4) data_test <- new_data(train, 8) |> mutate(COVID = test$COVID, GDPt = test$GDPt) fit_train |> forecast(new_data = data_test) |> autoplot(data) + autolayer(fitted(fit_train),col="blue", linewidth = 0.02) + labs(title = "ARIMAX ~ covid + GDPt ", subtitle = "Train - Test", y = "Unemployment") #Evaluate Model #In-sample training accuracy fit_train |> accuracy() #Out-of-sample forecast accuracy fit_train |> forecast(new_data = data_test) |> accuracy(test) # 100% Data #Fit Model fit <- data |> model(ARIMA(log(UNEM) ~ COVID+GDPt, stepwise = FALSE, approx = FALSE)) report(fit) #Residual Check bind_rows( `Regression residuals` = as_tibble(residuals(fit, type = "regression")), `ARIMA residuals` = as_tibble(residuals(fit, type = "innovation")), . id = "type" ) |> mutate( type = factor(type, levels=c( " Regression residuals", "ARIMA residuals")) ) |> ggplot(aes(x = Quarter, y = .resid)) + geom_line() + facet_grid(vars(type)) fit |> gg_tsresiduals() augment(fit) |> features(.innov, ljung_box, dof = 3 , lag = 20) #Forecast 2023 Q 1 - 2025 Q 4 ARIMAX ~ covid + GDPt #Forecast GDP 2023 Q 1 - 2025 Q 4 fit_GDP <- data |> model(ARIMA(GDPt, stepwise = FALSE, approx = FALSE)) report(fit_GDP) fit_GDP |> forecast(h= 12) |> autoplot(data) + labs(title = "GDP Forecast") f_GDP <- forecast(fit_GDP, h= 12) view(f_GDP) data_future <- new_data(data, 12) |> mutate(COVID = 0 , GDPt = f_GDP$.mean) fit |> forecast(new_data = data_future) |> autoplot(data) + autolayer(fitted(fit),col="blue", linewidth = 0.02) + labs(title = "ARIMAX ~ covid + GDPt", subtitle = "Forecast 2023 Q 1 - 2025 Q 4 " , y = "Unemployment") a <- forecast(fit, new_data = data_future) view(a)
Made with FlippingBook
RkJQdWJsaXNoZXIy MTA3NzA0Nw==