Grupo Centec
Especialización en Estadística con R
Modelamiento Estadístico
Trabajo Final
2022-12-25
En 2021 las exportaciones en Bolivia crecieron un 51,85% respecto al año anterior. Las ventas al exterior representan el 27,1% de su PIB, por lo que se encuentra en el puesto 84 de 191 países del ranking de exportaciones respecto al PIB. Con una cifra de 9.326,1 millones de euros Bolivia ocupa el puesto número 91 en el ranking de países según el importe de sus exportaciones. Este año hubo superavit en su Balanza comercial, ya que las importaciones, aunque crecieron, fueron menores que las exportaciones. La tasa de cobertura (porcentaje de lo que se importa que puede pagarse con lo que se exporta) fue del 115,39%. Si miramos la evolución de las exportaciones en Bolivia en los últimos años se observa que se han incrementado respecto a 2020, como ya hemos visto, al igual que ocurre respecto a 2011 cuando fueron de 6.004,5 millones de euros, que suponía un 34,59% de su PIB. En esta página te mostramos la evolución del saldo de las exportaciones Bolivia, haz clic en los siguientes links para ver la evolución de las importaciones y de la Balanza comercial en Bolivia. Puede interesarte ver un listado con las exportaciones de los 191 países que publicamos en Exportaciones y ver toda la información económica de Bolivia en Economía de Bolivia.
En el actual análisis de serie de tiempo se toma 3 variables las cuales representan un análisis al país de Bolivia, las cuales son: PIB, el producto interior bruto es un indicador económico que refleja el valor monetario de todos los bienes y servicios finales producidos por un territorio en un determinado periodo de tiempo. Se utiliza para medir la riqueza que genera un país. Importaciones, son el conjunto de bienes y servicios comprados por un país en territorio extranjero para su utilización en territorio nacional. Junto con las exportaciones, son una herramienta imprescindible de contabilidad nacional. Exportaciones, son el conjunto de bienes y servicios vendidos por un país en territorio extranjero para su utilización. Junto con las importaciones, son una herramienta imprescindible de contabilidad nacional. Las series mencionadas serán estudiadas en intervalos trimestrales desde el año 1990 hasta el año 2021. ### Visualización inicial de la serie de tiempo.
Librerias a utlizar
Cargamos la base de datos con los datos ya mencionados
## Base datos a utilizar
ruta <- "F:/Econometria Aplicada/Macroeconomia"
base <- read_excel("F:/Econometria Aplicada/Macroeconomia/Base de datos, EA.xlsx")
base$Fecha<-as.Date(base$Fecha, format="%Y-%m-%d")
class(base$Fecha)
## [1] "Date"
Visualización de la serie de tiempo del PIB
PIB_ts <- ts(base$PIB, start = c(1990,1),
frequency = 4)
PIB_ts
## Qtr1 Qtr2 Qtr3 Qtr4
## 1990 3587595 3926068 3934133 3995340
## 1991 3677806 4217984 4149575 4211088
## 1992 3795756 4299703 4164102 4264554
## 1993 3950724 4553625 4301545 4423684
## 1994 4182023 4630765 4648650 4572291
## 1995 4401909 4847211 4788395 4839881
## 1996 4561893 5122814 4989894 5026103
## 1997 4781223 5414865 5185940 5294691
## 1998 5104073 5682209 5428849 5501492
## 1999 5141965 5631526 5385855 5649983
## 2000 5249518 5904001 5440791 5761955
## 2001 5249129 5957303 5581774 5944495
## 2002 5321686 6187346 5790531 5998173
## 2003 5498240 6387990 5842775 6200411
## 2004 5739404 6620938 6202285 6365435
## 2005 5994798 6884146 6438360 6712936
## 2006 6259400 7150289 6807897 7061326
## 2007 6417302 7442694 7171628 7492403
## 2008 6837878 7955173 7678219 7806556
## 2009 7039510 8130167 7956762 8167814
## 2010 7266227 8437640 8251995 8629817
## 2011 7715275 8796981 8683047 9086166
## 2012 8101797 9183013 9081845 9670805
## 2013 8656909 9833485 9744162 10252014
## 2014 9168558 10305085 10331313 10783199
## 2015 9609051 10846338 10737402 11366807
## 2016 10123441 11197082 11268033 11785749
## 2017 10461781 11621187 11750299 12402633
## 2018 10977359 12184630 12218210 12808532
## 2019 11316218 12506583 12490126 12944005
## 2020 11339233 9412416 11132973 13068297
## 2021 11269709 11586170 11743203 13098574
ggplot(data = PIB_ts, aes(x=time(PIB_ts),
y=PIB_ts))+
geom_line()+
scale_x_continuous(breaks = seq(1990,2021,1))+
scale_y_continuous(labels = comma)+
labs(title = "Producto interno bruto del 1990 al 2021",
subtitle = "Cifras trimestrales desentralizadas: Millones de dolares",
x = "Año",
y = expression(PIB[t]))+
theme(axis.text.x = element_text(angle=90,
hjust=1))
Visualización de la serie de tiempo de la Importacion
### Importacion - Serie de tiempo
IMP_ts <- ts(base$Importaciones, start = c(1990,1),
frequency = 4)
IMP_ts
## Qtr1 Qtr2 Qtr3 Qtr4
## 1990 770382.9 840279.3 945667.7 1138639.7
## 1991 831060.2 1039987.9 1082231.9 1206861.0
## 1992 1066996.8 1070652.7 1201816.1 1233528.0
## 1993 946822.9 1110425.4 1065426.8 1417008.5
## 1994 968675.5 1040857.4 1180896.4 1319990.9
## 1995 1150719.0 1358298.6 1182714.4 1221002.2
## 1996 1059992.2 1251374.1 1404550.3 1586901.5
## 1997 1357507.0 1403424.0 1571353.4 1688487.8
## 1998 1631403.8 1789359.7 1908604.5 2034684.0
## 1999 1638501.4 1340462.1 1399624.3 1723201.8
## 2000 1600834.4 1599570.0 1590349.0 1595984.9
## 2001 1382576.9 1535238.1 1503115.4 1643915.2
## 2002 1543311.1 1743245.1 1807965.7 1764515.7
## 2003 1501367.6 1716552.5 1714898.7 1988980.8
## 2004 1586340.1 1797993.4 1785153.6 2130621.4
## 2005 1856675.8 2120152.0 2140144.1 2262573.6
## 2006 2149054.1 2296495.8 2231570.3 2134843.2
## 2007 2222224.8 2145706.4 2561162.8 2268161.6
## 2008 2437616.6 2555699.5 2620860.4 2450807.5
## 2009 2181779.5 2025954.0 2218917.4 2610789.3
## 2010 2374513.8 2355683.9 2395621.9 2909449.8
## 2011 2829893.1 2633506.1 3205691.6 3073199.8
## 2012 3141620.2 2704829.7 3084731.3 3313785.8
## 2013 3339536.9 2832031.4 3353298.3 3721661.7
## 2014 3885788.9 3225644.6 4135668.7 3997373.3
## 2015 3833854.8 3134695.1 3695579.0 3756294.6
## 2016 3729368.2 3155511.9 3351539.2 3579403.8
## 2017 3878967.2 3277828.8 3666318.6 3763726.0
## 2018 3893871.4 3391497.6 3554588.7 4028810.9
## 2019 4064372.5 3719892.3 3717327.5 3593874.6
## 2020 3846096.8 1836873.2 2566784.4 3077427.4
## 2021 3451132.2 2889118.0 3016404.9 3748661.7
ggplot(data = IMP_ts, aes(x=time(IMP_ts),
y=IMP_ts))+
geom_line()+
scale_x_continuous(breaks = seq(1990,2021,1))+
scale_y_continuous(labels = comma)+
labs(title = "Importaciones del 2005 al 2021",
subtitle = "Cifras trimestrales desentralizadas: Millones de dolares",
x = "Año",
y = expression(IMP[t]))+
theme(axis.text.x = element_text(angle=90,
hjust=1))
Visualización de la serie de tiempo de la Exportacion
### Exportacion - Serie de tiempo
EXP_ts <- ts(base$Exportaciones, start = c(1990,1),
frequency = 4)
EXP_ts
## Qtr1 Qtr2 Qtr3 Qtr4
## 1990 820443.0 847372.9 920782.3 928882.1
## 1991 851890.2 939002.5 1092747.3 890398.3
## 1992 869020.7 996297.0 964753.8 985964.5
## 1993 795572.9 997428.4 1058426.9 1167033.2
## 1994 1011725.0 1116968.3 1251656.8 1244758.4
## 1995 1087174.0 1364572.9 1301194.2 1293898.2
## 1996 1159967.1 1298032.9 1483826.8 1310351.3
## 1997 1154233.4 1343759.4 1296776.3 1346576.4
## 1998 1145556.5 1334306.7 1493543.2 1501223.3
## 1999 1016615.5 1253714.4 1179809.5 1323475.1
## 2000 1197267.2 1370454.0 1348228.3 1575645.8
## 2001 1273891.6 1419562.9 1487871.7 1770312.5
## 2002 1277839.9 1584558.2 1562962.0 1865119.7
## 2003 1441674.0 1600396.4 1756034.9 2257489.0
## 2004 1811565.9 1980891.5 2091801.8 2344013.3
## 2005 1915842.2 2253723.7 2332864.5 2411776.7
## 2006 2240739.7 2742080.0 2725700.6 2216275.7
## 2007 2141186.8 2802352.2 2653239.0 2634611.6
## 2008 2646317.7 2909900.4 2570842.0 2326814.5
## 2009 2196412.9 2364384.9 2389509.9 2379183.9
## 2010 2497238.8 2587873.7 2620283.4 2543296.1
## 2011 2507218.5 2718771.0 2842853.4 2650587.5
## 2012 2563026.9 2997711.9 3263650.0 3320252.6
## 2013 3030162.1 3075466.9 3138381.1 3397941.7
## 2014 3256579.6 3482106.7 3578672.7 3698199.1
## 2015 2915238.9 3404878.8 3377912.3 3487989.4
## 2016 2865461.7 3182416.0 3324781.2 3059866.0
## 2017 2621391.2 3069272.3 3209301.2 2914103.7
## 2018 2712162.0 3281365.4 3320063.9 3113628.4
## 2019 2629167.3 3239813.3 3348315.5 2983786.7
## 2020 2535347.3 1941888.4 2459122.8 2970938.2
## 2021 2275354.6 2946455.6 3071535.1 3141863.8
ggplot(data = EXP_ts, aes(x=time(EXP_ts),
y=EXP_ts))+
geom_line()+
scale_x_continuous(breaks = seq(1990,2021,1))+
scale_y_continuous(labels = comma)+
labs(title = "Exportaciones del 2005 al 2021",
subtitle = "Cifras trimestrales desentralizadas: Millones de dolares",
x = "Año",
y = expression(EXP[t]))+
theme(axis.text.x = element_text(angle=90,
hjust=1))
Creamos una funcion de curtosis para acoplarla en nuestra funion de resumen estadistico
### Se requiere modeest para asimetría
library(modeest)
## Warning: package 'modeest' was built under R version 4.2.1
## Registered S3 method overwritten by 'rmutil':
## method from
## print.response httr
## Registered S3 method overwritten by 'statip':
## method from
## predict.default forecast
##
## Attaching package: 'modeest'
## The following object is masked from 'package:forecast':
##
## naive
### Se crea una funcion para la curtosis
kurtosis <- function(x){
n <- length(x)
x_mean <- mean(x)
sd_x <- sd(x)
z <- sum((x - x_mean)^4)/(n*sd_x^4)
z
}
Creamos una funcion de resumen estadisticos para realizar un analisis estsdistico de la varibles a estudiar
### Se crea la funcion de resumen estadistico
Resumen_estadistico <- function(x){
Observaciones <- length(x)
Media <- mean(x)
Mediana <- median(x)
Varianza <- var(x)
`Desviación estándar`=sd(x)
Minimo<-min(x)
Maximo <-max(x)
Rango <- Maximo-Minimo
`1er cuartil`<-quantile(x, c(0.25))
`3er cuartil`<-quantile(x, c(0.75))
`Rango intercuartil`<-`3er cuartil`-`1er cuartil`
`Datos atípicos mayores`<-`1er cuartil` + (1.5*`Rango intercuartil`)
`Datos atípicos menores`<-`1er cuartil` - (1.5*`Rango intercuartil`)
`Datos atípicos`<-sum(x<=`Datos atípicos menores`,
x>=`Datos atípicos mayores`)
Asimetría <- skewness(x)
Curtosis <- kurtosis(x)
Datos <- c(Observaciones, Media, Mediana,
Varianza, `Desviación estándar`,
Minimo, Maximo, Rango, `1er cuartil`,
`3er cuartil`,`Rango intercuartil`,
`Datos atípicos`, Asimetría,
Curtosis)
Estadisticos <- c("Observaciones","Media", "Mediana",
"Varianza", "Desviación estándar",
"Minimo", "Maximo", "Rango", "1er cuartil",
"3er cuartil","Rango intercuartil",
"Datos atípicos", "Asimetría",
"Curtosis")
DF <- data.frame(Estadisticos, round(Datos,2))
colnames(DF)<-c("Estadísticos", "Resultados")
DF
}
Descripcion estadistica basica del PIB
print(Resumen_estadistico(PIB_ts))
## Estadísticos Resultados
## 1 Observaciones 1.280000e+02
## 2 Media 7.438770e+06
## 3 Mediana 6.666937e+06
## 4 Varianza 7.514600e+12
## 5 Desviación estándar 2.741277e+06
## 6 Minimo 3.587595e+06
## 7 Maximo 1.309857e+07
## 8 Rango 9.510979e+06
## 9 1er cuartil 5.233332e+06
## 10 3er cuartil 9.689144e+06
## 11 Rango intercuartil 4.455813e+06
## 12 Datos atípicos 9.000000e+00
## 13 Asimetría 5.100000e-01
## 14 Curtosis 1.960000e+00
Descripcion estadistica basica de la Importacion
print(Resumen_estadistico(IMP_ts))
## Estadísticos Resultados
## 1 Observaciones 1.280000e+02
## 2 Media 2.265136e+06
## 3 Mediana 2.132732e+06
## 4 Varianza 9.273854e+11
## 5 Desviación estándar 9.630085e+05
## 6 Minimo 7.703828e+05
## 7 Maximo 4.135669e+06
## 8 Rango 3.365286e+06
## 9 1er cuartil 1.480278e+06
## 10 3er cuartil 3.136426e+06
## 11 Rango intercuartil 1.656149e+06
## 12 Datos atípicos 4.000000e+00
## 13 Asimetría 3.600000e-01
## 14 Curtosis 1.820000e+00
Descripcion estadistica basica de la Exportacion
print(Resumen_estadistico(EXP_ts))
## Estadísticos Resultados
## 1 Observaciones 1.280000e+02
## 2 Media 2.113162e+06
## 3 Mediana 2.247232e+06
## 4 Varianza 7.273430e+11
## 5 Desviación estándar 8.528441e+05
## 6 Minimo 7.955729e+05
## 7 Maximo 3.698199e+06
## 8 Rango 2.902626e+06
## 9 1er cuartil 1.297719e+06
## 10 3er cuartil 2.876571e+06
## 11 Rango intercuartil 1.578853e+06
## 12 Datos atípicos 1.000000e+00
## 13 Asimetría 4.000000e-02
## 14 Curtosis 1.570000e+00
Funcion adicional para el histograma
histDenNorm <- function (x, ...) {
hist(x, ...) # Histograma
lines(density(x), col = "blue", lwd = 2) # Densidad
x2 <- seq(min(x), max(x), length = 40)
f <- dnorm(x2, mean(x), sd(x))
lines(x2, f, col = "red", lwd = 2) # Normal
legend("topright", c("Histograma", "Densidad", "Normal"), box.lty = 0,
lty = 1, col = c("black", "blue", "red"), lwd = c(1, 2, 2))
}
histDenNorm(PIB_ts, prob = TRUE,
main = "Histograma con curva de densidad y normal",xlab = "PIB", ylab = "Densidad",
width = 4)
histDenNorm(IMP_ts, prob = TRUE,
main = "Histograma con curva de densidad y normal",xlab = "Importacion", ylab = "Densidad", width = 4)
histDenNorm(EXP_ts, prob = TRUE,
main = "Histograma con curva de densidad y normal",xlab = "Exportacion", ylab = "Densidad", width = 4)
qqnorm (PIB_ts, main = 'QQ Plot for Normality', xlab = 'Theoretical Dist',
ylab = 'Sample dist', col = 'steelblue')
qqline (PIB_ts, col = 'red', lwd = 2, lty = 2)
qqnorm (IMP_ts, main = 'QQ Plot for Normality', xlab = 'Theoretical Dist',
ylab = 'Sample dist', col = 'steelblue')
qqline (IMP_ts, col = 'red', lwd = 2, lty = 2)
qqnorm (EXP_ts, main = 'QQ Plot for Normality', xlab = 'Theoretical Dist',
ylab = 'Sample dist', col = 'steelblue')
qqline (EXP_ts, col = 'red', lwd = 2, lty = 2)
Descompocision temporal con dplyr y ggplot2 y descompose - PIB
PIB_Desc <- data.frame(fecha = time(PIB_ts),
PIB_ts=PIB_ts,
estacional=decompose(PIB_ts)$seasonal,
tendencia=decompose(PIB_ts)$trend,
aleatorio=decompose(PIB_ts)$random)
Grafico con ggplot decopomse
PIB_Desc %>%
gather("id_var", "valores", -fecha) %>%
ggplot(aes(x=fecha, y=valores))+
geom_line(aes(color=id_var))+
facet_wrap(.~id_var,scale="free_y")+
theme_minimal()+
theme(legend.position = "none")+
labs(title = 'Descompocicion de la serie PIB',
subtitle = 'Observacion, Tendencia, Estacionalidad y Aleatoriedad',
caption = 'Elaboracion propia con datos del INE - Bolivia',
x='',
y='')
## Don't know how to automatically pick scale for object of type ts. Defaulting to continuous.
## Don't know how to automatically pick scale for object of type ts. Defaulting to continuous.
Descompocision temporal con dplyr y ggplot2 y descompose - Importacion
IMP_Desc <- data.frame(fecha = time(IMP_ts),
IMP_ts=IMP_ts,
estacional=decompose(IMP_ts)$seasonal,
tendencia=decompose(IMP_ts)$trend,
aleatorio=decompose(IMP_ts)$random)
Grafico con ggplot decopomse
IMP_Desc %>%
gather("id_var", "valores", -fecha) %>%
ggplot(aes(x=fecha, y=valores))+
geom_line(aes(color=id_var))+
facet_wrap(.~id_var,scale="free_y")+
theme_minimal()+
theme(legend.position = "none")+
labs(title = 'Descompocicion de la serie Importacion',
subtitle = 'Observacion, Tendencia, Estacionalidad y Aleatoriedad',
caption = 'Elaboracion propia con datos del INE - Bolivia',
x='',
y='')
## Don't know how to automatically pick scale for object of type ts. Defaulting to continuous.
## Don't know how to automatically pick scale for object of type ts. Defaulting to continuous.
Descompocision temporal con dplyr y ggplot2 y descompose - Exportacion
EXP_Desc <- data.frame(fecha = time(EXP_ts),
EXP_ts=EXP_ts,
estacional=decompose(EXP_ts)$seasonal,
tendencia=decompose(EXP_ts)$trend,
aleatorio=decompose(EXP_ts)$random)
Grafico con ggplot decopomse
EXP_Desc %>%
gather("id_var", "valores", -fecha) %>%
ggplot(aes(x=fecha, y=valores))+
geom_line(aes(color=id_var))+
facet_wrap(.~id_var,scale="free_y")+
theme_minimal()+
theme(legend.position = "none")+
labs(title = 'Descompocicion de la serie Exportacion',
subtitle = 'Observacion, Tendencia, Estacionalidad y Aleatoriedad',
caption = 'Elaboracion propia con datos del INE - Bolivia',
x='',
y='')
## Don't know how to automatically pick scale for object of type ts. Defaulting to continuous.
## Don't know how to automatically pick scale for object of type ts. Defaulting to continuous.
ACF_s<-Acf(PIB_ts, plot=F) %>%
autoplot()+
labs(title = 'Función de autocorrelación simple',
subtitle = 'Serie: PIB en I(0)',
x='Rezagos',
y=expression(rho[t]))
PACF_s<-Pacf(PIB_ts, plot=F) %>%
autoplot()+
labs(title = 'Función de autocorrelación parcial',
subtitle = 'Serie: PIB en I(0)',
x='Rezagos',
y=expression(rho[t]))
library(gridExtra)
##
## Attaching package: 'gridExtra'
## The following object is masked from 'package:dplyr':
##
## combine
grid.arrange(ACF_s, PACF_s, ncol=2)
ACF_s<-Acf(IMP_ts, plot=F) %>%
autoplot()+
labs(title = 'Función de autocorrelación simple',
subtitle = 'Serie: PIB en I(0)',
x='Rezagos',
y=expression(rho[t]))
PACF_s<-Pacf(IMP_ts, plot=F) %>%
autoplot()+
labs(title = 'Función de autocorrelación parcial',
subtitle = 'Serie: PIB en I(0)',
x='Rezagos',
y=expression(rho[t]))
grid.arrange(ACF_s, PACF_s, ncol=2)
ACF_s<-Acf(EXP_ts, plot=F) %>%
autoplot()+
labs(title = 'Función de autocorrelación simple',
subtitle = 'Serie: PIB en I(0)',
x='Rezagos',
y=expression(rho[t]))
PACF_s<-Pacf(EXP_ts, plot=F) %>%
autoplot()+
labs(title = 'Función de autocorrelación parcial',
subtitle = 'Serie: PIB en I(0)',
x='Rezagos',
y=expression(rho[t]))
grid.arrange(ACF_s, PACF_s, ncol=2)
Creamos la funcion de Dickey-Fuller para un analisis y toma de deciciones mas precisa
ADF_test <- function(x, alpha=0.05){
# Requiere tseries y tidyverse
adf<-adf.test(x)
df<-data.frame(adf[1],adf[2],adf[4])
names(df)<-c("Estadístico", "Rezagos", "Probabilidad")
df<-df %>%
mutate(Decisión=ifelse(Probabilidad>alpha, "No rechazar H0",
"Rechazar H0"),
Conclusión =ifelse(Probabilidad>alpha, "No estacionariedad",
"Estacionariedad"))
df
}
print(ADF_test(PIB_ts, alpha=0.05))
## Estadístico Rezagos Probabilidad Decisión
## Dickey-Fuller -1.862664 5 0.6336117 No rechazar H0
## Conclusión
## Dickey-Fuller No estacionariedad
print(ADF_test(IMP_ts, alpha=0.05))
## Estadístico Rezagos Probabilidad Decisión Conclusión
## Dickey-Fuller -3.522549 5 0.04311245 Rechazar H0 Estacionariedad
print(ADF_test(EXP_ts, alpha=0.05))
## Estadístico Rezagos Probabilidad Decisión
## Dickey-Fuller -1.738702 5 0.6851389 No rechazar H0
## Conclusión
## Dickey-Fuller No estacionariedad
Creamos la funcion de Phillips-Perron para un analisis y toma de deciciones mas precisa
PP_test <- function(x, alpha=0.05){
# Requiere tseries y tidyverse
pp<-pp.test(x)
df<-data.frame(pp[1],pp[2],pp[4])
names(df)<-c("Estadístico", "Rezagos", "Probabilidad")
df<-df %>%
mutate(Decisión=ifelse(Probabilidad>alpha, "No rechazar H0",
"Rechazar H0"),
Conclusión =ifelse(Probabilidad>alpha, "No estacionariedad",
"Estacionariedad"))
df
}
print(PP_test(PIB_ts))
## Warning in pp.test(x): p-value smaller than printed p-value
## Estadístico Rezagos Probabilidad Decisión
## Dickey-Fuller Z(alpha) -68.2251 4 0.01 Rechazar H0
## Conclusión
## Dickey-Fuller Z(alpha) Estacionariedad
print(PP_test(IMP_ts))
## Warning in pp.test(x): p-value smaller than printed p-value
## Estadístico Rezagos Probabilidad Decisión
## Dickey-Fuller Z(alpha) -54.91026 4 0.01 Rechazar H0
## Conclusión
## Dickey-Fuller Z(alpha) Estacionariedad
print(PP_test(EXP_ts))
## Warning in pp.test(x): p-value smaller than printed p-value
## Estadístico Rezagos Probabilidad Decisión
## Dickey-Fuller Z(alpha) -38.45301 4 0.01 Rechazar H0
## Conclusión
## Dickey-Fuller Z(alpha) Estacionariedad
Creamos la funcion de KPSS para un analisis y toma de deciciones mas precisa
KPSS_test <- function(x, alpha=0.05){
# Requiere tseries y tidyverse
kpss<-kpss.test(x)
df<-data.frame(kpss[1],kpss[2],kpss[3])
names(df)<-c("Estadístico", "Rezagos", "Probabilidad")
df<-df %>%
mutate(Decisión=ifelse(Probabilidad>alpha, "No rechazar H0",
"Rechazar H0"),
Conclusión =ifelse(Probabilidad>alpha, "Estacionariedad",
"No estacionariedad"))
df
}
print(KPSS_test(PIB_ts))
## Warning in kpss.test(x): p-value smaller than printed p-value
## Estadístico Rezagos Probabilidad Decisión Conclusión
## KPSS Level 2.572395 4 0.01 Rechazar H0 No estacionariedad
print(KPSS_test(IMP_ts))
## Warning in kpss.test(x): p-value smaller than printed p-value
## Estadístico Rezagos Probabilidad Decisión Conclusión
## KPSS Level 2.490414 4 0.01 Rechazar H0 No estacionariedad
print(KPSS_test(EXP_ts))
## Warning in kpss.test(x): p-value smaller than printed p-value
## Estadístico Rezagos Probabilidad Decisión Conclusión
## KPSS Level 2.467742 4 0.01 Rechazar H0 No estacionariedad
regresion_lm <-lm(PIB_ts~IMP_ts+EXP_ts)
summary(regresion_lm)
##
## Call:
## lm(formula = PIB_ts ~ IMP_ts + EXP_ts)
##
## Residuals:
## Min 1Q Median 3Q Max
## -2438642 -451510 -108139 364855 3310451
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.197e+06 2.226e+05 5.376 3.60e-07 ***
## IMP_ts 2.002e+00 2.273e-01 8.810 8.84e-15 ***
## EXP_ts 8.072e-01 2.567e-01 3.145 0.00208 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 937900 on 125 degrees of freedom
## Multiple R-squared: 0.8848, Adjusted R-squared: 0.8829
## F-statistic: 480 on 2 and 125 DF, p-value: < 2.2e-16
Interpretacion
El PIB con respecto a las variables explicativas que son la importación y exportación se relaciona positivamente, en concreto el aumento en una unidad en la variable IMP aumenta en media de 2.0025 al PIB, así mismo, el aumento en una unidad en la variable EXP obtendrá un aumenta en la media de 0.807. Con respecto al R-squared se evidencia que las variables independientes explican en un 88% porciento el comportamiento de la variable objetivo (PIB).
res <- regresion_lm$residuals
res_df <- data.frame(res) %>%
mutate(res_lag1=lag(res, k=-1))
ggplot(res_df, aes(x=res_lag1, y=res))+
geom_point()+
scale_x_continuous(labels = comma)+
scale_y_continuous(labels = comma)+
labs(x=expression(u[t-1]),
y=expression(u[t]),
title = 'Grafico de correlacion',
subtitle = expression(u[t]~u[t-1]),
caption = 'Modelo 1: Sin transformacion en las series')
Interpretacion En el grafico de dispercion observamos
que los residuos vienen a estar dispersos ligeramente, pero con una
tendencia positiva, lo que a primera vista se evidencia un problema de
autocorrelacion
library(lmtest)
## Loading required package: zoo
##
## Attaching package: 'zoo'
## The following objects are masked from 'package:base':
##
## as.Date, as.Date.numeric
DW_lm <- dwtest(regresion_lm)
print(DW_lm)
##
## Durbin-Watson test
##
## data: regresion_lm
## DW = 0.8228, p-value = 3.971e-12
## alternative hypothesis: true autocorrelation is greater than 0
Interpretacion La prueba con un p-value inferior al 5% nos indica aceptar la hipotesis alterna el cual evidenciaria un problema de autocorrelacion.
BP_test <- function(y, x1, x2){
BP_regresion <- lm(I(y^2)~x1+x2)
R2_BP <- summary(BP_regresion)$r.squared
Chi_BP <- nobs(BP_regresion)*R2_BP
Chi_critico <- qchisq(0.05, df=2, lower.tail = F)
prob_chi2 <- pchisq(Chi_BP, df=2, lower.tail = F)
BP_manual <- data.frame(Chi2=Chi_BP,
Chi2_critico = Chi_critico,
prob_chi2 =prob_chi2) %>%
mutate(Decisión=ifelse(Chi2<Chi2_critico,
"Homocedasticidad",
"Heterocedasticidad"))
BP_manual
}
Breusch_pagan <- BP_test(regresion_lm$residuals,
IMP_ts, EXP_ts)
print(Breusch_pagan)
## Chi2 Chi2_critico prob_chi2 Decisión
## 1 20.40018 5.991465 3.716696e-05 Heterocedasticidad
print(ADF_test(regresion_lm$residuals, alpha=0.05))
## Estadístico Rezagos Probabilidad Decisión
## Dickey-Fuller -2.060856 5 0.5512288 No rechazar H0
## Conclusión
## Dickey-Fuller No estacionariedad
print(PP_test(regresion_lm$residuals))
## Warning in pp.test(x): p-value smaller than printed p-value
## Estadístico Rezagos Probabilidad Decisión
## Dickey-Fuller Z(alpha) -61.33549 4 0.01 Rechazar H0
## Conclusión
## Dickey-Fuller Z(alpha) Estacionariedad
print(KPSS_test(regresion_lm$residuals))
## Estadístico Rezagos Probabilidad Decisión Conclusión
## KPSS Level 0.4914933 4 0.04358259 Rechazar H0 No estacionariedad
### Jarque-Bera
jarque_bera <- function(x){
M2=(x-mean(x))^2
M3=(x-mean(x))^3
M4=(x-mean(x))^4
n<-length(x)
Asimetria <- (sum(M3)/n)/((sum(M2)/n)^(3/2))
Kurtosis <- (sum(M4)/n)/((sum(M2)/n)^(2))
JB_manual <- (n/6)*(Asimetria^2+(1/4)*(Kurtosis-3)^2)
Chi_critico <- qchisq(0.05, df=2, lower.tail = F)
Prob_JB_manual <- pchisq(JB_manual, df=2, lower.tail = F)
JB_resultado <- data.frame(JB_manual, Chi_critico,
Prob_JB_manual) %>%
mutate(Decisión = ifelse(JB_manual < Chi_critico,
"Normalidad",
"No normalidad"))
names(JB_resultado)<-c("Jarque-Bera",
"Chi-Critico",
"Probabilidad",
"Regla")
JB_resultado
}
JB_manual <- jarque_bera(regresion_lm$residuals)
print(JB_manual)
## Jarque-Bera Chi-Critico Probabilidad Regla
## 1 32.86399 5.991465 7.305915e-08 No normalidad
library(car)
## Loading required package: carData
##
## Attaching package: 'car'
## The following object is masked from 'package:dplyr':
##
## recode
## The following object is masked from 'package:purrr':
##
## some
VIF <- vif(regresion_lm)
print(VIF)
## IMP_ts EXP_ts
## 6.918732 6.918732
Interpretacion Segun los resultados del Factor de inflación de varianza (VIF) podemos evidenciar un problema leve de multicolinealidad esto tomando como parametro del VIF => 5.
Realizamos la primera diferencia logaritmica a la variables de estudio, por lo que las variables tomarian un comportamiento de tasas porcentuales.
TC_PIB <- diff(log(x = PIB_ts))
TC_PIB
## Qtr1 Qtr2 Qtr3 Qtr4
## 1990 0.090156374 0.002051915 0.015438302
## 1991 -0.082812408 0.137041048 -0.016351476 0.014715061
## 1992 -0.103837391 0.124662454 -0.032045457 0.023837122
## 1993 -0.076438720 0.142024625 -0.056949214 0.027998372
## 1994 -0.056177733 0.101927092 0.003854726 -0.016562427
## 1995 -0.037975999 0.096365046 -0.012208200 0.010694955
## 1996 -0.059152435 0.115966028 -0.026289115 0.007230229
## 1997 -0.049948519 0.124451509 -0.043196868 0.020753498
## 1998 -0.036665678 0.107301286 -0.045612995 0.013292174
## 1999 -0.067584090 0.090945187 -0.044604255 0.047876309
## 2000 -0.073516170 0.117493962 -0.081705748 0.057352262
## 2001 -0.093214633 0.126555702 -0.065111289 0.062958943
## 2002 -0.110675241 0.150715979 -0.066282243 0.035230862
## 2003 -0.087026745 0.149991531 -0.089213751 0.059409751
## 2004 -0.077260324 0.142881726 -0.065319212 0.025964761
## 2005 -0.059990563 0.138329073 -0.066947220 0.041762498
## 2006 -0.069951989 0.133068370 -0.049069496 0.036549635
## 2007 -0.095635056 0.148235057 -0.037100239 0.043756868
## 2008 -0.091412104 0.151345044 -0.035434812 0.016576190
## 2009 -0.103425285 0.144042855 -0.021559309 0.026179238
## 2010 -0.116964121 0.149465466 -0.022247745 0.044768399
## 2011 -0.112021265 0.131206467 -0.013036008 0.045380509
## 2012 -0.114667198 0.125269536 -0.011078025 0.062834206
## 2013 -0.110753857 0.127435698 -0.009125050 0.050805786
## 2014 -0.111694083 0.116857377 0.002541988 0.042809870
## 2015 -0.115283881 0.121122137 -0.010094377 0.056964303
## 2016 -0.115843815 0.100799588 0.006316525 0.044921340
## 2017 -0.119162393 0.105101186 0.011048782 0.054030062
## 2018 -0.122073885 0.104340450 0.002752130 0.047184028
## 2019 -0.123874573 0.100018264 -0.001316752 0.035694364
## 2020 -0.132364136 -0.186238978 0.167881561 0.160278007
## 2021 -0.148070728 0.027693605 0.013462498 0.109228784
ggplot(data=TC_PIB, aes(x=time(TC_PIB),
y=TC_PIB))+
geom_line()+
scale_x_continuous(breaks = seq(1990,2021,1))+
labs(title = 'Tasa de crecimiento: Producto Interno Bruto del 1990 al 2021',
subtitle = 'Cifras trimestrales desestacionalizadas: %',
x='Año',
y=expression(paste(Delta, PIB[t])))+
theme(axis.text.x = element_text(angle=90,
hjust=1))
## Don't know how to automatically pick scale for object of type ts. Defaulting to continuous.
TC_IMP <- diff(log(x = IMP_ts))
TC_IMP
## Qtr1 Qtr2 Qtr3 Qtr4
## 1990 0.0868467113 0.1181569350 0.1856983458
## 1991 -0.3148873230 0.2242620470 0.0398164072 0.1089973139
## 1992 -0.1231747927 0.0034205227 0.1155653242 0.0260445286
## 1993 -0.2645215354 0.1593864155 -0.0413677220 0.2851724475
## 1994 -0.3803735954 0.0718704348 0.1262289914 0.1113510857
## 1995 -0.1372378973 0.1658459310 -0.1384207748 0.0318598503
## 1996 -0.1414103800 0.1659806695 0.1154749231 0.1220661950
## 1997 -0.1561334299 0.0332650188 0.1130223273 0.0718960119
## 1998 -0.0343924506 0.0924169950 0.0645144993 0.0639681783
## 1999 -0.2165584675 -0.2007676323 0.0431894213 0.2079802391
## 2000 -0.0736591292 -0.0007901434 -0.0057813376 0.0035375834
## 2001 -0.1435420171 0.1047364224 -0.0211455578 0.0895408055
## 2002 -0.0631505355 0.1218182048 0.0364539215 -0.0243260282
## 2003 -0.1614998282 0.1339414460 -0.0009638921 0.1482683301
## 2004 -0.2261927781 0.1252416815 -0.0071667670 0.1769092028
## 2005 -0.1376260036 0.1327001339 0.0093853592 0.0556297708
## 2006 -0.0514751398 0.0663566068 -0.0286788987 -0.0443123079
## 2007 0.0401156674 -0.0350400490 0.1769925458 -0.1214917302
## 2008 0.0720511092 0.0473052275 0.0251767060 -0.0670851116
## 2009 -0.1162767234 -0.0741001390 0.0909787003 0.1626331852
## 2010 -0.0948598671 -0.0079616399 0.0168117728 0.1943211335
## 2011 -0.0277250471 -0.0719228583 0.1966117634 -0.0422085405
## 2012 0.0220193649 -0.1496997183 0.1314255943 0.0716267530
## 2013 0.0077408432 -0.1648378764 0.1689501786 0.1042258291
## 2014 0.0431557449 -0.1861932166 0.2485162410 -0.0340115769
## 2015 -0.0417666810 -0.2013388814 0.1646053522 0.0162957294
## 2016 -0.0071941580 -0.1670881069 0.0602689774 0.0657765596
## 2017 0.0803726716 -0.1683876659 0.1120067887 0.0262213664
## 2018 0.0339944746 -0.1381322989 0.0469677613 0.1252319256
## 2019 0.0087880855 -0.0885646448 -0.0006897305 -0.0337740949
## 2020 0.0678279338 -0.7389940609 0.3345891392 0.1814400929
## 2021 0.1146083416 -0.1777510732 0.0431144274 0.2173332065
ggplot(data=TC_IMP, aes(x=time(TC_IMP),
y=TC_IMP))+
geom_line()+
scale_x_continuous(breaks = seq(1990,2021,1))+
labs(title = 'Tasa de crecimiento: Importaciones del 1990 al 2021',
subtitle = 'Cifras trimestrales desestacionalizadas: %',
x='Año',
y=expression(paste(Delta, IMP[t])))+
theme(axis.text.x = element_text(angle=90,
hjust=1))
## Don't know how to automatically pick scale for object of type ts. Defaulting to continuous.
TC_EXP <- diff(log(x = EXP_ts))
TC_EXP
## Qtr1 Qtr2 Qtr3 Qtr4
## 1990 0.032296365 0.083082857 0.008758185
## 1991 -0.086524152 0.097360416 0.151632125 -0.204781384
## 1992 -0.024301888 0.136678481 -0.032172521 0.021747423
## 1993 -0.214557873 0.226117935 0.059358588 0.097681083
## 1994 -0.142808035 0.098961365 0.113849975 -0.005526630
## 1995 -0.135359834 0.227259854 -0.047559027 -0.005622982
## 1996 -0.109267836 0.112458323 0.133774476 -0.124329160
## 1997 -0.126858854 0.152034775 -0.035589785 0.037683979
## 1998 -0.161674889 0.152521341 0.112739419 0.005129062
## 1999 -0.389801384 0.209631730 -0.060757664 0.114907883
## 2000 -0.100219302 0.135100495 -0.016350715 0.155873839
## 2001 -0.212588791 0.108272596 0.046997689 0.173809393
## 2002 -0.325985059 0.215134611 -0.013722941 0.176742508
## 2003 -0.257520292 0.104446417 0.092806989 0.251194776
## 2004 -0.220061495 0.089355356 0.054478808 0.113838762
## 2005 -0.201707237 0.162426510 0.034513101 0.033266790
## 2006 -0.073557682 0.201910713 -0.005991237 -0.206897340
## 2007 -0.034467919 0.269098894 -0.054677974 -0.007045411
## 2008 0.004433370 0.094949740 -0.123885382 -0.099733321
## 2009 -0.057674647 0.073692397 0.010570381 -0.004330786
## 2010 0.048428134 0.035650917 0.012445920 -0.029821576
## 2011 -0.014286945 0.081005970 0.044628325 -0.070026935
## 2012 -0.033592387 0.156660373 0.084996885 0.017194667
## 2013 -0.091424741 0.014840608 0.020250362 0.079462775
## 2014 -0.042492423 0.066960050 0.027354501 0.032853982
## 2015 -0.237894201 0.155257584 -0.007951508 0.032067623
## 2016 -0.196595963 0.104911153 0.043763217 -0.083032745
## 2017 -0.154665961 0.157735318 0.044612721 -0.096490912
## 2018 -0.071816201 0.190513514 0.011724414 -0.064195291
## 2019 -0.169121539 0.208848517 0.032941676 -0.115264175
## 2020 -0.162862579 -0.266669705 0.236143765 0.189073104
## 2021 -0.266741901 0.258467055 0.041574531 0.022638707
ggplot(data=TC_EXP, aes(x=time(TC_EXP),
y=TC_EXP))+
geom_line()+
scale_x_continuous(breaks = seq(1990,2021,1))+
labs(title = 'Tasa de crecimiento: Exportaciones del 1990 al 2021',
subtitle = 'Cifras trimestrales desestacionalizadas: %',
x='Año',
y=expression(paste(Delta, EXP[t])))+
theme(axis.text.x = element_text(angle=90,
hjust=1))
## Don't know how to automatically pick scale for object of type ts. Defaulting to continuous.
Mod_tran <- lm(TC_PIB~TC_IMP+TC_EXP)
summary(Mod_tran)
##
## Call:
## lm(formula = TC_PIB ~ TC_IMP + TC_EXP)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.140467 -0.042240 0.000742 0.050100 0.128905
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.005184 0.005600 0.926 0.356
## TC_IMP 0.030563 0.041596 0.735 0.464
## TC_EXP 0.438126 0.044718 9.798 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.06279 on 124 degrees of freedom
## Multiple R-squared: 0.4845, Adjusted R-squared: 0.4761
## F-statistic: 58.26 on 2 and 124 DF, p-value: < 2.2e-16
Interpretacion
El PIB con respecto a las variables explicativas que son la importación y exportación se relaciona positivamente, en concreto el aumento en 1% en la variable TC_IMP aumenta en media el PIB en un 0.03% , así mismo, el aumento en 1% en la variable TC_EXP obtendrá un aumento en el PIB del 0.43%. Con respecto al R-squared se evidencia que las variables independientes explican en un 48% porciento el comportamiento de la variable objetivo (PIB).
res <- Mod_tran$residuals
res_df <- data.frame(res) %>%
mutate(res_lag1=lag(res, k=-1))
ggplot(res_df, aes(x=res_lag1, y=res))+
geom_point()+
scale_x_continuous(labels = comma)+
scale_y_continuous(labels = comma)+
labs(x=expression(u[t-1]),
y=expression(u[t]),
title = 'Grafico de correlacion',
subtitle = expression(u[t]~u[t-1]),
caption = 'Modelo 2: Con transformacion en las series')
Interpretacion En el grafico de dispercion observamos que los residuos vienen a estar dispersos ligeramente, pero con una tendencia negativa, lo que a primera vista evidencia un problema de autocorrelacion
DW_lm <- dwtest(Mod_tran)
print(DW_lm)
##
## Durbin-Watson test
##
## data: Mod_tran
## DW = 3.0593, p-value = 1
## alternative hypothesis: true autocorrelation is greater than 0
Interpretacion La prueba con un p-value inferior al 5% nos indica aceptar la hipotesis alterna el cual evidenciaria un problema de autocorrelacion.
Breusch_pagan <- BP_test(Mod_tran$residuals,
TC_IMP, TC_EXP)
print(Breusch_pagan)
## Chi2 Chi2_critico prob_chi2 Decisión
## 1 0.5751074 5.991465 0.7500963 Homocedasticidad
print(ADF_test(Mod_tran$residuals, alpha=0.05))
## Warning in adf.test(x): p-value smaller than printed p-value
## Estadístico Rezagos Probabilidad Decisión Conclusión
## Dickey-Fuller -4.571198 5 0.01 Rechazar H0 Estacionariedad
print(PP_test(Mod_tran$residuals))
## Warning in pp.test(x): p-value smaller than printed p-value
## Estadístico Rezagos Probabilidad Decisión
## Dickey-Fuller Z(alpha) -169.5642 4 0.01 Rechazar H0
## Conclusión
## Dickey-Fuller Z(alpha) Estacionariedad
print(KPSS_test(Mod_tran$residuals))
## Warning in kpss.test(x): p-value greater than printed p-value
## Estadístico Rezagos Probabilidad Decisión Conclusión
## KPSS Level 0.09862712 4 0.1 No rechazar H0 Estacionariedad
JB_manual <- jarque_bera(Mod_tran$residuals)
print(JB_manual)
## Jarque-Bera Chi-Critico Probabilidad Regla
## 1 3.140328 5.991465 0.2080111 Normalidad
VIF <- vif(Mod_tran)
print(VIF)
## TC_IMP TC_EXP
## 1.146036 1.146036
Interpretacion Segun los resultados del Factor de inflación de varianza (VIF) podemos evidenciar la no existencia de multicolinealidad esto tomando como parametro del VIF => 5.
TC_PIB_hat <- Mod_tran$fitted.values
TC_PIB_hat <- ts(TC_PIB_hat, start = c(1990,2),
frequency = 4)
ggplot(data=TC_PIB, aes(x=time(TC_PIB), y=TC_PIB,
colour='TC_PIB'))+
geom_line()+
geom_line(data=TC_PIB_hat, aes(x=time(TC_PIB_hat),
y=TC_PIB_hat,
colour='TC_PIB_Estimado'))+
scale_x_continuous(breaks = seq(1990,2021,1))+
scale_y_continuous(labels = comma)+
scale_colour_manual(values = c("red", "steelblue"))+
labs(title = 'Valores reales / Valores estimados',
subtitle = 'Cifras desestacionalizadas: Porcentaje',
y='Valores',
x='Año')+
theme(axis.text.x = element_text(angle=90,
hjust=1))
PIB_log <- cumsum(c(log(PIB_ts)[1], Mod_tran$fitted.values))
PIB_hat <- ts(exp(PIB_log), start = c(1990,1), frequency = 4)
ggplot(data=PIB_ts, aes(x=time(PIB_ts), y=PIB_ts,
colour='PIB_ts'))+
geom_line()+
geom_line(data=PIB_hat, aes(x=time(PIB_hat),
y=PIB_hat,
colour='PIB_hat'))+
scale_x_continuous(breaks = seq(1990,2021,1))+
scale_y_continuous(labels = comma)+
scale_colour_manual(values = c("red", "steelblue"))+
labs(title = 'Valores reales / Valores estimados',
subtitle = 'Cifras desestacionalizadas: Millones de pesos',
y='Valores',
x='Año')+
theme(axis.text.x = element_text(angle=90,
hjust=1))
TC_IMP_hat <- Mod_tran$fitted.values
TC_IMP_hat <- ts(TC_IMP_hat, start = c(1990,2),
frequency = 4)
ggplot(data=TC_IMP, aes(x=time(TC_IMP), y=TC_IMP,
colour='TC_IMP'))+
geom_line()+
geom_line(data=TC_IMP_hat, aes(x=time(TC_IMP_hat),
y=TC_IMP_hat,
colour='TC_IMP_Estimado'))+
scale_x_continuous(breaks = seq(1990,2021,1))+
scale_y_continuous(labels = comma)+
scale_colour_manual(values = c("red", "steelblue"))+
labs(title = 'Valores reales / Valores estimados',
subtitle = 'Cifras desestacionalizadas: Porcentaje',
y='Valores',
x='Año')+
theme(axis.text.x = element_text(angle=90,
hjust=1))
IMP_log <- cumsum(c(log(IMP_ts)[1], Mod_tran$fitted.values))
IMP_hat <- ts(exp(IMP_log), start = c(1990,1), frequency = 4)
ggplot(data=IMP_ts, aes(x=time(IMP_ts), y=IMP_ts,
colour='IMP_ts'))+
geom_line()+
geom_line(data=IMP_hat, aes(x=time(IMP_hat),
y=IMP_hat,
colour='IMP_hat'))+
scale_x_continuous(breaks = seq(1990,2021,1))+
scale_y_continuous(labels = comma)+
scale_colour_manual(values = c("red", "steelblue"))+
labs(title = 'Valores reales / Valores estimados',
subtitle = 'Cifras desestacionalizadas: Millones de pesos',
y='Valores',
x='Año')+
theme(axis.text.x = element_text(angle=90,
hjust=1))
TC_EXP_hat <- Mod_tran$fitted.values
TC_EXP_hat <- ts(TC_EXP_hat, start = c(1990,2),
frequency = 4)
ggplot(data=TC_EXP, aes(x=time(TC_EXP), y=TC_EXP,
colour='TC_EXP'))+
geom_line()+
geom_line(data=TC_EXP_hat, aes(x=time(TC_EXP_hat),
y=TC_EXP_hat,
colour='TC_EXP_Estimado'))+
scale_x_continuous(breaks = seq(1990,2021,1))+
scale_y_continuous(labels = comma)+
scale_colour_manual(values = c("red", "steelblue"))+
labs(title = 'Valores reales / Valores estimados',
subtitle = 'Cifras desestacionalizadas: Porcentaje',
y='Valores',
x='Año')+
theme(axis.text.x = element_text(angle=90,
hjust=1))
EXP_log <- cumsum(c(log(EXP_ts)[1], Mod_tran$fitted.values))
EXP_hat <- ts(exp(EXP_log), start = c(1990,1), frequency = 4)
ggplot(data=EXP_ts, aes(x=time(EXP_ts), y=EXP_ts,
colour='EXP_ts'))+
geom_line()+
geom_line(data=EXP_hat, aes(x=time(EXP_hat),
y=EXP_hat,
colour='EXP_hat'))+
scale_x_continuous(breaks = seq(1990,2021,1))+
scale_y_continuous(labels = comma)+
scale_colour_manual(values = c("red", "steelblue"))+
labs(title = 'Valores reales / Valores estimados',
subtitle = 'Cifras desestacionalizadas: Millones de pesos',
y='Valores',
x='Año')+
theme(axis.text.x = element_text(angle=90,
hjust=1))
Podemos concluir que el modelo si bien una vez echa la transformacion se pudo corregir los problemas obtenidos sin la transformacion esto a excepcion de la autocorrelacion, que este biene siendo un problema desde el origen, el modelo tiene problemas en la prediccion de la serie con el uso de valores reales y valores estimados, este problema podria tener origen en la poca explicacion de las variables independientes en el comportamiento de la variable objetivo, una posible solucion seria el incorporar variables que se relacionen y expliquen mejor el comportamiento de la varible objetivo.
Instituto Nacional de Estadística (INE). Bolivia: oferta y demanda final a precios constantes por componente según trimestre, 1990 – 2022. https://www.ine.gob.bo/
GUJARATI, N.D. & POTER, C.D.(2010). Econometría (5ta. ED.). Mc- GrawHill, México.
GREENE, W. (1998). Análisis econométrico (3ra ED.). Prentice-Hall, España.
Mariam Kiziryan, 27 de mayo, 2015 Importación. Economipedia.com
Javier Montes de Oca, 14 de mayo, 2015 Exportación. Economipedia.com
Andrés Sevilla Arias, 23 de marzo, 2012 Producto interior bruto (PIB). Economipedia.com