DESARROLLO DEL TALLER 7 DE ECONOMETRÍA 2

A continuación se muestran los códigos necesarios para la estimación de las pruebas del taller.

Código del Desarrollo del Punto 2

#|----------------------------------------------------------------------------|#
#|------>>| PRUEBAS DE RAÍCES UNITARIAS - PROCESOS NO ESTACIONARIOS |<<-------|#
#|----------------------------------------------------------------------------|#

library(tseries)
library(uroot)
library(urca)
library(readxl)
library(stargazer)
#|----------------------------------------------------------------------------|#

#| Directorio
setwd("C:/Programacion en R/5. ECONOMETRIA 2/ECO-EJ8")

#| Datos como CT
DATA <- read_excel("2. Series de Tiempo.xlsx")
View(DATA)

#| Datos como ST
Y <- ts(DATA[,2], start = c(1980), frequency = 1)

LY <- log(Y) 
IN <- ts(DATA[,3], start = c(1980), frequency = 1)
DE <- ts(DATA[,4], start = c(1980), frequency = 1)

#| Gráfica de la ST
par(mfrow=c(1,1))
ts.plot(Y,main="Gráfica de la Serie del PIB", col = "black",lwd=2)
ts.plot(LY,main="Gráfica de la Serie de Log(Y)", col = "red",lwd=2)
ts.plot(IN,main="Gráfica de la Serie de Inflación", col = "blue",lwd=2)
ts.plot(DE,main="Gráfica de la Serie de Desempleo", col = "darkgreen",lwd=2)

#|----------------------------------------------------------------------------|#

#| Primeras Diferencias
DIF1_LY <-diff(LY)
DIF1_IN <-diff(IN)
DIF1_DE <-diff(DE)

#| Gráfica de las Primeras Diferencias
ts.plot(DIF1_LY,main="Serie de Tiempo - Primera Diferencia (Log(Y))", col = "red", lwd=2)
ts.plot(DIF1_IN,main="Serie de Tiempo - Primera Diferencia (Inflación)", col = "blue", lwd=2)
ts.plot(DIF1_DE,main="Serie de Tiempo - Primera Diferencia (Desempleo)", col = "darkgreen", lwd=2)

#|----------------------------------------------------------------------------|#

#| Segundas Diferencias
DIF2_LY <-diff(DIF1_LY)
DIF2_IN <-diff(DIF1_IN)
DIF2_DE <-diff(DIF1_DE)

#| Gráfica de las Segundas Diferencias
ts.plot(DIF2_LY,main="Serie de Tiempo - Segunda Diferencia (Log(Y))", col = "red", lwd=2)
ts.plot(DIF2_IN,main="Serie de Tiempo - Segunda Diferencia (Inflación)", col = "blue", lwd=2)
ts.plot(DIF2_DE,main="Serie de Tiempo - Segunda Diferencia (Desempleo)", col = "darkgreen", lwd=2)

#|----------------------------------------------------------------------------|#

#| TODAS LAS VARIABLES

#| Variables en Niveles
LY 
IN 
DE 

#| Variables en Primeras Diferencias
DIF1_LY 
DIF1_IN
DIF1_DE 

#| Variables en Segundas Diferencias
DIF2_LY 
DIF2_IN
DIF2_DE 

#|----------------------------------------------------------------------------|#

#| PRUEBAS DE RAÍCES UNITARIAS EN NIVELES

#| LY
PADF1 <- ur.df(LY , type="drift", selectlags = "AIC")
summary(PADF1)  

PERS1 <- ur.ers(LY, type="DF-GLS", model="trend", lag.max = 4)
summary(PERS1)

PPP1 <- ur.pp(LY, type="Z-tau", model = "constant")
PPP1 <- ur.pp(LY, type="Z-alpha", model = "constant")
summary(PPP1)

PKPSS1 <- ur.kpss(LY, type="mu")
summary(PKPSS1)

#| IN
PADF1 <- ur.df(IN , type="drift", selectlags = "AIC")
summary(PADF1)  

PERS1 <- ur.ers(IN, type="DF-GLS", model="trend", lag.max = 4)
summary(PERS1)

PPP1 <- ur.pp(IN, type="Z-tau", model = "constant")
PPP1 <- ur.pp(IN, type="Z-alpha", model = "constant")
summary(PPP1)

PKPSS1 <- ur.kpss(IN, type="mu")
summary(PKPSS1)

#| DE
PADF1 <- ur.df(DE, type="drift", selectlags = "AIC")
summary(PADF1)  

PERS1 <- ur.ers(DE, type="DF-GLS", model="trend", lag.max = 4)
summary(PERS1)

PPP1 <- ur.pp(DE, type="Z-tau", model = "constant")
PPP1 <- ur.pp(DE, type="Z-alpha", model = "constant")
summary(PPP1)

PKPSS1 <- ur.kpss(DE, type="mu")
summary(PKPSS1)

#|----------------------------------------------------------------------------|#

#| PRUEBAS DE RAÍCES UNITARIAS EN PRIMERAS DIFERENCIAS

#| LY
PADF2 <- ur.df(DIF1_LY , type="none", selectlags = "AIC")
summary(PADF2)

PERS2 <- ur.ers(DIF1_LY , type="DF-GLS", model="trend", lag.max = 0)
summary(PERS2)

PPP2 <- ur.pp(DIF1_LY , type="Z-tau", model = "constant")
PPP2 <- ur.pp(DIF1_LY, type="Z-alpha", model = "constant")
summary(PPP2)

PKPSS2 <- ur.kpss(DIF1_LY , type="mu")
summary(PKPSS2)

#| IN
PADF2 <- ur.df(DIF1_IN , type="none", selectlags = "AIC")
summary(PADF2)

PERS2 <- ur.ers(DIF1_IN , type="DF-GLS", model="trend", lag.max = 0)
summary(PERS2)

PPP2 <- ur.pp(DIF1_IN, type="Z-tau", model = "constant")
PPP2 <- ur.pp(DIF1_IN, type="Z-alpha", model = "constant")
summary(PPP2)

PKPSS2 <- ur.kpss(DIF1_IN , type="mu")
summary(PKPSS2)

#| DE
PADF2 <- ur.df(DIF1_DE , type="none", selectlags = "AIC")
summary(PADF2)

PERS2 <- ur.ers(DIF1_DE , type="DF-GLS", model="trend", lag.max = 0)
summary(PERS2)

PPP2 <- ur.pp(DIF1_DE , type="Z-tau", model = "constant")
PPP2 <- ur.pp(DIF1_DE, type="Z-alpha", model = "constant")
summary(PPP2)

PKPSS2 <- ur.kpss(DIF1_DE , type="mu")
summary(PKPSS2)