library(WDI)
df = WDI(indicator=c(nfs='SP.POP.TOTL', enf='FP.CPI.TOTL.ZG' ), country=c('TR'),  start=2000, end=2020)
library(dynlm)
## Warning: package 'dynlm' was built under R version 4.1.3
## Loading required package: zoo
## 
## Attaching package: 'zoo'
## The following objects are masked from 'package:base':
## 
##     as.Date, as.Date.numeric
df.ts <- ts(df, start=c(2000), end=c(2020),frequency=1)
df.ts<-df.ts[,c("nfs","enf")]
plot(df.ts[,"nfs"], ylab="nüfus")

df.ts<-df.ts[,c("nfs","enf")]
plot(df.ts[,"nfs"], ylab="nüfus")

plot(df.ts[,"enf"], ylab="enflasyon")

gecikmeliun <- data.frame(cbind(df.ts[,"nfs"], lag(df.ts[,"nfs"],-1)))
names(gecikmeliun) <- c("nfs","nfs1gec")
head(gecikmeliun)
##        nfs  nfs1gec
## 1 63240196       NA
## 2 64192243 63240196
## 3 65145357 64192243
## 4 66089402 65145357
## 5 67010930 66089402
## 6 67903461 67010930
acf(df.ts[,"nfs"])

acf(df.ts[,"enf"])

enflasyon <- df.ts[,"enf"]
deltanüfus <- diff(df.ts[,"nfs"])
plot(enflasyon)

plot(deltanüfus)

phillips.reg <- dynlm(enflasyon~deltanüfus)
summary(phillips.reg)
## 
## Time series regression with "ts" data:
## Start = 2001, End = 2020
## 
## Call:
## dynlm(formula = enflasyon ~ deltanüfus)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -10.224  -7.171  -3.163   0.762  38.671 
## 
## Coefficients:
##               Estimate Std. Error t value Pr(>|t|)
## (Intercept)  3.014e+01  1.764e+01   1.708    0.105
## deltanüfus  -1.513e-05  1.650e-05  -0.917    0.371
## 
## Residual standard error: 12.84 on 18 degrees of freedom
## Multiple R-squared:  0.04465,    Adjusted R-squared:  -0.008427 
## F-statistic: 0.8412 on 1 and 18 DF,  p-value: 0.3712
uhat <- resid(phillips.reg)
plot(uhat)

acf(uhat)

library(lmtest)
## Warning: package 'lmtest' was built under R version 4.1.3
bgtest(phillips.reg, order=1, type="F")
## 
##  Breusch-Godfrey test for serial correlation of order up to 1
## 
## data:  phillips.reg
## LM test = 9.1715, df1 = 1, df2 = 17, p-value = 0.00758