รายงานการศึกษาค่าคาดการณ์อัตราการว่างงานของประเทศไทย
87 #Evaluate Model #In-sample training accuracy fit |> accuracy() 2.2.3 อัตราการว่างงาน data |> autoplot(UNEM_RATE) #Fit Model for Train fit_train <- train |> model(ARIMA(log(UNEM_RATE) ~ COVID + GDPt, stepwise = FALSE, approx = FALSE)) report(fit_train) #Residual Check bind_rows( `Regression residuals` = as_tibble(residuals(fit_train, type = "regression")), `ARIMA residuals` = as_tibble(residuals(fit_train, 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_train |> gg_tsresiduals() augment(fit_train) |> features(.innov, ljung_box, dof = 5 , lag = 20) #Forecast Test Data ( 2020 Q 1 - 2022 Q 4) data_test <- new_data(train, 8) |> mutate(COVID = test$COVID) fit_train |> forecast(new_data = data_test) |> autoplot(data) + autolayer(fitted(fit_train),col="blue", linewidth = 0.02) + labs(title = "ARIMAX ~ covid", subtitle = "Train - Test", y = "Unemployment Rate") #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_RATE) ~ 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()
Made with FlippingBook
RkJQdWJsaXNoZXIy MTA3NzA0Nw==