Indicaciones Generales: Presente en un reporte de Rmardown todas las operaciones que se indican en la tarea, debe incluir el archivo rmd, la correspondiente versión html y el informe publicado en una cuenta de Rpubs (incluir el enlace en los comentarios de entrega de las tareas, y en un archivo txt dentro de la entrega), incluyendo los nombres y apellidos de cada uno de los integrantes del grupo.

Usando los datos incluidos en el archivo datos_PIB_trime_CA.xlsx:

Aplique el filtro HP para cada uno de los países de Centroamérica, para los periodos disponibles para cada país

• represente sus resultados de forma gráfica: o 1. Usando la versión personalizada y o 2. usando la representación rápida. o En todos los gráficos indique el país y el periodo al que corresponden los datos.

Carga de Datos

library(readxl)
PIB_trimestral <- read_excel("C:/Users/MINEDUCYT/Downloads/datos_PIB_trim_CA.xlsx")
print(PIB_trimestral)
## # A tibble: 143 × 8
##    Secretaría Ejecutiva del Consejo …¹ ...2  ...3  ...4  ...5  ...6  ...7  ...8 
##    <chr>                               <chr> <chr> <chr> <chr> <chr> <chr> <chr>
##  1 Producción                          <NA>  <NA>  <NA>  <NA>  <NA>  <NA>  <NA> 
##  2 Producto Interno Bruto trimestral   <NA>  <NA>  <NA>  <NA>  <NA>  <NA>  <NA> 
##  3 Unidad de medida: Millones de mone… <NA>  <NA>  <NA>  <NA>  <NA>  <NA>  <NA> 
##  4 Fechas                              Cost… El S… Guat… Hond… Nica… Repú… Pana…
##  5 <NA>                                PIB … PIB … PIB … PIB … PIB … PIB … PIB …
##  6 1990-I                              --    48.97 --    --    --    --    --   
##  7 1990-II                             --    56.32 --    --    --    --    --   
##  8 1990-III                            --    56.41 --    --    --    --    --   
##  9 1990-IV                             --    59.88 --    --    --    --    --   
## 10 1991-I                              2730… 50.54 --    --    --    43.2  --   
## # ℹ 133 more rows
## # ℹ abbreviated name:
## #   ¹​`Secretaría Ejecutiva del Consejo Monetario Centroamericano`

Costa Rica

library(mFilter)  
library(forecast) 

datos_cr <- PIB_trimestral[[2]][11:144]
datos_cr <- as.numeric(datos_cr)
datos_cr <- na.omit(datos_cr)

PIB_CostaRica <- ts(datos_cr, start = c(2005,1), frequency = 4)

hp_result <- hpfilter(PIB_CostaRica, freq = 1600)

trend <- hp_result$trend
cycle <- hp_result$cycle

plot(PIB_CostaRica, type = "l", main = "Filtro HP - Costa Rica", ylab = "PIB", xlab = "Tiempo")
lines(trend, col = "red", lwd = 2)
legend("topleft", legend = c("PIB Original", "Tendencia (Filtro HP)"), col = c("black", "red"), lty = 1, lwd = 2)

plot(cycle, type = "l", main = "Componente Ciclico", ylab = "Ciclo", xlab = "Tiempo")

Aplicacion de forma rapida para COSTA RICA

plot(hp_result,ask = FALSE)

El Salvador

datos_sv <- PIB_trimestral[[3]][7:144]
datos_sv <- as.numeric(datos_sv)
datos_sv <- na.omit(datos_sv)

PIB_ElSalvador <- ts(datos_sv, start = c(2005,1), frequency = 4)

hp_result <- hpfilter(PIB_ElSalvador, freq = 1600)

trend <- hp_result$trend
cycle <- hp_result$cycle

plot(PIB_ElSalvador, type = "l", main = "Filtro HP - El Salvador", ylab = "PIB", xlab = "Tiempo")
lines(trend, col = "red", lwd = 2)
legend("topleft", legend = c("PIB Original", "Tendencia (Filtro HP)"), col = c("black", "red"), lty = 1, lwd = 2)

plot(cycle, type = "l", main = "Componente Ciclico", ylab = "Ciclo", xlab = "Tiempo")

Aplicacion de forma rapida para EL SALVADOR

plot(hp_result,ask = FALSE)

Guatemala

datos_gt <- PIB_trimestral[[4]][51:144]
datos_gt <- as.numeric(datos_gt)
datos_gt <- na.omit(datos_gt)

PIB_Guatemala <- ts(datos_gt, start = c(2005,1), frequency = 4)

