TUGAS KELOMPOK STA1353 - ADP (CME)

library(performance)
library(readxl)
library(plm)
library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:plm':
## 
##     between, lag, lead
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
library(data.table)
## 
## Attaching package: 'data.table'
## The following objects are masked from 'package:dplyr':
## 
##     between, first, last
## The following object is masked from 'package:plm':
## 
##     between
# DATA

data <- read_excel("C:/SEMESTER 6/ADP/data.xlsx", sheet="asean all years")
head(data)
## # A tibble: 6 × 7
##   Country           C.Code  Year    GDP      P   Emp   FCE
##   <chr>             <chr>  <dbl>  <dbl>  <dbl> <dbl> <dbl>
## 1 Brunei Darussalam BRN     2007 32337. 378748  62.8  42.8
## 2 Brunei Darussalam BRN     2008 37427. 384568  62.6  34.8
## 3 Brunei Darussalam BRN     2009 27497. 390311  62.4  47.6
## 4 Brunei Darussalam BRN     2010 34610. 396053  62.0  36.9
## 5 Brunei Darussalam BRN     2011 46140. 401506  61.8  31.5
## 6 Brunei Darussalam BRN     2012 46843. 406634  61.2  32.2
str(data)
## tibble [150 × 7] (S3: tbl_df/tbl/data.frame)
##  $ Country: chr [1:150] "Brunei Darussalam" "Brunei Darussalam" "Brunei Darussalam" "Brunei Darussalam" ...
##  $ C.Code : chr [1:150] "BRN" "BRN" "BRN" "BRN" ...
##  $ Year   : num [1:150] 2007 2008 2009 2010 2011 ...
##  $ GDP    : num [1:150] 32337 37427 27497 34610 46140 ...
##  $ P      : num [1:150] 378748 384568 390311 396053 401506 ...
##  $ Emp    : num [1:150] 62.8 62.6 62.4 62 61.8 ...
##  $ FCE    : num [1:150] 42.8 34.8 47.6 36.9 31.5 ...
View(data)
summary(data)
##    Country             C.Code               Year           GDP         
##  Length:150         Length:150         Min.   :2007   Min.   :  321.8  
##  Class :character   Class :character   1st Qu.:2010   1st Qu.: 1636.8  
##  Mode  :character   Mode  :character   Median :2014   Median : 3368.2  
##                                        Mean   :2014   Mean   :11787.8  
##                                        3rd Qu.:2018   3rd Qu.:10115.5  
##                                        Max.   :2021   Max.   :72794.0  
##        P                  Emp             FCE       
##  Min.   :   378748   Min.   :53.37   Min.   :31.50  
##  1st Qu.:  6715445   1st Qu.:61.62   1st Qu.:64.56  
##  Median : 41009760   Median :65.63   Median :68.38  
##  Mean   : 62712562   Mean   :67.50   Mean   :67.95  
##  3rd Qu.: 90091148   3rd Qu.:74.73   3rd Qu.:81.20  
##  Max.   :273753191   Max.   :84.94   Max.   :91.19

MODEL OLS

ols <- lm(GDP~P+Emp+FCE,data=data)
summary(ols)
## 
## Call:
## lm(formula = GDP ~ P + Emp + FCE, data = data)
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -17374  -6632  -1318   4568  33504 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  7.952e+04  7.335e+03  10.840  < 2e-16 ***
## P           -6.033e-05  1.146e-05  -5.266 4.91e-07 ***
## Emp          4.919e+00  1.167e+02   0.042    0.966    
## FCE         -9.459e+02  6.075e+01 -15.571  < 2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 9557 on 146 degrees of freedom
## Multiple R-squared:  0.7186, Adjusted R-squared:  0.7128 
## F-statistic: 124.3 on 3 and 146 DF,  p-value: < 2.2e-16
multicollinearity(ols)
## # Check for Multicollinearity
## 
## Low Correlation
## 
##  Term  VIF   VIF 95% CI Increased SE Tolerance Tolerance 95% CI
##     P 1.15 [1.04, 1.57]         1.07      0.87     [0.64, 0.96]
##   Emp 1.31 [1.14, 1.69]         1.14      0.76     [0.59, 0.88]
##   FCE 1.27 [1.11, 1.65]         1.13      0.79     [0.61, 0.90]
model_performance(ols,metrics = "all")
## # Indices of model performance
## 
## AIC      |     AICc |      BIC |    R2 | R2 (adj.) |     RMSE |    Sigma
## ------------------------------------------------------------------------
## 3181.122 | 3181.539 | 3196.176 | 0.719 |     0.713 | 9428.283 | 9556.565

