Indeks Pembangunan Manusia atau Human Development Index adalah pengukuran perbandingan dari harapan hidup, melek huruf, pendidikan dan standar hidup. Pada bagian ini, saya akan melakukan pendeteksian autokorelasi terhadap data IPM Provinsi Kalimantan Timur selama 12 tahun terakhir beserta penanganannya (apabila terdapat autokorelasi).
library(dplyr)
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
library(readxl)
library(forecast)
## Registered S3 method overwritten by 'quantmod':
## method from
## as.zoo.data.frame zoo
library(TTR)
library(tseries)
library(lmtest) #uji-Durbin Watson
## Loading required package: zoo
##
## Attaching package: 'zoo'
## The following objects are masked from 'package:base':
##
## as.Date, as.Date.numeric
library(orcutt) #Cochrane-Orcutt
library(HoRM)#Hildreth Lu
library(ggplot2)
#membuka file data
dataregresi <- read_excel("C:/SEMESTER 5/MPDW/dataregkaltim.xlsx")
knitr::kable(dataregresi,align = "c")
| x | y |
|---|---|
| 2010 | 71.31 |
| 2011 | 72.02 |
| 2012 | 72.62 |
| 2013 | 73.21 |
| 2014 | 73.82 |
| 2015 | 74.17 |
| 2016 | 74.59 |
| 2017 | 75.12 |
| 2018 | 75.83 |
| 2019 | 76.61 |
| 2020 | 76.24 |
| 2021 | 76.88 |
x <- dataregresi$x
y <- dataregresi$y
#diagram pencar identifikasi model
ggplot(dataregresi, aes(x=x, y=y)) +
geom_line(lwd=1.2,col="blue") +
labs(x="Tahun",y="IPM_Kaltim",
title="Time Series Plot IPM Kaltim",
subtitle = "Tahun 2010-2021") +
theme_bw()+
theme(plot.title = element_text(size = 14L,
face = "bold",
hjust = 0.5),
plot.subtitle = element_text(size = 11L,
hjust = 0.5))+
geom_point(size=2) +
geom_text(aes(label=paste(y, "%")), vjust=-0.8, size=3)
#korelasi x dan y
cor(x,y)
## [1] 0.9913687
Model Regresi Deret Waktu
#model regresi
model <- lm(y~x, data = dataregresi)
summary(model)
##
## Call:
## lm(formula = y ~ x, data = dataregresi)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.40351 -0.12214 0.00726 0.12866 0.47209
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -944.65719 42.61522 -22.17 7.83e-10 ***
## x 0.50559 0.02114 23.91 3.72e-10 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.2528 on 10 degrees of freedom
## Multiple R-squared: 0.9828, Adjusted R-squared: 0.9811
## F-statistic: 571.8 on 1 and 10 DF, p-value: 3.719e-10
#sisaan dan fitted value
resi1 <- residuals(model)
fit <- predict(model)
#Diagnostik dengan eksploratif
par(mfrow = c(2,2))
qqnorm(resi1)
qqline(resi1, col = "steelblue", lwd = 2)
plot(fit, resi1, col = "steelblue", pch = 20, xlab = "Sisaan",
ylab = "Fitted Values", main = "Sisaan vs Fitted Values")
abline(a = 0, b = 0, lwd = 2)
hist(resi1, col = "steelblue")
plot(seq(1,12,1), resi1, col = "steelblue", pch = 20,
xlab = "Sisaan", ylab = "Order", main = "Sisaan vs Order")
lines(seq(1,12,1), resi1, col = "red")
abline(a = 0, b = 0, lwd = 2)
#ACF dan PACF identifikasi autokorelasi
par(mfrow = c(2,1))
acf(resi1)
pacf(resi1)
#Berdasarkna Plot ACF dan PACF dapat disimpulkan sisaan Saling Bebas
H0: tidak ada autokorelasi
H1: ada autokorelasi
lmtest::dwtest(model, alternative = 'two.sided')
##
## Durbin-Watson test
##
## data: model
## DW = 1.5684, p-value = 0.2418
## alternative hypothesis: true autocorrelation is not 0
H0: tidak ada autokorelasi
H1: ada autokorelasi
lmtest::bgtest(y ~ x, data=dataregresi, order=1)
##
## Breusch-Godfrey test for serial correlation of order up to 1
##
## data: y ~ x
## LM test = 0.13912, df = 1, p-value = 0.7092
lawstat::runs.test(resid(model), alternative = 'two.sided')
##
## Runs Test - Two sided
##
## data: resid(model)
## Standardized Runs Statistic = -1.2111, p-value = 0.2259
Berdasarkan hasil uji statistik Durbin Watson Test, Breusch-Godfrey Test, dan Run’s Test ketiganya memberikan hasil nilai p-value > 0.05, sehingga Tak Tolak H0 yang berarti belum cukup bukti untuk menyatakan bahwa terdapat autokorelasi pada taraf 5%. Dengan demikian, tidak perlu dilakukan penanganan autokorelasi terhadap data IPM Kalimantan Timur.