hp_result <- hpfilter(PIB_Guatemala, freq = 1600)

trend <- hp_result$trend
cycle <- hp_result$cycle

plot(PIB_Guatemala, type = "l", main = "Filtro HP - Guatemala", ylab = "PIB", xlab = "Tiempo")
lines(trend, col = "red", lwd = 2)
legend("topleft", legend = c("PIB Original", "Tendencia (Filtro HP)"), col = c("black", "red"), lty = 1, lwd = 2)

plot(cycle, type = "l", main = "Componente Ciclico", ylab = "Ciclo", xlab = "Tiempo")

Aplicacion de forma rapida para GUATEMALA

plot(hp_result,ask = FALSE)

Honduras

datos_hn <- PIB_trimestral[[5]][47:144]
datos_hn <- as.numeric(datos_hn)
datos_hn <- na.omit(datos_hn)

PIB_Honduras <- ts(datos_hn, start = c(2005,1), frequency = 4)

hp_result <- hpfilter(PIB_Honduras, freq = 1600)

trend <- hp_result$trend
cycle <- hp_result$cycle

plot(PIB_Honduras, type = "l", main = "Filtro HP - Honduras", ylab = "PIB", xlab = "Tiempo")
lines(trend, col = "red", lwd = 2)
legend("topleft", legend = c("PIB Original", "Tendencia (Filtro HP)"), col = c("black", "red"), lty = 1, lwd = 2)

plot(cycle, type = "l", main = "Componente Ciclico", ylab = "Ciclo", xlab = "Tiempo")

Aplicacion de forma rapida para HONDURAS

plot(hp_result,ask = FALSE)

Nicaragua

datos_ni <- PIB_trimestral[[6]][71:144]
datos_ni <- as.numeric(datos_ni)
datos_ni <- na.omit(datos_ni)

PIB_Nicaragua <- ts(datos_ni, start = c(2005,1), frequency = 4)

hp_result <- hpfilter(PIB_Nicaragua, freq = 1600)

trend <- hp_result$trend
cycle <- hp_result$cycle

plot(PIB_Nicaragua, type = "l", main = "Filtro HP - Nicaragua", ylab = "PIB", xlab = "Tiempo")
lines(trend, col = "red", lwd = 2)
legend("topleft", legend = c("PIB Original", "Tendencia (Filtro HP)"), col = c("black", "red"), lty = 1, lwd = 2)

plot(cycle, type = "l", main = "Componente Ciclico", ylab = "Ciclo", xlab = "Tiempo")

Aplicacion de forma rapida para NICARAGUA

plot(hp_result,ask = FALSE)

República Dominicana

datos_rd <- PIB_trimestral[[7]][11:144]
datos_rd <- as.numeric(datos_rd)
datos_rd <- na.omit(datos_rd)

PIB_RepDom <- ts(datos_rd, start = c(2005,1), frequency = 4)

hp_result <- hpfilter(PIB_RepDom, freq = 1600)

trend <- hp_result$trend
cycle <- hp_result$cycle

plot(PIB_RepDom, type = "l", main = "Filtro HP - República Dominicana", ylab = "PIB", xlab = "Tiempo")
lines(trend, col = "red", lwd = 2)
legend("topleft", legend = c("PIB Original", "Tendencia (Filtro HP)"), col = c("black", "red"), lty = 1, lwd = 2)

plot(cycle, type = "l", main = "Componente Ciclico", ylab = "Ciclo", xlab = "Tiempo")

Aplicacion de forma rapida para REPUBLICA DOMINICANA

plot(hp_result,ask = FALSE)

Panamá

datos_pa <- PIB_trimestral[[8]][31:137]
datos_pa <- as.numeric(datos_pa)
datos_pa <- na.omit(datos_pa)

PIB_Panama <- ts(datos_pa, start = c(2005,1), frequency = 4)

hp_result <- hpfilter(PIB_Panama, freq = 1600)

trend <- hp_result$trend
cycle <- hp_result$cycle

plot(PIB_Panama, type = "l", main = "Filtro HP - Panamá", ylab = "PIB", xlab = "Tiempo")
lines(trend, col = "red", lwd = 2)
legend("topleft", legend = c("PIB Original", "Tendencia (Filtro HP)"), col = c("black", "red"), lty = 1, lwd = 2)

plot(cycle, type = "l", main = "Componente Ciclico", ylab = "Ciclo", xlab = "Tiempo")

Aplicacion de forma rapida para PANAMA

plot(hp_result,ask = FALSE)