Nilai R^2 Adjective yang diperoleh pada model ini sebesar 74.2% dan RMSE 9428.283. Kemudian, melihat hasil eksplorasi data sebelumnya dan untuk menyamakan skala pengukuran pada data set yang digunakan, maka pada analisis ini diterapkan transformasi logaritma natural pada peubah yang dianalisis.

ols1 <- lm(log(GDP)~log(P)+log(Emp)+log(FCE),data=data)
summary(ols1)
## 
## Call:
## lm(formula = log(GDP) ~ log(P) + log(Emp) + log(FCE), data = data)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -1.65316 -0.38762 -0.02592  0.56402  1.17610 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 33.88468    2.18431  15.513  < 2e-16 ***
## log(P)      -0.07399    0.04116  -1.798  0.07432 .  
## log(Emp)    -1.56806    0.56029  -2.799  0.00583 ** 
## log(FCE)    -4.20196    0.32655 -12.868  < 2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.6827 on 146 degrees of freedom
## Multiple R-squared:  0.7476, Adjusted R-squared:  0.7424 
## F-statistic: 144.2 on 3 and 146 DF,  p-value: < 2.2e-16
multicollinearity(ols1)
## # Check for Multicollinearity
## 
## Low Correlation
## 
##      Term  VIF   VIF 95% CI Increased SE Tolerance Tolerance 95% CI
##    log(P) 1.73 [1.44, 2.23]         1.32      0.58     [0.45, 0.70]
##  log(Emp) 1.26 [1.11, 1.64]         1.12      0.79     [0.61, 0.90]
##  log(FCE) 1.97 [1.61, 2.55]         1.40      0.51     [0.39, 0.62]
model_performance(ols1,metrics = "all")
## # Indices of model performance
## 
## AIC      |     AICc |      BIC |    R2 | R2 (adj.) |  RMSE | Sigma
## ------------------------------------------------------------------
## 2842.247 | 2842.663 | 2857.300 | 0.748 |     0.742 | 0.674 | 0.683

Pada model OLS yang datanya dilakukan transformasi logaritma natural diperoleh nilai R^2 adjective sebesar 74.2% dan RMSE 0.674.

DIAGNOSTIK SISAAN

Kenormalan

Hipotesis:

H0 = Sisaan menyebar normal

H1 = Sisaan tidak Menyebar normal

res.ols <- residuals(ols)
yhat.ols <- fitted(ols)

#normality
library(tseries)
## Registered S3 method overwritten by 'quantmod':
##   method            from
##   as.zoo.data.frame zoo
jarque.bera.test(res.ols)
## 
##  Jarque Bera Test
## 
## data:  res.ols
## X-squared = 47.699, df = 2, p-value = 4.388e-11
#histogram
hist(res.ols, 
     xlab = "sisaan",
     col = "steelblue", 
     breaks=30,  
     prob = TRUE) 
lines(density(res.ols), # density plot
      lwd = 2, # thickness of line
      col = "chocolate3")

#plotqqnorm
qqnorm(res.ols,datax=T, col="blue")
qqline(rnorm(length(res.ols),mean(res.ols),sd(res.ols)),datax=T, col="red")

Hasil uji normalitas memberikan nilai p-value kurang dari α = 5% , sehingga Tolak H0, yang menandakan bahwa sisaan belum menyebar normal. Plot histogram dan QQ normal juga menunjukkan bahwa sisaan belum menyebar normal.

Kebebasan Sisaan

Hipotesis:

H0 = Sisaan saling bebas

H1 = Sisaan tidak saling bebas

library(lmtest)
## Loading required package: zoo
## 
## Attaching package: 'zoo'
## The following objects are masked from 'package:base':
## 
##     as.Date, as.Date.numeric
dwtest(ols1)
## 
##  Durbin-Watson test
## 
## data:  ols1
## DW = 0.32389, p-value < 2.2e-16
## alternative hypothesis: true autocorrelation is greater than 0

