This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.
When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
summary(cars)
## speed dist
## Min. : 4.0 Min. : 2.00
## 1st Qu.:12.0 1st Qu.: 26.00
## Median :15.0 Median : 36.00
## Mean :15.4 Mean : 42.98
## 3rd Qu.:19.0 3rd Qu.: 56.00
## Max. :25.0 Max. :120.00
You can also embed plots, for example:
Note that the echo = FALSE
parameter was added to the
code chunk to prevent printing of the R code that generated the
plot.
#setup library package
library(tidyverse)
## Warning: package 'tidyverse' was built under R version 4.3.3
## Warning: package 'tibble' was built under R version 4.3.3
## Warning: package 'tidyr' was built under R version 4.3.3
## Warning: package 'readr' was built under R version 4.3.3
## Warning: package 'purrr' was built under R version 4.3.3
## Warning: package 'dplyr' was built under R version 4.3.3
## Warning: package 'stringr' was built under R version 4.3.3
## Warning: package 'forcats' was built under R version 4.3.3
## Warning: package 'lubridate' was built under R version 4.3.3
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr 1.1.4 ✔ readr 2.1.5
## ✔ forcats 1.0.0 ✔ stringr 1.5.1
## ✔ ggplot2 3.5.2 ✔ tibble 3.2.1
## ✔ lubridate 1.9.4 ✔ tidyr 1.3.1
## ✔ purrr 1.0.4
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(readxl)
## Warning: package 'readxl' was built under R version 4.3.3
library(ggplot2)
library(knitr)
## Warning: package 'knitr' was built under R version 4.3.3
library(corrplot)
## Warning: package 'corrplot' was built under R version 4.3.3
## corrplot 0.95 loaded
library(factoextra)
## Warning: package 'factoextra' was built under R version 4.3.3
## Welcome! Want to learn more? See two factoextra-related books at https://goo.gl/ve3WBa
theme_set(theme_minimal())
#Memuat Data
#Beberapa Indikator Popular dan Indikator Ekonomi Indonesia - World Bank Indicators
data <- read_excel("ID-WB_Indicators-Nett.xlsx", sheet = "Sheet3")
head(data)
## # A tibble: 6 × 19
## Periode POP.GROW POV.NAHC PRM.CMPT.ZS SEC.ENRR GDP.MKTP.KD.ZG GDP.DEFL.KD.ZG
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 2000 [YR… 1.43 19.1 0 56.2 4.92 20.4
## 2 2001 [YR… 1.39 18.4 95.4 56.9 3.64 14.3
## 3 2002 [YR… 1.36 18.2 97.3 58.4 4.50 5.90
## 4 2003 [YR… 1.32 17.4 99.5 61.6 4.78 5.49
## 5 2004 [YR… 1.27 16.7 98.7 64.0 5.03 8.55
## 6 2005 [YR… 1.28 16 99.0 62.6 5.69 14.3
## # ℹ 12 more variables: AGR.TOTL.ZS <dbl>, IND.TOTL.ZS <dbl>, EXP.GNFS.ZS <dbl>,
## # IMP.GNFS.ZS <dbl>, GDI.TOTL.ZS <dbl>, REV.XGRT.GD.ZS <dbl>,
## # MKT.LCAP.GD.ZS <dbl>, MIL.XPND.GD.ZS <dbl>, VAL.TECH.MF.ZS <dbl>,
## # VAL.TOTL.GD.ZS <dbl>, TDS.DECT.GN.ZS <dbl>, CPI.TOTL.ZG <dbl>
#Struktur Data
str(data)
## tibble [24 × 19] (S3: tbl_df/tbl/data.frame)
## $ Periode : chr [1:24] "2000 [YR2000]" "2001 [YR2001]" "2002 [YR2002]" "2003 [YR2003]" ...
## $ POP.GROW : num [1:24] 1.43 1.39 1.36 1.32 1.27 ...
## $ POV.NAHC : num [1:24] 19.1 18.4 18.2 17.4 16.7 16 17.8 16.6 15.4 14.1 ...
## $ PRM.CMPT.ZS : num [1:24] 0 95.4 97.3 99.5 98.7 ...
## $ SEC.ENRR : num [1:24] 56.2 56.9 58.4 61.6 64 ...
## $ GDP.MKTP.KD.ZG: num [1:24] 4.92 3.64 4.5 4.78 5.03 ...
## $ GDP.DEFL.KD.ZG: num [1:24] 20.45 14.3 5.9 5.49 8.55 ...
## $ AGR.TOTL.ZS : num [1:24] 15.7 16 16.3 15.2 14.3 ...
## $ IND.TOTL.ZS : num [1:24] 42 47.9 47.7 43.7 44.6 ...
## $ EXP.GNFS.ZS : num [1:24] 41 39 32.7 30.5 32.2 ...
## $ IMP.GNFS.ZS : num [1:24] 30.5 30.8 26.4 23.1 27.5 ...
## $ GDI.TOTL.ZS : num [1:24] 22.2 22.5 21.4 25.6 24.1 ...
## $ REV.XGRT.GD.ZS: num [1:24] 0 18.7 17.4 17.3 18.4 ...
## $ MKT.LCAP.GD.ZS: num [1:24] 16.2 14.3 15.4 23.3 28.5 ...
## $ MIL.XPND.GD.ZS: num [1:24] 0.684 0.573 0.7 0.909 0.946 ...
## $ VAL.TECH.MF.ZS: num [1:24] 0 0 0 0 0 0 0 0 0 0 ...
## $ VAL.TOTL.GD.ZS: num [1:24] 66.1 59.1 49.8 45.3 48.9 ...
## $ TDS.DECT.GN.ZS: num [1:24] 10.84 10.06 8.92 8.22 8.4 ...
## $ CPI.TOTL.ZG : num [1:24] 3.69 11.5 11.9 6.76 6.06 ...
summary(data)
## Periode POP.GROW POV.NAHC PRM.CMPT.ZS
## Length:24 Min. :0.7046 Min. : 0.00 Min. : 0.00
## Class :character 1st Qu.:1.0092 1st Qu.:10.03 1st Qu.: 99.15
## Mode :character Median :1.2638 Median :11.70 Median :102.45
## Mean :1.1572 Mean :12.82 Mean : 98.45
## 3rd Qu.:1.3032 3rd Qu.:16.62 3rd Qu.:105.28
## Max. :1.4324 Max. :19.10 Max. :109.71
## SEC.ENRR GDP.MKTP.KD.ZG GDP.DEFL.KD.ZG AGR.TOTL.ZS
## Min. :56.19 Min. :-2.066 Min. :-0.4017 Min. :12.40
## 1st Qu.:65.27 1st Qu.: 4.852 1st Qu.: 3.9398 1st Qu.:13.15
## Median :80.53 Median : 5.041 Median : 5.9500 Median :13.49
## Mean :79.30 Mean : 4.884 Mean : 7.9377 Mean :13.84
## 3rd Qu.:92.04 3rd Qu.: 5.591 3rd Qu.:11.9658 3rd Qu.:14.37
## Max. :99.10 Max. : 6.345 Max. :20.4475 Max. :16.32
## IND.TOTL.ZS EXP.GNFS.ZS IMP.GNFS.ZS GDI.TOTL.ZS
## Min. :38.24 Min. :17.33 Min. :15.64 Min. :21.40
## 1st Qu.:40.00 1st Qu.:21.35 1st Qu.:20.48 1st Qu.:25.32
## Median :42.71 Median :24.40 Median :23.50 Median :31.22
## Mean :43.08 Mean :26.32 Mean :23.50 Mean :29.73
## 3rd Qu.:46.61 3rd Qu.:30.62 3rd Qu.:25.81 3rd Qu.:33.79
## Max. :48.06 Max. :40.98 Max. :30.76 Max. :35.07
## REV.XGRT.GD.ZS MKT.LCAP.GD.ZS MIL.XPND.GD.ZS VAL.TECH.MF.ZS
## Min. : 0.000 Min. : 0.00 Min. :0.5711 Min. : 0.000
## 1st Qu.: 0.000 1st Qu.:27.18 1st Qu.:0.6728 1st Qu.: 0.000
## Median : 0.000 Median :42.36 Median :0.7237 Median : 8.045
## Mean : 4.447 Mean :36.22 Mean :0.7427 Mean : 5.319
## 3rd Qu.: 3.777 3rd Qu.:46.78 3rd Qu.:0.8105 3rd Qu.: 8.938
## Max. :19.788 Max. :51.27 Max. :0.9457 Max. :12.312
## VAL.TOTL.GD.ZS TDS.DECT.GN.ZS CPI.TOTL.ZG
## Min. :28.79 Min. : 3.579 Min. : 1.560
## 1st Qu.:35.31 1st Qu.: 4.757 1st Qu.: 3.684
## Median :40.30 Median : 6.272 Median : 5.245
## Mean :42.61 Mean : 6.528 Mean : 5.973
## 3rd Qu.:49.15 3rd Qu.: 7.691 3rd Qu.: 6.499
## Max. :66.05 Max. :10.837 Max. :13.109
#Periode = Periode Data (2000 s.d 2023)
#POP.GROW = Population growth (annual %)
#POV.NAHC = Poverty headcount ratio at national poverty lines (% of population)
#PRM.CMPT.ZS = Primary completion rate, total (% of relevant age group)
#SEC.ENRR = School enrollment, secondary (% gross)
#GDP.MKTP.KD.ZG = GDP growth (annual %)
#GDP.DEFL.KD.ZG = Inflation, GDP deflator (annual %)
#AGR.TOTL.ZS = Agriculture, forestry, and fishing, value added (% of GDP)
#IND.TOTL.ZS = Industry (including construction), value added (% of GDP)
#EXP.GNFS.ZS = Exports of goods and services (% of GDP)
#IMP.GNFS.ZS = Imports of goods and services (% of GDP)
#GDI.TOTL.ZS = Gross capital formation (% of GDP)
#REV.XGRT.GD.ZS = Revenue, excluding grants (% of GDP)
#MKT.LCAP.GD.ZS = Market capitalization of listed domestic companies (% of GDP)
#MIL.XPND.GD.ZS = Military expenditure (% of GDP)
#VAL.TECH.MF.ZS = High-technology exports (% of manufactured exports)
#VAL.TOTL.GD.ZS = Merchandise trade (% of GDP)
#TDS.DECT.GN.ZS = Total debt service (% of GNI)
#CPI.TOTL.ZG = Inflation, consumer prices (annual %)
#Pembersihan Kolom Periode
data <- data %>%
mutate(Tahun = as.numeric(str_extract(Periode, "\\d{4}")))
#Visualisasi Tren Beberapa Indikator Utama
data_long <- data %>%
pivot_longer(cols = -c(Periode, Tahun), names_to = "Indikator", values_to = "Nilai")
indikator_terpilih <- c("POP.GROW", "POV.NAHC", "GDP.MKTP.KD.ZG", "SEC.ENRR", "CPI.TOTL.ZG")
data_long %>%
filter(Indikator %in% indikator_terpilih) %>%
ggplot(aes(x = Tahun, y = Nilai, color = Indikator)) +
geom_line(size = 1) +
labs(title = "Tren Beberapa Indikator Sosial dan Ekonomi", y = "Nilai", x = "Tahun")
## Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.
## ℹ Please use `linewidth` instead.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.
#Korelasi Antar Variabel
cor_data <- data %>%
select(-Periode, -Tahun) %>%
cor()
# Plot korelasi
library(corrplot)
corrplot::corrplot(cor_data, method = "color", tl.cex = 0.6)
##Regresi Linear: Prediksi Kemiskinan Berdasarkan Indikator Lain
# Model regresi
model <- lm(POV.NAHC ~ GDP.MKTP.KD.ZG + POP.GROW + CPI.TOTL.ZG + SEC.ENRR, data = data)
summary(model)
##
## Call:
## lm(formula = POV.NAHC ~ GDP.MKTP.KD.ZG + POP.GROW + CPI.TOTL.ZG +
## SEC.ENRR, data = data)
##
## Residuals:
## Min 1Q Median 3Q Max
## -12.2674 0.0840 0.4217 0.8746 3.4347
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 42.7578 16.9970 2.516 0.0210 *
## GDP.MKTP.KD.ZG -0.3004 0.4396 -0.684 0.5025
## POP.GROW -6.2456 7.4976 -0.833 0.4152
## CPI.TOTL.ZG 0.1763 0.2893 0.609 0.5495
## SEC.ENRR -0.2812 0.1155 -2.435 0.0249 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 3.06 on 19 degrees of freedom
## Multiple R-squared: 0.59, Adjusted R-squared: 0.5037
## F-statistic: 6.835 on 4 and 19 DF, p-value: 0.001384
# Diagnostik model
par(mfrow = c(2,2))
plot(model)