library(readxl)
PIBT_SV <- read_excel(
"C:/Users/karla/Downloads/datos_PIB_trim_CA.xlsx",
range = "C7:C144",
col_types = c("numeric")
)
PIBT_GT <- read_excel(
"C:/Users/karla/Downloads/datos_PIB_trim_CA.xlsx",
range = "D51:D144",
col_types = c("numeric")
)
PIBT_HN <- read_excel(
"C:/Users/karla/Downloads/datos_PIB_trim_CA.xlsx",
range = "E47:E144",
col_types = c("numeric")
)
PIBT_NI <- read_excel(
"C:/Users/karla/Downloads/datos_PIB_trim_CA.xlsx",
range = "f71:f144",
col_types = c("numeric")
)
PIBT_CR <- read_excel(
"C:/Users/karla/Downloads/datos_PIB_trim_CA.xlsx",
range = "B11:B144",
col_types = c("numeric")
)
PIBT_PA <- read_excel(
"C:/Users/karla/Downloads/datos_PIB_trim_CA.xlsx",
range = "H31:H137",
col_types = c("numeric")
)
PIBT_RD <- read_excel(
"C:/Users/karla/Downloads/datos_PIB_trim_CA.xlsx",
range = "g11:g144",
col_types = c("numeric")
)library(mFilter)
library(forecast)
TS_PIBT_SV <- ts(PIBT_SV, start = c(2006, 1), frequency = 4)
# aplicando el filtro hp y escogiendo el valor de lambda de 1600 dado que es trimestral
hp_SV <- hpfilter(TS_PIBT_SV, freq = 1600)
trend_SV <- hp_SV$trend
cycle_SV <- hp_SV$cycleplot(
TS_PIBT_SV,
type = "l",
main = "EL SALVADOR (1990 I - 2024 II) - Filtro de Hodrick-Prescott",
ylab = "PIB",
xlab = "Tiempo"
)
lines(trend_SV, col = "green", lwd = 2)
legend(
"topleft",
legend = c("PIB Original", "Tendencia (Filtro HP)"),
col = c("black", "green"),
lty = 1,
lwd = 2
)plot(
cycle_SV,
type = "l",
main = "EL SALVADOR (1990 I - 2024 II) - Componente Ciclico",
ylab = "Ciclo",
xlab = "Tiempo"
)TS_PIBT_GT <- ts(PIBT_GT, start = c(2006, 1), frequency = 4)
hp_GT <- hpfilter(TS_PIBT_GT, freq = 1600)
trend_GT <- hp_GT$trend
cycle_GT <- hp_GT$cycleplot(
TS_PIBT_GT,
type = "l",
main = "GUATEMALA (2001 I - 2024 II) - Filtro de Hodrick-Prescott",
ylab = "PIB",
xlab = "Tiempo"
)
lines(trend_GT, col = "green", lwd = 2)
legend(
"topleft",
legend = c("PIB Original", "Tendencia (Filtro HP)"),
col = c("black", "green"),
lty = 1,
lwd = 2
)plot(
cycle_GT,
type = "l",
main = "GUATEMALA (2001 I - 2024 II) - Componente Ciclico",
ylab = "Ciclo",
xlab = "Tiempo"
)TS_PIBT_HN <- ts(PIBT_HN, start = c(2006, 1), frequency = 4)
hp_HN <- hpfilter(TS_PIBT_HN, freq = 1600)
trend_HN <- hp_HN$trend
cycle_HN <- hp_HN$cycleplot(
TS_PIBT_HN,
type = "l",
main = "HONDURAS (2000 I - 2024 II) - Filtro de Hodrick-Prescott",
ylab = "PIB",
xlab = "Tiempo"
)
lines(trend_HN, col = "green", lwd = 2)
legend(
"topleft",
legend = c("PIB Original", "Tendencia (Filtro HP)"),
col = c("black", "green"),
lty = 1,
lwd = 2
)plot(
cycle_HN,
type = "l",
main = "HONDURAS (2000 I - 2024 II) - Componente Ciclico",
ylab = "Ciclo",
xlab = "Tiempo"
)TS_PIBT_NI <- ts(PIBT_NI, start = c(2006, 1), frequency = 4)
hp_NI <- hpfilter(TS_PIBT_NI, freq = 1600)
trend_NI <- hp_NI$trend
cycle_NI <- hp_NI$cycleplot(
TS_PIBT_NI,
type = "l",
main = "NICARAGUA (2006 I - 2024 II) - Filtro de Hodrick-Prescott",
ylab = "PIB",
xlab = "Tiempo"
)
lines(trend_NI, col = "green", lwd = 2)
legend(
"topleft",
legend = c("PIB Original", "Tendencia (Filtro HP)"),
col = c("black", "green"),
lty = 1,
lwd = 2
)plot(
cycle_NI,
type = "l",
main = "NICARAGUA (2006 I - 2024 II) - Componente Ciclico",
ylab = "Ciclo",
xlab = "Tiempo"
)TS_PIBT_CR <- ts(PIBT_CR, start = c(2006, 1), frequency = 4)
hp_CR <- hpfilter(TS_PIBT_CR, freq = 1600)
trend_CR <- hp_CR$trend
cycle_CR <- hp_CR$cycleplot(
TS_PIBT_CR,
type = "l",
main = "COSTA RICA (1991 I - 2024 II) - Filtro de Hodrick-Prescott",
ylab = "PIB",
xlab = "Tiempo"
)
lines(trend_CR, col = "green", lwd = 2)
legend(
"topleft",
legend = c("PIB Original", "Tendencia (Filtro HP)"),
col = c("black", "green"),
lty = 1,
lwd = 2
)plot(
cycle_CR,
type = "l",
main = "COSTA RICA (1991 I - 2024 II) - Componente Ciclico",
ylab = "Ciclo",
xlab = "Tiempo"
)TS_PIBT_PA <- ts(PIBT_PA, start = c(2006, 1), frequency = 4)
hp_PA <- hpfilter(TS_PIBT_PA, freq = 1600)
trend_PA <- hp_PA$trend
cycle_PA <- hp_PA$cycleplot(
TS_PIBT_PA,
type = "l",
main = "PANAMÁ (1996 I - 2022 III) - Filtro de Hodrick-Prescott",
ylab = "PIB",
xlab = "Tiempo"
)
lines(trend_PA, col = "green", lwd = 2)
legend(
"topleft",
legend = c("PIB Original", "Tendencia (Filtro HP)"),
col = c("black", "green"),
lty = 1,
lwd = 2
)plot(
cycle_PA,
type = "l",
main = "COSTA RICA (1991 I - 2024 II) - Componente Ciclico",
ylab = "Ciclo",
xlab = "Tiempo"
)TS_PIBT_RD <- ts(PIBT_RD, start = c(2006, 1), frequency = 4)
hp_RD <- hpfilter(TS_PIBT_RD, freq = 1600)
trend_RD <- hp_RD$trend
cycle_RD <- hp_RD$cycleplot(
TS_PIBT_RD,
type = "l",
main = "REPÚBLICA DOMINICANA (1991 I - 2024 II) - Filtro de Hodrick-Prescott",
ylab = "PIB",
xlab = "Tiempo"
)
lines(trend_RD, col = "green", lwd = 2)
legend(
"topleft",
legend = c("PIB Original", "Tendencia (Filtro HP)"),
col = c("black", "green"),
lty = 1,
lwd = 2
)plot(
cycle_RD,
type = "l",
main = "REPÚBLICA DOMINICANA (1991 I - 2024 II) - Componente Ciclico",
ylab = "Ciclo",
xlab = "Tiempo"
)