Nilai p-value yang diperoleh < α (5%) sehingga tolak H0, hal ini dapat dikatakan bahwa sisaan tidak saling bebas atau terdapat gejala autokorelasi pada model.

Kehomogenan Ragam

Hipotesis:

H0 = Sisaan memiliki ragam homogen

H1 = Sisaan tidak memiliki ragam homogen

bptest(ols1)
## 
##  studentized Breusch-Pagan test
## 
## data:  ols1
## BP = 9.0402, df = 3, p-value = 0.02876

Nilai p-value yang diperoleh < α (5%) sehingga tolak H0, atau dapat dikatakan bahwa sisaan belum homogen.

#Hasil plot menunjukkan ragam tidak homogen
plot(yhat.ols,res.ols, 
     xlab = "fitted value", 
     ylab = "residuals")

Rangkuman Hasil OLS (BBEELLUUMMSS)

MODEL CEM

Tanpa melakukan transformasi Data

common <- plm(GDP~P+Emp+FCE,data=data,model="pooling")

summary(common)
## Pooling Model
## 
## Call:
## plm(formula = GDP ~ P + Emp + FCE, data = data, model = "pooling")
## 
## Unbalanced Panel: n = 10, T = 15-15, N = 150
## 
## Residuals:
##     Min.  1st Qu.   Median  3rd Qu.     Max. 
## -17374.1  -6631.9  -1318.3   4568.4  33503.6 
## 
## Coefficients:
##                Estimate  Std. Error  t-value  Pr(>|t|)    
## (Intercept)  7.9516e+04  7.3355e+03  10.8399 < 2.2e-16 ***
## P           -6.0328e-05  1.1457e-05  -5.2657 4.905e-07 ***
## Emp          4.9186e+00  1.1667e+02   0.0422    0.9664    
## FCE         -9.4593e+02  6.0750e+01 -15.5709 < 2.2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Total Sum of Squares:    4.7389e+10
## Residual Sum of Squares: 1.3334e+10
## R-Squared:      0.71863
## Adj. R-Squared: 0.71285
## F-statistic: 124.296 on 3 and 146 DF, p-value: < 2.22e-16
library(performance)
multicollinearity(common)
## # Check for Multicollinearity
## 
## Low Correlation
## 
##  Term  VIF   VIF 95% CI Increased SE Tolerance Tolerance 95% CI
##     P 1.15 [1.04, 1.57]         1.07      0.87     [0.64, 0.96]
##   Emp 1.31 [1.14, 1.69]         1.14      0.76     [0.59, 0.88]
##   FCE 1.27 [1.11, 1.65]         1.13      0.79     [0.61, 0.90]
model_performance(common,metrics = "all")
## # Indices of model performance
## 
## AIC      |     AICc |      BIC |    R2 | R2 (adj.) |     RMSE |    Sigma
## ------------------------------------------------------------------------
## 3181.122 | 3181.539 | 3196.176 | 0.719 |     0.713 | 9428.283 | 9556.565

Model dengan melakukan transformasi logaritma natural pada seluruh peubah

common1 <- plm(log(GDP)~log(P)+log(Emp)+log(FCE), data=data, model="pooling")

