library(WDI)
df = WDI(indicator=c(tik='SL.AGR.EMPL.FE.ZS', tie='SL.AGR.EMPL.MA.ZS' ), country=c('TR'),  start=1992, end=2020)
library(dynlm)
## Warning: package 'dynlm' was built under R version 4.1.3
## Zorunlu paket yükleniyor: zoo
## Warning: package 'zoo' was built under R version 4.1.3
## 
## Attaching package: 'zoo'
## The following objects are masked from 'package:base':
## 
##     as.Date, as.Date.numeric
 df.ts <- ts(df, start=c(1992), end=c(2020),frequency=1)
 df.ts<-df.ts[,c("tik","tie")]
 plot(df.ts[,"tik"], ylab="tarımda.istihdam.kadın ")

 plot(df.ts[,"tie"], ylab="tarımda.istihdam.erkek")

gecikmelitik <- data.frame(cbind(df.ts[,"tik"], lag(df.ts[,"tik"],-1 )))
names(gecikmelitik) <- c("tik","tik1gec")
head(gecikmelitik)
##     tik tik1gec
## 1 49.21      NA
## 2 50.29   49.21
## 3 49.10   50.29
## 4 48.79   49.10
## 5 48.37   48.79
## 6 48.52   48.37
tarımda.istihdam.erkek <- df.ts[,"tie"]
deltatarımda.istihdam.erkek <- diff(df.ts[,"tie"])
plot(tarımda.istihdam.erkek)

plot(deltatarımda.istihdam.erkek)

phillips.reg <- dynlm(tarımda.istihdam.erkek~deltatarımda.istihdam.erkek)
summary(phillips.reg)
## 
## Time series regression with "ts" data:
## Start = 1993, End = 2019
## 
## Call:
## dynlm(formula = tarımda.istihdam.erkek ~ deltatarımda.istihdam.erkek)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -3.3975 -1.2830 -0.4208  1.6609  3.4411 
## 
## Coefficients:
##                             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                  18.2557     0.4458  40.954   <2e-16 ***
## deltatarımda.istihdam.erkek   0.8175     0.9279   0.881    0.387    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 2.037 on 25 degrees of freedom
##   (0 observations deleted due to missingness)
## Multiple R-squared:  0.03012,    Adjusted R-squared:  -0.008677 
## F-statistic: 0.7763 on 1 and 25 DF,  p-value: 0.3867
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 = 255.75, df1 = 1, df2 = 24, p-value = 2.67e-14