รายงานการศึกษาค่าคาดการณ์อัตราการว่างงานของประเทศไทย
84 #Evaluate Model #In-sample training accuracy fit |> accuracy() 2.2 ชุดคำสั่งการพยากรณ์รายไตรมาส data <- Dataset |> mutate(Quarter = yearquarter(Qtr)) |> select(-Qtr) |> as_tsibble(index = Quarter) #Split Train-Test train <- data |> filter(year(Quarter) <= 2020) test <- data |> filter(year(Quarter) > 2020) 2.2.1 กำลังแรงงานรวม data |> autoplot(LF) #Fit Model for Train fit_train <- train |> model(ARIMA(LF ~ COVID+GDPt_ 3 , 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 = 3 , lag = 20) #Forecast Test Data ( 2020 Q 1 - 2022 Q 4) data_test <- new_data(train, 8) |> mutate(COVID = test$COVID, GDPt_ 3 = test$GDPt_ 3) fit_train |> forecast(new_data = data_test) |> autoplot(data) + autolayer(fitted(fit_train),col="blue", linewidth = 0.02) + labs(title = "ARIMAX ~ covid + GDPt_ 3 " , subtitle = "Train - Test", y = "Labourforce") #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(LF ~ COVID+GDPt_ 3 , stepwise = FALSE, approx = FALSE)) report(fit)
Made with FlippingBook
RkJQdWJsaXNoZXIy MTA3NzA0Nw==