summary(common1)
## Pooling Model
## 
## Call:
## plm(formula = log(GDP) ~ log(P) + log(Emp) + log(FCE), data = data, 
##     model = "pooling")
## 
## Unbalanced Panel: n = 10, T = 15-15, N = 150
## 
## Residuals:
##      Min.   1st Qu.    Median   3rd Qu.      Max. 
## -1.653165 -0.387620 -0.025915  0.564021  1.176104 
## 
## Coefficients:
##              Estimate Std. Error  t-value  Pr(>|t|)    
## (Intercept) 33.884678   2.184308  15.5128 < 2.2e-16 ***
## log(P)      -0.073988   0.041162  -1.7975  0.074321 .  
## log(Emp)    -1.568064   0.560291  -2.7987  0.005825 ** 
## log(FCE)    -4.201960   0.326555 -12.8676 < 2.2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Total Sum of Squares:    269.64
## Residual Sum of Squares: 68.055
## R-Squared:      0.74761
## Adj. R-Squared: 0.74243
## F-statistic: 144.159 on 3 and 146 DF, p-value: < 2.22e-16
multicollinearity(common1)
## # Check for Multicollinearity
## 
## Low Correlation
## 
##      Term  VIF   VIF 95% CI Increased SE Tolerance Tolerance 95% CI
##    log(P) 1.73 [1.44, 2.23]         1.32      0.58     [0.45, 0.70]
##  log(Emp) 1.26 [1.11, 1.64]         1.12      0.79     [0.61, 0.90]
##  log(FCE) 1.97 [1.61, 2.55]         1.40      0.51     [0.39, 0.62]
model_performance(common1,metrics = "all")
## # Indices of model performance
## 
## AIC      |     AICc |      BIC |    R2 | R2 (adj.) |  RMSE | Sigma
## ------------------------------------------------------------------
## 2842.247 | 2842.663 | 2857.300 | 0.748 |     0.742 | 0.674 | 0.683

Hasil pendugaan parameter dengan menggunakan model OLS dan model CEM memiliki nilai yang sama.

DIAGNOSTIK SISAAN

Kenormalan

Hipotesis:

H0 = Sisaan menyebar normal

H1 = Sisaan tidak Menyebar normal

res.cem <- residuals(common1)
yhat.cem <- fitted(common1)


#normality
library(tseries)
jarque.bera.test(res.cem)
## 
##  Jarque Bera Test
## 
## data:  res.cem
## X-squared = 5.6407, df = 2, p-value = 0.05959
shapiro.test(res.cem)
## 
##  Shapiro-Wilk normality test
## 
## data:  res.cem
## W = 0.96734, p-value = 0.001237
#histogram
hist(res.cem, 
     xlab = "sisaan",
     col = "steelblue", 
     breaks=30,  
     prob = TRUE) 
lines(density(res.ols), # density plot
      lwd = 2, # thickness of line
      col = "chocolate3")

#plotqqnorm
res.cem1 <- as.numeric(res.cem)
qqnorm(res.cem1,datax=T, col="blue")
qqline(rnorm(length(res.cem1),mean(res.cem1),sd(res.cem1)),datax=T, col="red")

Hasil uji normalitas memberikan nilai p-value kurang dari α = 5% , sehingga Tolak H0, yang menandakan bahwa sisaan belum menyebar normal. Plot histogram dan QQ normal juga menunjukkan bahwa sisaan belum menyebar normal.

Kebebasan Sisaan

Hipotesis:

H0 = Sisaan saling bebas

H1 = Sisaan tidak saling bebas

pbgtest(common1)
## 
##  Breusch-Godfrey/Wooldridge test for serial correlation in panel models
## 
## data:  log(GDP) ~ log(P) + log(Emp) + log(FCE)
## chisq = 106.6, df = 15, p-value = 7.225e-16
## alternative hypothesis: serial correlation in idiosyncratic errors

Nilai p-value yang diperoleh < α (5%) sehingga tolak H0, hal ini dapat dikatakan bahwa sisaan tidak saling bebas atau terdapat gejala autokorelasi pada model.

Kehomogenan Ragam

Hipotesis:

H0 = Sisaan memiliki ragam homogen

H1 = Sisaan tidak memiliki ragam homogen

bptest(common1)
## 
##  studentized Breusch-Pagan test
## 
## data:  common1
## BP = 9.0402, df = 3, p-value = 0.02876

Nilai p-value yang diperoleh < α (5%) sehingga tolak H0, atau dapat dikatakan bahwa sisaan belum homogen.

Sementara berdasarkan hasil analsis data panel dengan pendugaan parameter model menggunakan metode OLS dan juga CEM dimana pendugaan yang dilakukan adalah menggunakan Metode Kuadrat Terkecil(MKT) menunjukkan bahwa asumsi-asumsi dari model belum terpenuhi meski telah dilakukan proses transformasi data dengan logaritma natural. Oleh karena itu selanjutnya dilakukan pemodelan data panel model CEM dengan menggunakan metode Generalized Least Square (GLS).