# 1. Load package
library(readxl)
## Warning: package 'readxl' was built under R version 4.4.3
library(forecast)
## Warning: package 'forecast' was built under R version 4.4.3
## Registered S3 method overwritten by 'quantmod':
## method from
## as.zoo.data.frame zoo
library(tseries)
## Warning: package 'tseries' was built under R version 4.4.3
library(ggplot2)
## Warning: package 'ggplot2' was built under R version 4.4.3
# 2. Import data
data <- read_excel("C:/Users/ASUS/Downloads/UR_LFPR_Jateng_TimeSeries_2017_2025.xlsx")
# Melihat struktur data
str(data)
## tibble [16 × 3] (S3: tbl_df/tbl/data.frame)
## $ Periode: chr [1:16] "2017-02" "2017-08" "2018-02" "2018-08" ...
## $ UR : chr [1:16] "4.15" "4.57" "4.19" "4.47" ...
## $ LFPR : chr [1:16] "70.2" "69.11" "69.86" "68.81" ...
head(data)
## # A tibble: 6 × 3
## Periode UR LFPR
## <chr> <chr> <chr>
## 1 2017-02 4.15 70.2
## 2 2017-08 4.57 69.11
## 3 2018-02 4.19 69.86
## 4 2018-08 4.47 68.81
## 5 2019-02 4.19 70.45
## 6 2019-08 4.44 68.85
# 3. Mengubah tipe data menjadi numerik
data$UR <- as.numeric(data$UR)
data$LFPR <- as.numeric(data$LFPR)
str(data)
## tibble [16 × 3] (S3: tbl_df/tbl/data.frame)
## $ Periode: chr [1:16] "2017-02" "2017-08" "2018-02" "2018-08" ...
## $ UR : num [1:16] 4.15 4.57 4.19 4.47 4.19 4.44 4.2 6.48 5.96 5.95 ...
## $ LFPR : num [1:16] 70.2 69.1 69.9 68.8 70.5 ...
# 4. Statistik Deskriptif
summary(data$UR)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 4.150 4.298 4.615 4.955 5.615 6.480
summary(data$LFPR)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 68.81 69.42 70.33 70.66 71.80 74.36
# 5. Membentuk Data Time Series
ur <- ts(
data$UR,
start = c(2017,1),
frequency = 2
)
lfpr <- ts(
data$LFPR,
start = c(2017,1),
frequency = 2
)
# 6. Visualisasi Data
autoplot(ur) +
ggtitle("Tingkat Pengangguran Terbuka Jawa Tengah") +
xlab("Tahun") +
ylab("UR (%)")

autoplot(lfpr) +
ggtitle("Tingkat Partisipasi Angkatan Kerja Jawa Tengah") +
xlab("Tahun") +
ylab("LFPR (%)")

# 7. Uji Stasioneritas
adf.test(ur)
##
## Augmented Dickey-Fuller Test
##
## data: ur
## Dickey-Fuller = -1.2095, Lag order = 2, p-value = 0.8735
## alternative hypothesis: stationary
# Differencing pertama
ur_diff <- diff(ur)
plot(ur_diff)

adf.test(ur_diff)
##
## Augmented Dickey-Fuller Test
##
## data: ur_diff
## Dickey-Fuller = -2.0709, Lag order = 2, p-value = 0.5454
## alternative hypothesis: stationary
# Differencing kedua
ur_diff2 <- diff(ur, differences = 2)
plot(ur_diff2)

adf.test(ur_diff2)
##
## Augmented Dickey-Fuller Test
##
## data: ur_diff2
## Dickey-Fuller = -2.7511, Lag order = 2, p-value = 0.2862
## alternative hypothesis: stationary
# 8. Plot ACF dan PACF
acf(ur)

pacf(ur)

acf(ur_diff)

pacf(ur_diff)

# 9. Korelasi antara UR dan LFPR
cor(data$UR, data$LFPR)
## [1] -0.06849481
cor.test(
data$UR,
data$LFPR
)
##
## Pearson's product-moment correlation
##
## data: data$UR and data$LFPR
## t = -0.25689, df = 14, p-value = 0.801
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
## -0.5456728 0.4422255
## sample estimates:
## cor
## -0.06849481
# Scatter Plot
ggplot(data,
aes(x = LFPR,
y = UR)) +
geom_point(size = 3) +
geom_smooth(method = "lm") +
ggtitle("Hubungan LFPR dan UR")
## `geom_smooth()` using formula = 'y ~ x'

# 10. Pemodelan ARIMAX
model <- auto.arima(
ur,
xreg = lfpr,
seasonal = FALSE,
stepwise = FALSE,
approximation = FALSE
)
summary(model)
## Series: ur
## Regression with ARIMA(0,1,0) errors
##
## Coefficients:
## xreg
## -0.2387
## s.e. 0.1210
##
## sigma^2 = 0.3975: log likelihood = -13.85
## AIC=31.7 AICc=32.7 BIC=33.11
##
## Training set error measures:
## ME RMSE MAE MPE MAPE MASE
## Training set 0.09523254 0.5897868 0.3503212 1.414012 6.480395 0.6600937
## ACF1
## Training set -0.2435486
# 11. Diagnostik Residual
checkresiduals(model)

##
## Ljung-Box test
##
## data: Residuals from Regression with ARIMA(0,1,0) errors
## Q* = 2.7958, df = 3, p-value = 0.4242
##
## Model df: 0. Total lags used: 3
# 12. Evaluasi Model
accuracy(model)
## ME RMSE MAE MPE MAPE MASE
## Training set 0.09523254 0.5897868 0.3503212 1.414012 6.480395 0.6600937
## ACF1
## Training set -0.2435486
# 13. Forecast Tahun Berikutnya
future_lfpr <- c(74.8, 75.1)
forecast_result <- forecast(
model,
xreg = future_lfpr,
h = 2
)
forecast_result
## Point Forecast Lo 80 Hi 80 Lo 95 Hi 95
## 2025.00 4.554991 3.746961 5.363020 3.319216 5.790765
## 2025.50 4.483393 3.340667 5.626119 2.735744 6.231042
# Grafik Forecast
plot(forecast_result)

# 14. Mengubah Forecast Menjadi Tabel
hasil_forecast <- data.frame(
Periode = c("Februari 2026",
"Agustus 2026"),
Forecast = forecast_result$mean,
Lower80 = forecast_result$lower[,1],
Upper80 = forecast_result$upper[,1],
Lower95 = forecast_result$lower[,2],
Upper95 = forecast_result$upper[,2]
)
hasil_forecast
## Periode Forecast Lower80 Upper80 Lower95 Upper95
## 1 Februari 2026 4.554991 3.746961 5.363020 3.319216 5.790765
## 2 Agustus 2026 4.483393 3.340667 5.626119 2.735744 6.231042
# 15. Menyimpan Hasil Forecast
write.csv(
hasil_forecast,
"hasil_forecast_2026.csv",
row.names = FALSE
)