- Briefly describe what is time series analysis.
Time series analysis is a technique in statistics for analyzing a sequence of data points collected over an interval of time. This technique deals with time series data and trend analysis in order to show how variables change over time and can also help detect dependencies between the analyzed variables. In order to make a precise and reliable time series analysis you require a large number of data points to detect trend, patterns and any strange behavior of the data. Time series analysis is also used to forecast future data based on historical data.
As we learnt before, Nearshoring is the relocation of business projects as part of a reconstruction within the supply chain. This relocation consists of shortening the supply chain by bringing the production centers closer and consequently, both production costs and risks for the company are reduced. Mexico has some benefits that might attract nearshoring investment projects, and one of the latest trends of Nearshoring in Mexico is: “The Rise of Cross-Border Logistics in US-MX”. This trend consists in Border logistics increasing within United States companies, since when seeking to reduce their costs, they take advantage of their proximity to Mexico. American companies seek to relocate and maintain their regional supply chains and mention that by making these movements in Mexico, they manage to reduce costs and risks. In the other hand, the Increased Trade between the U.S. and Mexico is also a trend that implies significant changes that nearshoring bring to the relationship between the U.S. and Mexico. The demand trade between both countries is increasing and has already reaches $614.5 billion in the past years.
- What is the problem situation? How to address the problem situation? In the first part of this problem situation, we focused on discovering what are the conditions that Mexico offers to attract Nearshoring by applying the regression analysis methos. Now we have a different focus, which is discovering the trend that Foreign Investment Flow will have in the future, for this we’ll be applying a Time series Analysis. When applying this analyisis we use the historical data in order to forecast the next periods, as well as analyzing how the past data of different variables such as: Education, Innovation, Exchange Rate, etc, might have an impact in the behavior of actual and future data.
# Install libraries
library(xts)
## Loading required package: zoo
##
## Attaching package: 'zoo'
## The following objects are masked from 'package:base':
##
## as.Date, as.Date.numeric
library(dplyr)
##
## ######################### Warning from 'xts' package ##########################
## # #
## # The dplyr lag() function breaks how base R's lag() function is supposed to #
## # work, which breaks lag(my_xts). Calls to lag(my_xts) that you type or #
## # source() into this session won't work correctly. #
## # #
## # Use stats::lag() to make sure you're not using dplyr::lag(), or you can add #
## # conflictRules('dplyr', exclude = 'lag') to your .Rprofile to stop #
## # dplyr from breaking base R's lag() function. #
## # #
## # Code in packages is not affected. It's protected by R's namespace mechanism #
## # Set `options(xts.warn_dplyr_breaks_lag = FALSE)` to suppress this warning. #
## # #
## ###############################################################################
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:xts':
##
## first, last
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
library(zoo)
library(tseries)
## Registered S3 method overwritten by 'quantmod':
## method from
## as.zoo.data.frame zoo
library(stats)
library(forecast)
library(astsa)
##
## Attaching package: 'astsa'
## The following object is masked from 'package:forecast':
##
## gas
library(corrplot)
## corrplot 0.92 loaded
library(AER)
## Loading required package: car
## Loading required package: carData
##
## Attaching package: 'car'
## The following object is masked from 'package:dplyr':
##
## recode
## Loading required package: lmtest
## Loading required package: sandwich
## Loading required package: survival
library(vars)
## Loading required package: MASS
##
## Attaching package: 'MASS'
## The following object is masked from 'package:dplyr':
##
## select
## Loading required package: strucchange
## Loading required package: urca
library(dynlm)
library(vars)
library(TSstudio)
library(forecast)
library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ forcats 1.0.0 ✔ readr 2.1.4
## ✔ ggplot2 3.4.3 ✔ stringr 1.5.0
## ✔ lubridate 1.9.2 ✔ tibble 3.2.1
## ✔ purrr 1.0.2 ✔ tidyr 1.3.0
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ stringr::boundary() masks strucchange::boundary()
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::first() masks xts::first()
## ✖ dplyr::lag() masks stats::lag()
## ✖ dplyr::last() masks xts::last()
## ✖ car::recode() masks dplyr::recode()
## ✖ MASS::select() masks dplyr::select()
## ✖ purrr::some() masks car::some()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(sarima)
## Loading required package: stats4
##
## Attaching package: 'sarima'
##
## The following object is masked from 'package:astsa':
##
## sarima
##
## The following object is masked from 'package:stats':
##
## spectrum
library(dygraphs)
library(readxl)
library(lubridate)
data2<-read_excel("/Users/yessicaacosta/Desktop/SP_DataMexicoAtractiveness_alumn-TS.xlsx",sheet=1, range="A6:R32",na="-")
data2
## # A tibble: 26 × 18
## Año IED_Flujos IED_Flujos_MXN Exportaciones Exportaciones_MXN Empleo
## <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 1997 12146. 294298. 9088. 220201. NA
## 2 1998 8374. 210849. 9875. 248659. NA
## 3 1999 13960. 299834. 10990. 236039. NA
## 4 2000 18249. 362638. 12483. 248061. 97.8
## 5 2001 30057. 546448. 11300. 205445. 97.4
## 6 2002 24099. 468391. 11923. 231737. 97.7
## 7 2003 18250. 368747. 13156 265822. 97.1
## 8 2004 25016. 481300. 13573. 261147. 96.5
## 9 2005 25796. 458581. 16466. 292718. 97.2
## 10 2006 21233. 368329. 17486. 303335. 96.5
## # ℹ 16 more rows
## # ℹ 12 more variables: Educación <dbl>, Salario_Diario <dbl>, Innovación <dbl>,
## # Inseguridad_Robo <dbl>, Inseguridad_Homicidio <dbl>, Tipo_de_Cambio <dbl>,
## # Densidad_Carretera <dbl>, Densidad_Población <dbl>, CO2_Emisiones <dbl>,
## # PIB_Per_Cápita <dbl>, INPC <dbl>, Crisis_Financiera <dbl>
data1<-read_excel("/Users/yessicaacosta/Desktop/SP_DataMexicoAtractiveness_alumn-TS.xlsx", sheet=2, range="B5:E101",na="-")
data1
## # A tibble: 96 × 4
## Año Trimestre IED_Flujos IED_Flujos_MXN
## <dbl> <chr> <dbl> <dbl>
## 1 1999 I 3596. 77235.
## 2 1999 II 3396. 72936.
## 3 1999 III 3028. 65044.
## 4 1999 IV 3940. 84620.
## 5 2000 I 4601. 91424.
## 6 2000 II 4857. 96527.
## 7 2000 III 3057. 60748.
## 8 2000 IV 5734. 113940.
## 9 2001 I 3599. 65425.
## 10 2001 II 5219. 94880.
## # ℹ 86 more rows
# Showing database structure
str(data2)
## tibble [26 × 18] (S3: tbl_df/tbl/data.frame)
## $ Año : num [1:26] 1997 1998 1999 2000 2001 ...
## $ IED_Flujos : num [1:26] 12146 8374 13960 18249 30057 ...
## $ IED_Flujos_MXN : num [1:26] 294298 210849 299834 362638 546448 ...
## $ Exportaciones : num [1:26] 9088 9875 10990 12483 11300 ...
## $ Exportaciones_MXN : num [1:26] 220201 248659 236039 248061 205445 ...
## $ Empleo : num [1:26] NA NA NA 97.8 97.4 ...
## $ Educación : num [1:26] 7.2 7.31 7.43 7.56 7.68 ...
## $ Salario_Diario : num [1:26] 24.3 31.9 31.9 35.1 37.6 ...
## $ Innovación : num [1:26] 11.3 11.4 12.5 13.1 13.5 ...
## $ Inseguridad_Robo : num [1:26] 267 315 273 217 215 ...
## $ Inseguridad_Homicidio: num [1:26] 14.6 14.3 12.6 10.9 10.2 ...
## $ Tipo_de_Cambio : num [1:26] 8.06 9.94 9.52 9.6 9.17 ...
## $ Densidad_Carretera : num [1:26] 0.0521 0.053 0.055 0.0552 0.0565 ...
## $ Densidad_Población : num [1:26] 47.4 48.8 49.5 50.6 51.3 ...
## $ CO2_Emisiones : num [1:26] 3.68 3.85 3.69 3.87 3.81 ...
## $ PIB_Per_Cápita : num [1:26] 127570 126739 129165 130875 128083 ...
## $ INPC : num [1:26] 33.3 39.5 44.3 48.3 50.4 ...
## $ Crisis_Financiera : num [1:26] 0 0 0 0 0 0 0 0 0 0 ...
str(data1)
## tibble [96 × 4] (S3: tbl_df/tbl/data.frame)
## $ Año : num [1:96] 1999 1999 1999 1999 2000 ...
## $ Trimestre : chr [1:96] "I" "II" "III" "IV" ...
## $ IED_Flujos : num [1:96] 3596 3396 3028 3940 4601 ...
## $ IED_Flujos_MXN: num [1:96] 77235 72936 65044 84620 91424 ...
After showing data structure we can see al variables are numeric, as well as the year, this means we might transform this columns later. In the other hand, we appear to have null values in the Employment column.
# Filling na's with median value
colSums(is.na(data2))
## Año IED_Flujos IED_Flujos_MXN
## 0 0 0
## Exportaciones Exportaciones_MXN Empleo
## 0 0 3
## Educación Salario_Diario Innovación
## 3 0 2
## Inseguridad_Robo Inseguridad_Homicidio Tipo_de_Cambio
## 0 1 0
## Densidad_Carretera Densidad_Población CO2_Emisiones
## 0 0 3
## PIB_Per_Cápita INPC Crisis_Financiera
## 0 0 0
data2 <- data2 %>%
mutate_all(~ifelse(is.na(.),median(., na.rm = TRUE),.))
print(data2)
## # A tibble: 26 × 18
## Año IED_Flujos IED_Flujos_MXN Exportaciones Exportaciones_MXN Empleo
## <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 1997 12146. 294298. 9088. 220201. 96.5
## 2 1998 8374. 210849. 9875. 248659. 96.5
## 3 1999 13960. 299834. 10990. 236039. 96.5
## 4 2000 18249. 362638. 12483. 248061. 97.8
## 5 2001 30057. 546448. 11300. 205445. 97.4
## 6 2002 24099. 468391. 11923. 231737. 97.7
## 7 2003 18250. 368747. 13156 265822. 97.1
## 8 2004 25016. 481300. 13573. 261147. 96.5
## 9 2005 25796. 458581. 16466. 292718. 97.2
## 10 2006 21233. 368329. 17486. 303335. 96.5
## # ℹ 16 more rows
## # ℹ 12 more variables: Educación <dbl>, Salario_Diario <dbl>, Innovación <dbl>,
## # Inseguridad_Robo <dbl>, Inseguridad_Homicidio <dbl>, Tipo_de_Cambio <dbl>,
## # Densidad_Carretera <dbl>, Densidad_Población <dbl>, CO2_Emisiones <dbl>,
## # PIB_Per_Cápita <dbl>, INPC <dbl>, Crisis_Financiera <dbl>
We filled the NA’s with the median value in order to reduce extreme data and make a better forecast eventually.
# Transforming to Data format
data2$Año <- as.yearmon(paste(data2$Año, "01", sep = "-"))
head(data2)
## # A tibble: 6 × 18
## Año IED_Flujos IED_Flujos_MXN Exportaciones Exportaciones_MXN Empleo
## <yearmon> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 Jan 1997 12146. 294298. 9088. 220201. 96.5
## 2 Jan 1998 8374. 210849. 9875. 248659. 96.5
## 3 Jan 1999 13960. 299834. 10990. 236039. 96.5
## 4 Jan 2000 18249. 362638. 12483. 248061. 97.8
## 5 Jan 2001 30057. 546448. 11300. 205445. 97.4
## 6 Jan 2002 24099. 468391. 11923. 231737. 97.7
## # ℹ 12 more variables: Educación <dbl>, Salario_Diario <dbl>, Innovación <dbl>,
## # Inseguridad_Robo <dbl>, Inseguridad_Homicidio <dbl>, Tipo_de_Cambio <dbl>,
## # Densidad_Carretera <dbl>, Densidad_Población <dbl>, CO2_Emisiones <dbl>,
## # PIB_Per_Cápita <dbl>, INPC <dbl>, Crisis_Financiera <dbl>
str(data2)
## tibble [26 × 18] (S3: tbl_df/tbl/data.frame)
## $ Año : 'yearmon' num [1:26] Jan 1997 Jan 1998 Jan 1999 Jan 2000 ...
## $ IED_Flujos : num [1:26] 12146 8374 13960 18249 30057 ...
## $ IED_Flujos_MXN : num [1:26] 294298 210849 299834 362638 546448 ...
## $ Exportaciones : num [1:26] 9088 9875 10990 12483 11300 ...
## $ Exportaciones_MXN : num [1:26] 220201 248659 236039 248061 205445 ...
## $ Empleo : num [1:26] 96.5 96.5 96.5 97.8 97.4 ...
## $ Educación : num [1:26] 7.2 7.31 7.43 7.56 7.68 ...
## $ Salario_Diario : num [1:26] 24.3 31.9 31.9 35.1 37.6 ...
## $ Innovación : num [1:26] 11.3 11.4 12.5 13.1 13.5 ...
## $ Inseguridad_Robo : num [1:26] 267 315 273 217 215 ...
## $ Inseguridad_Homicidio: num [1:26] 14.6 14.3 12.6 10.9 10.2 ...
## $ Tipo_de_Cambio : num [1:26] 8.06 9.94 9.52 9.6 9.17 ...
## $ Densidad_Carretera : num [1:26] 0.0521 0.053 0.055 0.0552 0.0565 ...
## $ Densidad_Población : num [1:26] 47.4 48.8 49.5 50.6 51.3 ...
## $ CO2_Emisiones : num [1:26] 3.68 3.85 3.69 3.87 3.81 ...
## $ PIB_Per_Cápita : num [1:26] 127570 126739 129165 130875 128083 ...
## $ INPC : num [1:26] 33.3 39.5 44.3 48.3 50.4 ...
## $ Crisis_Financiera : num [1:26] 0 0 0 0 0 0 0 0 0 0 ...
We transform the year into Month-year date format in order to have time series data and make an accurate time series model.
data1$Trimestre[data1$Trimestre == "I"] <- 01
data1$Trimestre[data1$Trimestre == "II"] <- 02
data1$Trimestre[data1$Trimestre == "III"] <- 03
data1$Trimestre[data1$Trimestre == "IV"] <- 04
print(data1$Trimestre)
## [1] "1" "2" "3" "4" "1" "2" "3" "4" "1" "2" "3" "4" "1" "2" "3" "4" "1" "2" "3"
## [20] "4" "1" "2" "3" "4" "1" "2" "3" "4" "1" "2" "3" "4" "1" "2" "3" "4" "1" "2"
## [39] "3" "4" "1" "2" "3" "4" "1" "2" "3" "4" "1" "2" "3" "4" "1" "2" "3" "4" "1"
## [58] "2" "3" "4" "1" "2" "3" "4" "1" "2" "3" "4" "1" "2" "3" "4" "1" "2" "3" "4"
## [77] "1" "2" "3" "4" "1" "2" "3" "4" "1" "2" "3" "4" "1" "2" "3" "4" "1" "2" "3"
## [96] "4"
# Concatenar las columnas 'Año' y 'Trimestre'
data1$Date <- paste(data1$Año, data1$Trimestre, sep = "/")
# Ver el resultado
print(data1)
## # A tibble: 96 × 5
## Año Trimestre IED_Flujos IED_Flujos_MXN Date
## <dbl> <chr> <dbl> <dbl> <chr>
## 1 1999 1 3596. 77235. 1999/1
## 2 1999 2 3396. 72936. 1999/2
## 3 1999 3 3028. 65044. 1999/3
## 4 1999 4 3940. 84620. 1999/4
## 5 2000 1 4601. 91424. 2000/1
## 6 2000 2 4857. 96527. 2000/2
## 7 2000 3 3057. 60748. 2000/3
## 8 2000 4 5734. 113940. 2000/4
## 9 2001 1 3599. 65425. 2001/1
## 10 2001 2 5219. 94880. 2001/2
## # ℹ 86 more rows
data1$Date
## [1] "1999/1" "1999/2" "1999/3" "1999/4" "2000/1" "2000/2" "2000/3" "2000/4"
## [9] "2001/1" "2001/2" "2001/3" "2001/4" "2002/1" "2002/2" "2002/3" "2002/4"
## [17] "2003/1" "2003/2" "2003/3" "2003/4" "2004/1" "2004/2" "2004/3" "2004/4"
## [25] "2005/1" "2005/2" "2005/3" "2005/4" "2006/1" "2006/2" "2006/3" "2006/4"
## [33] "2007/1" "2007/2" "2007/3" "2007/4" "2008/1" "2008/2" "2008/3" "2008/4"
## [41] "2009/1" "2009/2" "2009/3" "2009/4" "2010/1" "2010/2" "2010/3" "2010/4"
## [49] "2011/1" "2011/2" "2011/3" "2011/4" "2012/1" "2012/2" "2012/3" "2012/4"
## [57] "2013/1" "2013/2" "2013/3" "2013/4" "2014/1" "2014/2" "2014/3" "2014/4"
## [65] "2015/1" "2015/2" "2015/3" "2015/4" "2016/1" "2016/2" "2016/3" "2016/4"
## [73] "2017/1" "2017/2" "2017/3" "2017/4" "2018/1" "2018/2" "2018/3" "2018/4"
## [81] "2019/1" "2019/2" "2019/3" "2019/4" "2020/1" "2020/2" "2020/3" "2020/4"
## [89] "2021/1" "2021/2" "2021/3" "2021/4" "2022/1" "2022/2" "2022/3" "2022/4"
data1$quarter=as.yearqtr(data1$Date,format="%Y/%q")
head(data1)
## # A tibble: 6 × 6
## Año Trimestre IED_Flujos IED_Flujos_MXN Date quarter
## <dbl> <chr> <dbl> <dbl> <chr> <yearqtr>
## 1 1999 1 3596. 77235. 1999/1 1999 Q1
## 2 1999 2 3396. 72936. 1999/2 1999 Q2
## 3 1999 3 3028. 65044. 1999/3 1999 Q3
## 4 1999 4 3940. 84620. 1999/4 1999 Q4
## 5 2000 1 4601. 91424. 2000/1 2000 Q1
## 6 2000 2 4857. 96527. 2000/2 2000 Q2
- IED_Flujos: Exports Millions of Dollars Non-Petroleum Exports. Value of exports from the Maquiladora Export Industry is included.
- Empleo: Percentage Rate Percentage of the Economically Active Employed Population.
- Educación: Average Years of Education.
- Salario_Diario: Pesos Minimum wage in daily pesos.
- Innovación: Patent Rate per 100,000 inhabitants Number of patents requested in Mexico.
- Inseguridad_Robo: Theft Rate per 100,000 inhabitants Violent robberies in homes, vehicles, pedestrians, transporters, banking institutions, businesses, livestock, machinery, auto parts, mainly.
- Tipo_de_Cambio: Pesos per dollar FIX exchange rate.
- Densidad_Población: Population per km2 The population number is divided by the territorial area of Mexico in km2.
- PIB_Per_Cápita: Real 2013 MXN Pesos Gross Domestic Product (GDP) divided by population. Value adjusted for 2013 prices.
- INPC: ÍPrice index National Consumer Price Index (INPC). Base 2018 = 100.
Flujos2<-ts(data2$IED_Flujos_MXN,start=c(1997,01),end=c(2022,01),frequency=1)
plot(data2$Año,data2$IED_Flujos_MXN,type="l",col="blue",lwd=2,xlab="Date",ylab="IED_Flujos",main="Flujos")
After plotting th independent variable we can see that Foreign
investment flow has had many peaks and drops over the years, we see a
constant drop starting approximately in 2016. IED had a significant drop
in 2020, we can assume it happened because of the pandemic, bt it seems
to starting growing for the future years.
# Time Series Format
Flujos<-ts(data1$IED_Flujos_MXN,start=c(1999,01),end=c(2022,04),frequency=4)
plot(data1$quarter,Flujos,type="l",col="blue",lwd=2,xlab="Date",ylab="IED_Flujos",main="Flujos")
This time series appears to don’t have a specific trend and to be
constant through time. This means it might be a stationary serie.
Flujosdec<-decompose(Flujos)
plot(Flujosdec)
This is the decomoposition of out time series, here we can see it has a
particular trend with many drops and peaks that don’t show a specific
trend. In the season part er can see a pattern that means there are come
high points in each interval. Finally, in the random part we can see
that there are unknown factors after 2000, before 2015 that caused a
peak in the time series.
adf.test(Flujos) # non-stationary (p-value > 0.05)
##
## Augmented Dickey-Fuller Test
##
## data: Flujos
## Dickey-Fuller = -3.3111, Lag order = 4, p-value = 0.07383
## alternative hypothesis: stationary
Box.test(Flujos,lag=1,type="Ljung-Box")
##
## Box-Ljung test
##
## data: Flujos
## X-squared = 0.054511, df = 1, p-value = 0.8154
acf(Flujos, main= "Serial Correlation Plot")
The LJUNG Box test drops a p-value >0.05, which means there’s no
presence of serial correlation.
####a. Time Series Model 1*
# Here we transform the independent variable to make it stationar, this will make better forcast and smooth the model.
log_Flujos<-diff(log(data1$IED_Flujos_MXN))
# First order (t-1), it transforms the serie to stationary
summary(Flujos_ARMA<-arma(log_Flujos),order=c(1,1))
##
## Call:
## arma(x = log_Flujos)
##
## Model:
## ARMA(1,1)
##
## Residuals:
## Min 1Q Median 3Q Max
## -1.82230 -0.20371 0.05846 0.32862 1.31285
##
## Coefficient(s):
## Estimate Std. Error t value Pr(>|t|)
## ar1 0.066091 0.120783 0.547 0.584
## ma1 -0.927325 0.063231 -14.666 <2e-16 ***
## intercept 0.002948 0.004893 0.602 0.547
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Fit:
## sigma^2 estimated as 0.289, Conditional Sum-of-Squares = 26.9, AIC = 157.67
In the summary of Model1 - ARMA we can se we have an AIC statistic of 157.67.
Flujos_ARIMA <- Arima(log_Flujos,order=c(1,1,1))
summary(Flujos_ARIMA)
## Series: log_Flujos
## ARIMA(1,1,1)
##
## Coefficients:
## ar1 ma1
## -0.2861 -1.0000
## s.e. 0.0987 0.0297
##
## sigma^2 = 0.4469: log likelihood = -97.08
## AIC=200.16 AICc=200.43 BIC=207.79
##
## Training set error measures:
## ME RMSE MAE MPE MAPE MASE
## Training set -0.02520049 0.6578468 0.5052593 67.35795 203.6826 0.5753086
## ACF1
## Training set -0.1548131
In the summary of Model1 - ARMA we can se we have an AIC statistic of -155
# Ho: There is no serial autocorrelation
# H1: There is serial autocorrelation
Flujos_ARMA_residuals<-Flujos_ARMA$residuals
Box.test(Flujos_ARMA_residuals,lag=1,type="Ljung-Box")
##
## Box-Ljung test
##
## data: Flujos_ARMA_residuals
## X-squared = 0.049024, df = 1, p-value = 0.8248
The LJUNG Box test drops a p-value >0.05, which means there’s no presence of serial correlation.
#Testing residuals
Flujos_ARMA$fitted.values <- na.omit(Flujos_ARMA$fitted.values)
Flujos_ARMA$residuals <- na.omit(Flujos_ARMA$residuals)
adf.test(Flujos_ARMA$residuals)
##
## Augmented Dickey-Fuller Test
##
## data: Flujos_ARMA$residuals
## Dickey-Fuller = -3.4505, Lag order = 4, p-value = 0.05108
## alternative hypothesis: stationary
The residuals of our ARMA model drop a p-value slightly>0.05, which still means the residuals of this model are non-stationary.
hist(Flujos_ARMA$residuals)
adf.test(Flujos_ARMA$fitted.values)
##
## Augmented Dickey-Fuller Test
##
## data: Flujos_ARMA$fitted.values
## Dickey-Fuller = -3.5595, Lag order = 4, p-value = 0.04094
## alternative hypothesis: stationary
As we can see, the resul of the adf test drops a p-value<0.05, which means that our time series data is stationary.
plot(log_Flujos,type="l",ylab="IED Flujos",main = "IED Flujos")
At first glance it’s seems to be a stationary time series model.
# Ho: There is no serial autocorrelation
# H1: There is serial autocorrelation
Flujos_ARIMA_residuals<-Flujos_ARIMA$residuals
Box.test(Flujos_ARIMA_residuals,lag=1,type="Ljung-Box") # Reject the Ho. P-value is < 0.05 indicating that ARMA Model does show residual serial autocorrelation.
##
## Box-Ljung test
##
## data: Flujos_ARIMA_residuals
## X-squared = 2.3495, df = 1, p-value = 0.1253
The adf test drops a p-value<0.05, which means we don’t have serial autocorrelation between residuals.
# Testing residuals
hist(Flujos_ARIMA$residuals)
adf.test(Flujos_ARIMA$residuals)
##
## Augmented Dickey-Fuller Test
##
## data: Flujos_ARIMA$residuals
## Dickey-Fuller = -5.3578, Lag order = 4, p-value = 0.01
## alternative hypothesis: stationary
After applying the adf test to the residuals we get a p-value<0.05, which means the residuals of the ARIMA model residuals are stationary.
#Testing ts values
adf.test(Flujos_ARIMA$fitted)
##
## Augmented Dickey-Fuller Test
##
## data: Flujos_ARIMA$fitted
## Dickey-Fuller = -5.7991, Lag order = 4, p-value = 0.01
## alternative hypothesis: stationary
The adf test drops a p-value<0.05, which means we have a stationary time series data.
After both model testing and diagnosis, we can conclude that the ARMA model has the better results to make a better forecast. Model 1- ARMA has an AIC of 157, while Model 2 - has an AIC of 200. In the other hand, model 1 - ARMA might make a better forecast because it is a stationary time series, as well as its residuals.
Flujos_revert<-c(exp(Flujos_ARMA$fitted.values))
FlSog<-c(data1$IED_Flujos_MXN)
sum_values<- Flujos_revert+FlSog
## Warning in Flujos_revert + FlSog: longer object length is not a multiple of
## shorter object length
og_flujos <- ts(sum_values,start=1,end=length(sum_values),frequency = 1)
og_flujos
## Time Series:
## Start = 1
## End = 96
## Frequency = 1
## [1] 77236.02 72936.64 65044.63 84620.48 91424.64 96527.94 60748.34
## [8] 113940.91 65425.76 94880.06 296594.75 89550.10 98501.93 121641.17
## [15] 118838.81 129412.93 80088.61 112087.73 50952.18 125622.85 180154.35
## [22] 83724.38 63202.48 154223.19 120204.46 120417.88 97401.55 120560.74
## [29] 129010.15 115090.29 40708.08 83525.66 181308.06 102887.27 127877.95
## [36] 130945.84 169877.32 166492.62 112179.71 137871.05 110957.70 110757.03
## [43] 43573.89 59119.29 144128.66 153702.94 64988.90 86463.40 151503.43
## [50] 120348.73 78165.21 110583.64 127235.19 90632.63 92474.20 40595.50
## [57] 164880.05 327826.75 65175.38 196280.83 233692.21 92591.75 54453.58
## [64] 132198.43 236327.81 129627.29 187631.08 146337.97 287498.47 139438.13
## [71] 96929.21 176372.28 276715.56 136844.72 127748.61 141833.62 276771.97
## [78] 188439.01 81315.29 124386.42 270356.77 115884.18 146398.99 83374.84
## [85] 306635.89 133074.49 24459.66 50421.86 283424.76 102900.16 112269.93
## [92] 53241.62 349890.11 125323.31 53413.92 27281.90
Flujos_estimate<-exp(og_flujos)
Flujos_forecast<-forecast(og_flujos,h=5)
print(Flujos_forecast)
## Point Forecast Lo 80 Hi 80 Lo 95 Hi 95
## 97 139819.5 38326.80 241312.3 -15400.22 295039.3
## 98 139819.5 38210.71 241428.4 -15577.75 295216.8
## 99 139819.5 38094.70 241544.4 -15755.18 295394.2
## 100 139819.5 37978.75 241660.3 -15932.50 295571.6
## 101 139819.5 37862.87 241776.2 -16109.73 295748.8
After making the forecast we obtained different predicted values por the next 5 periods, for the first predicted value we have a Foreign Investment Flow between $-15400.22 and $295039.3, while in the last period we have predicted values between $-161109.73 and $295748. We also have a linear point forecast of $139819.5
# Plotting the forecast of the next 5 periods
plot(Flujos_forecast,xlab="Date",ylab="IED_Flujos (MXN)", main = "IED_Flujos")
After making a forecast we obtain a linear forecast, this might be
because of the frequency selected. Anyways, we can also see in the graph
that we have a similar trend from the past periods of time.
We select the independent variables that might explain Nearshoring in Mexico and converting them in time series format.
## Time series format
exportaciones<-ts(data2$Exportaciones_MXN,start=c(1999),end=c(2022),frequency=1)
empleo<-ts(data2$Empleo,start=c(1999),end=c(2022),frequency=1)
innovación<-ts(data2$Innovación,start=c(1999),end=c(2022),frequency=1)
inseguridad<-ts(data2$Inseguridad_Robo,start=c(1999),end=c(2022),frequency=1)
salario<-ts(data2$Salario_Diario,start=c(1999),end=c(2022),frequency=1)
educación<-ts(data2$Educación,start=c(1999),end=c(2022),frequency=1)
cambio<-ts(data2$Tipo_de_Cambio,start=c(1999),end=c(2022),frequency=1)
- Exportations: The increase in exportations might afect in a positive way foreign direct investment. - Employment: The increase in exportations might have a positive impact in de Foreign investment flows in Mexico. - Innovation: The increase in innovation has a positive impact in the Direct Foreign investment flow in Mexico. - Insecurity: The increase in insecurity might have a negative impact in the Firect Foreign Investment in Mexico - Wage: The increase in Daily Wage Might have a positive impact in the Direct Foreign investment - Education: The increase of the Average Education might have a positive impact in the Direct Foreign Investment un Mexico. - Exchange rate: The increase in the Exchange rate might have a positive impact in the Direct Foreign Investment in Mexico.
# Time series plot describing the selected variables performance over the time period:
par(mfrow=c(3,4))
plot(data2$Año,data2$IED_Flujos_MXN,type="l",col="blue",lwd=2,xlab="Date",ylab="IED_Flujos",main="Foreign Investment Flow")
plot(data2$Año,data2$Exportaciones_MXN,type="l",col="blue",lwd=2,xlab="Date",ylab="Exportations",main="Exportations")
plot(data2$Año,data2$Empleo,type="l",col="blue",lwd=2,xlab="Date",ylab="Employment",main="Employment")
plot(data2$Año,data2$Innovación,type="l",col="blue",lwd=2,xlab="Date",ylab="Innovation",main="Innovation")
plot(data2$Año,data2$Inseguridad_Robo,type="l",col="blue",lwd=2,xlab="Date",ylab="Insecurity",main="Insecurity by thief")
plot(data2$Año,data2$Salario_Diario,type="l",col="blue",lwd=2,xlab="Date",ylab="Daily Wage",main="Daily Wage")
plot(data2$Año,data2$Educación,type="l",col="blue",lwd=2,xlab="Date",ylab="Education",main="Education")
plot(data2$Año,data2$Tipo_de_Cambio,type="l",col="blue",lwd=2,xlab="Date",ylab="Exchange rate",main="Exchange rate")
# Converting variables to time series format
flujos<-ts(data2$IED_Flujos_MXN,start=c(1999),end=c(2022),frequency=12)
exportaciones<-ts(data2$Exportaciones_MXN,start=c(1999),end=c(2022),frequency=12)
empleo<-ts(data2$Empleo,start=c(1999),end=c(2022),frequency=12)
innovación<-ts(data2$Innovación,start=c(1999),end=c(2022),frequency=12)
inseguridad<-ts(data2$Inseguridad_Robo,start=c(1999),end=c(2022),frequency=12)
salario<-ts(data2$Salario_Diario,start=c(1999),end=c(2022),frequency=12)
educación<-ts(data2$Educación,start=c(1999),end=c(2022),frequency=12)
cambio<-ts(data2$Tipo_de_Cambio,start=c(1999),end=c(2022),frequency=12)
VAR_ts<-cbind(flujos,exportaciones,empleo,innovación,inseguridad,salario,educación,cambio)
colnames(VAR_ts)<-cbind("IED_Flujos", "Exportaciones", "Empleo","Innovación","Inseguridad","Salario","Educación","Tipo_de_Cambio")
lag_selection<-VARselect(VAR_ts,lag.max=5,type="const", season=12)
lag_selection$selection
## AIC(n) HQ(n) SC(n) FPE(n)
## 4 4 4 4
lag_selection$criteria
## 1 2 3 4 5
## AIC(n) 4.547006e+01 3.087821e+01 -4.508062e+02 -4.523673e+02 -4.518967e+02
## HQ(n) 4.632159e+01 3.207036e+01 -4.492734e+02 -4.504939e+02 -4.496827e+02
## SC(n) 4.759112e+01 3.384770e+01 -4.469883e+02 -4.477009e+02 -4.463819e+02
## FPE(n) 5.601675e+19 2.586902e+13 1.670311e-196 3.542854e-197 5.758562e-197
When we have a lag of 4 periods we have a lower AIC, so this is what we select.
# We use p=2 to not produce null values in the model and reduce the lags to 2
# Estimating VAR model1.
VAR_model1<-VAR(VAR_ts,p=2,type="const",season=12)
summary(VAR_model1)
##
## VAR Estimation Results:
## =========================
## Endogenous variables: IED_Flujos, Exportaciones, Empleo, Innovación, Inseguridad, Salario, Educación, Tipo_de_Cambio
## Deterministic variables: const
## Sample size: 275
## Log Likelihood: -7139.427
## Roots of the characteristic polynomial:
## 0.9815 0.9815 0.9119 0.9119 0.896 0.896 0.8367 0.8367 0.7999 0.7999 0.6378 0.6378 0.6111 0.6111 0.5215 0.09156
## Call:
## VAR(y = VAR_ts, p = 2, type = "const", season = 12L)
##
##
## Estimation results for equation IED_Flujos:
## ===========================================
## IED_Flujos = IED_Flujos.l1 + Exportaciones.l1 + Empleo.l1 + Innovación.l1 + Inseguridad.l1 + Salario.l1 + Educación.l1 + Tipo_de_Cambio.l1 + IED_Flujos.l2 + Exportaciones.l2 + Empleo.l2 + Innovación.l2 + Inseguridad.l2 + Salario.l2 + Educación.l2 + Tipo_de_Cambio.l2 + const + sd1 + sd2 + sd3 + sd4 + sd5 + sd6 + sd7 + sd8 + sd9 + sd10 + sd11
##
## Estimate Std. Error t value Pr(>|t|)
## IED_Flujos.l1 -1.348e-01 6.763e-02 -1.993 0.047364 *
## Exportaciones.l1 2.385e+00 2.283e-01 10.446 < 2e-16 ***
## Empleo.l1 -3.937e+04 1.222e+04 -3.221 0.001448 **
## Innovación.l1 9.203e+03 1.373e+04 0.670 0.503403
## Inseguridad.l1 -1.991e+03 3.790e+02 -5.255 3.21e-07 ***
## Salario.l1 -4.022e+03 4.995e+02 -8.051 3.48e-14 ***
## Educación.l1 3.710e+04 3.071e+04 1.208 0.228062
## Tipo_de_Cambio.l1 -9.726e+04 9.725e+03 -10.001 < 2e-16 ***
## IED_Flujos.l2 1.076e-02 7.640e-02 0.141 0.888083
## Exportaciones.l2 1.645e+00 4.689e-01 3.508 0.000536 ***
## Empleo.l2 5.322e+04 1.180e+04 4.511 1.00e-05 ***
## Innovación.l2 9.904e+03 1.008e+04 0.982 0.326865
## Inseguridad.l2 4.447e+02 1.830e+02 2.430 0.015806 *
## Salario.l2 -7.119e+03 1.191e+03 -5.980 7.80e-09 ***
## Educación.l2 -7.295e+04 3.422e+04 -2.132 0.034022 *
## Tipo_de_Cambio.l2 -3.772e+02 9.334e+03 -0.040 0.967797
## const -1.073e+05 1.697e+06 -0.063 0.949636
## sd1 2.255e+04 1.886e+04 1.195 0.233050
## sd2 7.221e+03 1.816e+04 0.398 0.691239
## sd3 1.250e+04 1.864e+04 0.671 0.503121
## sd4 -1.850e+03 1.799e+04 -0.103 0.918200
## sd5 1.758e+04 1.868e+04 0.941 0.347399
## sd6 -7.352e+03 1.798e+04 -0.409 0.682906
## sd7 2.264e+04 1.881e+04 1.204 0.229881
## sd8 8.619e+03 1.799e+04 0.479 0.632315
## sd9 2.751e+04 1.871e+04 1.471 0.142599
## sd10 3.247e+03 1.795e+04 0.181 0.856617
## sd11 2.298e+04 1.860e+04 1.236 0.217715
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
##
## Residual standard error: 60690 on 247 degrees of freedom
## Multiple R-Squared: 0.8313, Adjusted R-squared: 0.8128
## F-statistic: 45.07 on 27 and 247 DF, p-value: < 2.2e-16
##
##
## Estimation results for equation Exportaciones:
## ==============================================
## Exportaciones = IED_Flujos.l1 + Exportaciones.l1 + Empleo.l1 + Innovación.l1 + Inseguridad.l1 + Salario.l1 + Educación.l1 + Tipo_de_Cambio.l1 + IED_Flujos.l2 + Exportaciones.l2 + Empleo.l2 + Innovación.l2 + Inseguridad.l2 + Salario.l2 + Educación.l2 + Tipo_de_Cambio.l2 + const + sd1 + sd2 + sd3 + sd4 + sd5 + sd6 + sd7 + sd8 + sd9 + sd10 + sd11
##
## Estimate Std. Error t value Pr(>|t|)
## IED_Flujos.l1 2.015e-01 4.723e-02 4.267 2.82e-05 ***
## Exportaciones.l1 9.472e-01 1.595e-01 5.940 9.64e-09 ***
## Empleo.l1 -3.680e+04 8.536e+03 -4.311 2.35e-05 ***
## Innovación.l1 -1.957e+01 9.591e+03 -0.002 0.998373
## Inseguridad.l1 -2.994e+02 2.647e+02 -1.131 0.259139
## Salario.l1 -2.816e+03 3.489e+02 -8.071 3.05e-14 ***
## Educación.l1 -1.172e+05 2.145e+04 -5.465 1.13e-07 ***
## Tipo_de_Cambio.l1 -1.044e+03 6.792e+03 -0.154 0.877990
## IED_Flujos.l2 2.079e-01 5.336e-02 3.895 0.000126 ***
## Exportaciones.l2 6.701e-01 3.275e-01 2.046 0.041835 *
## Empleo.l2 2.224e+04 8.241e+03 2.699 0.007434 **
## Innovación.l2 -4.626e+04 7.041e+03 -6.569 2.97e-10 ***
## Inseguridad.l2 -1.895e+02 1.278e+02 -1.483 0.139443
## Salario.l2 -3.540e+03 8.315e+02 -4.257 2.95e-05 ***
## Educación.l2 1.746e+05 2.390e+04 7.306 3.79e-12 ***
## Tipo_de_Cambio.l2 -1.064e+04 6.519e+03 -1.632 0.104013
## const 1.724e+06 1.185e+06 1.455 0.147022
## sd1 -4.235e+04 1.317e+04 -3.215 0.001481 **
## sd2 7.690e+03 1.268e+04 0.606 0.544849
## sd3 -4.292e+04 1.302e+04 -3.297 0.001122 **
## sd4 5.268e+03 1.257e+04 0.419 0.675414
## sd5 -4.502e+04 1.304e+04 -3.451 0.000656 ***
## sd6 7.802e+03 1.255e+04 0.621 0.534897
## sd7 -3.981e+04 1.314e+04 -3.031 0.002698 **
## sd8 4.773e+03 1.257e+04 0.380 0.704399
## sd9 -4.289e+04 1.306e+04 -3.283 0.001175 **
## sd10 -2.186e+03 1.254e+04 -0.174 0.861713
## sd11 -4.089e+04 1.299e+04 -3.148 0.001846 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
##
## Residual standard error: 42390 on 247 degrees of freedom
## Multiple R-Squared: 0.9547, Adjusted R-squared: 0.9497
## F-statistic: 192.6 on 27 and 247 DF, p-value: < 2.2e-16
##
##
## Estimation results for equation Empleo:
## =======================================
## Empleo = IED_Flujos.l1 + Exportaciones.l1 + Empleo.l1 + Innovación.l1 + Inseguridad.l1 + Salario.l1 + Educación.l1 + Tipo_de_Cambio.l1 + IED_Flujos.l2 + Exportaciones.l2 + Empleo.l2 + Innovación.l2 + Inseguridad.l2 + Salario.l2 + Educación.l2 + Tipo_de_Cambio.l2 + const + sd1 + sd2 + sd3 + sd4 + sd5 + sd6 + sd7 + sd8 + sd9 + sd10 + sd11
##
## Estimate Std. Error t value Pr(>|t|)
## IED_Flujos.l1 2.853e-06 2.274e-07 12.550 < 2e-16 ***
## Exportaciones.l1 6.150e-06 7.676e-07 8.013 4.46e-14 ***
## Empleo.l1 1.484e-02 4.109e-02 0.361 0.718313
## Innovación.l1 8.599e-02 4.617e-02 1.863 0.063716 .
## Inseguridad.l1 -4.893e-03 1.274e-03 -3.841 0.000156 ***
## Salario.l1 -1.694e-02 1.679e-03 -10.090 < 2e-16 ***
## Educación.l1 -3.782e-01 1.032e-01 -3.664 0.000304 ***
## Tipo_de_Cambio.l1 -1.784e-01 3.269e-02 -5.457 1.18e-07 ***
## IED_Flujos.l2 4.782e-07 2.568e-07 1.862 0.063830 .
## Exportaciones.l2 2.000e-08 1.577e-06 0.013 0.989888
## Empleo.l2 3.786e-01 3.967e-02 9.545 < 2e-16 ***
## Innovación.l2 -2.499e-01 3.389e-02 -7.373 2.51e-12 ***
## Inseguridad.l2 7.148e-03 6.152e-04 11.620 < 2e-16 ***
## Salario.l2 -5.731e-03 4.003e-03 -1.432 0.153475
## Educación.l2 -9.837e-01 1.151e-01 -8.550 1.31e-15 ***
## Tipo_de_Cambio.l2 1.983e-01 3.138e-02 6.320 1.21e-09 ***
## const 6.860e+01 5.705e+00 12.025 < 2e-16 ***
## sd1 5.128e-02 6.342e-02 0.809 0.419516
## sd2 -1.921e-02 6.105e-02 -0.315 0.753303
## sd3 6.398e-02 6.266e-02 1.021 0.308266
## sd4 -2.340e-02 6.049e-02 -0.387 0.699259
## sd5 3.719e-02 6.279e-02 0.592 0.554168
## sd6 -6.445e-03 6.043e-02 -0.107 0.915163
## sd7 4.737e-02 6.323e-02 0.749 0.454479
## sd8 4.991e-03 6.049e-02 0.083 0.934307
## sd9 3.878e-02 6.289e-02 0.617 0.537988
## sd10 2.702e-02 6.035e-02 0.448 0.654759
## sd11 5.862e-02 6.252e-02 0.938 0.349336
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
##
## Residual standard error: 0.204 on 247 degrees of freedom
## Multiple R-Squared: 0.9273, Adjusted R-squared: 0.9193
## F-statistic: 116.6 on 27 and 247 DF, p-value: < 2.2e-16
##
##
## Estimation results for equation Innovación:
## ===========================================
## Innovación = IED_Flujos.l1 + Exportaciones.l1 + Empleo.l1 + Innovación.l1 + Inseguridad.l1 + Salario.l1 + Educación.l1 + Tipo_de_Cambio.l1 + IED_Flujos.l2 + Exportaciones.l2 + Empleo.l2 + Innovación.l2 + Inseguridad.l2 + Salario.l2 + Educación.l2 + Tipo_de_Cambio.l2 + const + sd1 + sd2 + sd3 + sd4 + sd5 + sd6 + sd7 + sd8 + sd9 + sd10 + sd11
##
## Estimate Std. Error t value Pr(>|t|)
## IED_Flujos.l1 -8.766e-08 3.857e-07 -0.227 0.820422
## Exportaciones.l1 2.344e-05 1.302e-06 18.002 < 2e-16 ***
## Empleo.l1 -3.008e-01 6.971e-02 -4.314 2.32e-05 ***
## Innovación.l1 1.178e-01 7.833e-02 1.504 0.133825
## Inseguridad.l1 -1.998e-02 2.162e-03 -9.245 < 2e-16 ***
## Salario.l1 -4.437e-02 2.849e-03 -15.571 < 2e-16 ***
## Educación.l1 -1.098e+00 1.751e-01 -6.271 1.59e-09 ***
## Tipo_de_Cambio.l1 -8.170e-01 5.547e-02 -14.729 < 2e-16 ***
## IED_Flujos.l2 8.042e-07 4.358e-07 1.846 0.066154 .
## Exportaciones.l2 1.361e-05 2.675e-06 5.089 7.12e-07 ***
## Empleo.l2 1.992e-02 6.730e-02 0.296 0.767527
## Innovación.l2 9.073e-02 5.750e-02 1.578 0.115901
## Inseguridad.l2 -3.325e-03 1.044e-03 -3.186 0.001629 **
## Salario.l2 -5.464e-02 6.791e-03 -8.046 3.58e-14 ***
## Educación.l2 -5.966e-01 1.952e-01 -3.056 0.002486 **
## Tipo_de_Cambio.l2 -2.023e-01 5.324e-02 -3.800 0.000182 ***
## const 6.027e+01 9.679e+00 6.227 2.03e-09 ***
## sd1 -1.886e-01 1.076e-01 -1.753 0.080917 .
## sd2 -7.622e-02 1.036e-01 -0.736 0.462513
## sd3 -1.882e-01 1.063e-01 -1.770 0.077924 .
## sd4 -2.276e-02 1.026e-01 -0.222 0.824644
## sd5 -1.820e-01 1.065e-01 -1.708 0.088865 .
## sd6 -6.230e-02 1.025e-01 -0.608 0.544017
## sd7 -2.147e-01 1.073e-01 -2.002 0.046413 *
## sd8 -2.580e-02 1.026e-01 -0.251 0.801672
## sd9 -2.141e-01 1.067e-01 -2.007 0.045853 *
## sd10 2.474e-02 1.024e-01 0.242 0.809236
## sd11 -2.076e-01 1.061e-01 -1.957 0.051424 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
##
## Residual standard error: 0.3462 on 247 degrees of freedom
## Multiple R-Squared: 0.9012, Adjusted R-squared: 0.8904
## F-statistic: 83.48 on 27 and 247 DF, p-value: < 2.2e-16
##
##
## Estimation results for equation Inseguridad:
## ============================================
## Inseguridad = IED_Flujos.l1 + Exportaciones.l1 + Empleo.l1 + Innovación.l1 + Inseguridad.l1 + Salario.l1 + Educación.l1 + Tipo_de_Cambio.l1 + IED_Flujos.l2 + Exportaciones.l2 + Empleo.l2 + Innovación.l2 + Inseguridad.l2 + Salario.l2 + Educación.l2 + Tipo_de_Cambio.l2 + const + sd1 + sd2 + sd3 + sd4 + sd5 + sd6 + sd7 + sd8 + sd9 + sd10 + sd11
##
## Estimate Std. Error t value Pr(>|t|)
## IED_Flujos.l1 -1.382e-05 1.660e-05 -0.833 0.40586
## Exportaciones.l1 1.067e-04 5.603e-05 1.905 0.05791 .
## Empleo.l1 5.689e+00 2.999e+00 1.897 0.05900 .
## Innovación.l1 -8.698e+00 3.370e+00 -2.581 0.01043 *
## Inseguridad.l1 5.338e-01 9.299e-02 5.741 2.76e-08 ***
## Salario.l1 -1.008e-02 1.226e-01 -0.082 0.93451
## Educación.l1 -1.357e+00 7.535e+00 -0.180 0.85723
## Tipo_de_Cambio.l1 -7.096e+00 2.386e+00 -2.973 0.00324 **
## IED_Flujos.l2 -2.786e-05 1.875e-05 -1.486 0.13848
## Exportaciones.l2 2.275e-04 1.151e-04 1.977 0.04916 *
## Empleo.l2 -2.588e+01 2.895e+00 -8.940 < 2e-16 ***
## Innovación.l2 2.994e+01 2.474e+00 12.102 < 2e-16 ***
## Inseguridad.l2 -3.414e-02 4.490e-02 -0.760 0.44774
## Salario.l2 3.653e-01 2.922e-01 1.250 0.21238
## Educación.l2 -5.428e+01 8.398e+00 -6.463 5.43e-10 ***
## Tipo_de_Cambio.l2 -3.689e+00 2.291e+00 -1.610 0.10858
## const 2.234e+03 4.164e+02 5.365 1.86e-07 ***
## sd1 2.845e+01 4.629e+00 6.146 3.16e-09 ***
## sd2 -1.160e+00 4.456e+00 -0.260 0.79490
## sd3 3.005e+01 4.574e+00 6.570 2.95e-10 ***
## sd4 -2.414e+00 4.415e+00 -0.547 0.58499
## sd5 2.912e+01 4.583e+00 6.353 1.01e-09 ***
## sd6 -2.024e+00 4.411e+00 -0.459 0.64678
## sd7 2.869e+01 4.615e+00 6.217 2.15e-09 ***
## sd8 -1.217e+00 4.415e+00 -0.276 0.78303
## sd9 3.085e+01 4.590e+00 6.720 1.24e-10 ***
## sd10 4.516e-01 4.405e+00 0.103 0.91842
## sd11 2.958e+01 4.563e+00 6.483 4.86e-10 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
##
## Residual standard error: 14.89 on 247 degrees of freedom
## Multiple R-Squared: 0.9068, Adjusted R-squared: 0.8966
## F-statistic: 88.96 on 27 and 247 DF, p-value: < 2.2e-16
##
##
## Estimation results for equation Salario:
## ========================================
## Salario = IED_Flujos.l1 + Exportaciones.l1 + Empleo.l1 + Innovación.l1 + Inseguridad.l1 + Salario.l1 + Educación.l1 + Tipo_de_Cambio.l1 + IED_Flujos.l2 + Exportaciones.l2 + Empleo.l2 + Innovación.l2 + Inseguridad.l2 + Salario.l2 + Educación.l2 + Tipo_de_Cambio.l2 + const + sd1 + sd2 + sd3 + sd4 + sd5 + sd6 + sd7 + sd8 + sd9 + sd10 + sd11
##
## Estimate Std. Error t value Pr(>|t|)
## IED_Flujos.l1 2.564e-05 1.777e-05 1.443 0.150387
## Exportaciones.l1 2.443e-04 6.000e-05 4.071 6.31e-05 ***
## Empleo.l1 -1.278e+01 3.212e+00 -3.980 9.06e-05 ***
## Innovación.l1 -7.090e+00 3.609e+00 -1.965 0.050588 .
## Inseguridad.l1 -3.942e-01 9.959e-02 -3.958 9.88e-05 ***
## Salario.l1 -7.299e-01 1.313e-01 -5.560 7.00e-08 ***
## Educación.l1 -2.779e+01 8.070e+00 -3.444 0.000673 ***
## Tipo_de_Cambio.l1 -1.750e+00 2.556e+00 -0.685 0.494122
## IED_Flujos.l2 3.076e-05 2.008e-05 1.532 0.126830
## Exportaciones.l2 2.239e-04 1.232e-04 1.816 0.070519 .
## Empleo.l2 8.016e+00 3.101e+00 2.585 0.010307 *
## Innovación.l2 -7.499e+00 2.650e+00 -2.830 0.005032 **
## Inseguridad.l2 2.919e-02 4.809e-02 0.607 0.544364
## Salario.l2 -9.134e-01 3.129e-01 -2.919 0.003832 **
## Educación.l2 2.125e+00 8.994e+00 0.236 0.813458
## Tipo_de_Cambio.l2 -1.214e+00 2.453e+00 -0.495 0.620988
## const 9.178e+02 4.460e+02 2.058 0.040654 *
## sd1 -1.111e+01 4.957e+00 -2.241 0.025897 *
## sd2 2.599e+00 4.772e+00 0.545 0.586505
## sd3 -1.206e+01 4.898e+00 -2.462 0.014511 *
## sd4 2.590e+00 4.729e+00 0.548 0.584383
## sd5 -1.194e+01 4.908e+00 -2.432 0.015716 *
## sd6 3.582e+00 4.724e+00 0.758 0.449087
## sd7 -1.081e+01 4.943e+00 -2.186 0.029745 *
## sd8 1.413e+00 4.728e+00 0.299 0.765296
## sd9 -1.224e+01 4.916e+00 -2.491 0.013402 *
## sd10 -1.457e+00 4.717e+00 -0.309 0.757665
## sd11 -1.139e+01 4.887e+00 -2.331 0.020556 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
##
## Residual standard error: 15.95 on 247 degrees of freedom
## Multiple R-Squared: 0.8078, Adjusted R-squared: 0.7868
## F-statistic: 38.46 on 27 and 247 DF, p-value: < 2.2e-16
##
##
## Estimation results for equation Educación:
## ==========================================
## Educación = IED_Flujos.l1 + Exportaciones.l1 + Empleo.l1 + Innovación.l1 + Inseguridad.l1 + Salario.l1 + Educación.l1 + Tipo_de_Cambio.l1 + IED_Flujos.l2 + Exportaciones.l2 + Empleo.l2 + Innovación.l2 + Inseguridad.l2 + Salario.l2 + Educación.l2 + Tipo_de_Cambio.l2 + const + sd1 + sd2 + sd3 + sd4 + sd5 + sd6 + sd7 + sd8 + sd9 + sd10 + sd11
##
## Estimate Std. Error t value Pr(>|t|)
## IED_Flujos.l1 1.272e-06 1.348e-07 9.437 < 2e-16 ***
## Exportaciones.l1 6.905e-06 4.549e-07 15.178 < 2e-16 ***
## Empleo.l1 -2.750e-01 2.435e-02 -11.291 < 2e-16 ***
## Innovación.l1 1.574e-01 2.736e-02 5.751 2.61e-08 ***
## Inseguridad.l1 3.637e-03 7.551e-04 4.817 2.55e-06 ***
## Salario.l1 -1.282e-02 9.954e-04 -12.875 < 2e-16 ***
## Educación.l1 6.325e-01 6.118e-02 10.337 < 2e-16 ***
## Tipo_de_Cambio.l1 -1.424e-01 1.938e-02 -7.350 2.89e-12 ***
## IED_Flujos.l2 6.456e-07 1.522e-07 4.241 3.15e-05 ***
## Exportaciones.l2 -7.781e-06 9.344e-07 -8.327 5.72e-15 ***
## Empleo.l2 1.441e-01 2.351e-02 6.129 3.48e-09 ***
## Innovación.l2 -1.144e-01 2.009e-02 -5.696 3.47e-08 ***
## Inseguridad.l2 -1.303e-03 3.646e-04 -3.574 0.000423 ***
## Salario.l2 7.447e-03 2.372e-03 3.139 0.001902 **
## Educación.l2 -1.370e-01 6.819e-02 -2.009 0.045639 *
## Tipo_de_Cambio.l2 2.199e-01 1.860e-02 11.822 < 2e-16 ***
## const 1.459e+01 3.381e+00 4.315 2.31e-05 ***
## sd1 7.045e-02 3.759e-02 1.874 0.062049 .
## sd2 1.757e-03 3.618e-02 0.049 0.961316
## sd3 4.616e-02 3.714e-02 1.243 0.215069
## sd4 2.809e-03 3.585e-02 0.078 0.937611
## sd5 6.562e-02 3.721e-02 1.763 0.079096 .
## sd6 -5.736e-03 3.582e-02 -0.160 0.872901
## sd7 6.248e-02 3.748e-02 1.667 0.096745 .
## sd8 1.064e-02 3.585e-02 0.297 0.766946
## sd9 5.166e-02 3.727e-02 1.386 0.167007
## sd10 1.047e-02 3.577e-02 0.293 0.769961
## sd11 5.743e-02 3.705e-02 1.550 0.122462
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
##
## Residual standard error: 0.1209 on 247 degrees of freedom
## Multiple R-Squared: 0.9694, Adjusted R-squared: 0.9661
## F-statistic: 290.2 on 27 and 247 DF, p-value: < 2.2e-16
##
##
## Estimation results for equation Tipo_de_Cambio:
## ===============================================
## Tipo_de_Cambio = IED_Flujos.l1 + Exportaciones.l1 + Empleo.l1 + Innovación.l1 + Inseguridad.l1 + Salario.l1 + Educación.l1 + Tipo_de_Cambio.l1 + IED_Flujos.l2 + Exportaciones.l2 + Empleo.l2 + Innovación.l2 + Inseguridad.l2 + Salario.l2 + Educación.l2 + Tipo_de_Cambio.l2 + const + sd1 + sd2 + sd3 + sd4 + sd5 + sd6 + sd7 + sd8 + sd9 + sd10 + sd11
##
## Estimate Std. Error t value Pr(>|t|)
## IED_Flujos.l1 2.859e-06 1.163e-06 2.458 0.014657 *
## Exportaciones.l1 2.723e-05 3.927e-06 6.935 3.54e-11 ***
## Empleo.l1 -4.257e-01 2.102e-01 -2.025 0.043940 *
## Innovación.l1 8.752e-01 2.362e-01 3.705 0.000261 ***
## Inseguridad.l1 1.796e-02 6.518e-03 2.755 0.006301 **
## Salario.l1 -6.781e-02 8.592e-03 -7.892 9.69e-14 ***
## Educación.l1 -1.447e+00 5.281e-01 -2.739 0.006608 **
## Tipo_de_Cambio.l1 1.984e-01 1.673e-01 1.186 0.236806
## IED_Flujos.l2 2.662e-06 1.314e-06 2.025 0.043892 *
## Exportaciones.l2 -1.767e-05 8.066e-06 -2.190 0.029424 *
## Empleo.l2 1.191e+00 2.029e-01 5.870 1.40e-08 ***
## Innovación.l2 -1.119e+00 1.734e-01 -6.452 5.79e-10 ***
## Inseguridad.l2 -8.523e-03 3.147e-03 -2.708 0.007245 **
## Salario.l2 7.991e-03 2.048e-02 0.390 0.696695
## Educación.l2 4.133e+00 5.886e-01 7.022 2.11e-11 ***
## Tipo_de_Cambio.l2 1.711e-01 1.606e-01 1.066 0.287577
## const -8.926e+01 2.919e+01 -3.058 0.002472 **
## sd1 -1.004e+00 3.244e-01 -3.095 0.002195 **
## sd2 2.318e-01 3.123e-01 0.742 0.458625
## sd3 -1.044e+00 3.206e-01 -3.257 0.001285 **
## sd4 1.377e-01 3.095e-01 0.445 0.656847
## sd5 -1.065e+00 3.212e-01 -3.316 0.001052 **
## sd6 1.706e-01 3.092e-01 0.552 0.581577
## sd7 -9.477e-01 3.235e-01 -2.929 0.003714 **
## sd8 1.334e-01 3.095e-01 0.431 0.666810
## sd9 -9.504e-01 3.217e-01 -2.954 0.003440 **
## sd10 -9.285e-02 3.087e-01 -0.301 0.763867
## sd11 -9.553e-01 3.198e-01 -2.987 0.003102 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
##
## Residual standard error: 1.044 on 247 degrees of freedom
## Multiple R-Squared: 0.9391, Adjusted R-squared: 0.9325
## F-statistic: 141.1 on 27 and 247 DF, p-value: < 2.2e-16
##
##
##
## Covariance matrix of residuals:
## IED_Flujos Exportaciones Empleo Innovación Inseguridad
## IED_Flujos 3683089705 1.007e+08 -8.760e+02 -3.323e+03 4.365e+04
## Exportaciones 100678725 1.797e+09 -6.931e+02 -1.048e+04 -4.016e+05
## Empleo -876 -6.931e+02 4.163e-02 1.874e-02 1.016e+00
## Innovación -3323 -1.048e+04 1.874e-02 1.198e-01 1.211e+00
## Inseguridad 43655 -4.016e+05 1.016e+00 1.211e+00 2.218e+02
## Salario -31430 5.632e+05 -1.160e+00 -4.118e+00 -1.861e+02
## Educación 3363 -5.716e+02 -3.423e-03 6.058e-03 -9.132e-01
## Tipo_de_Cambio 15434 4.103e+04 -6.231e-02 -2.794e-01 -8.067e+00
## Salario Educación Tipo_de_Cambio
## IED_Flujos -3.143e+04 3.363e+03 1.543e+04
## Exportaciones 5.632e+05 -5.716e+02 4.103e+04
## Empleo -1.160e+00 -3.423e-03 -6.231e-02
## Innovación -4.118e+00 6.058e-03 -2.794e-01
## Inseguridad -1.861e+02 -9.132e-01 -8.067e+00
## Salario 2.544e+02 3.653e-01 1.331e+01
## Educación 3.653e-01 1.462e-02 -1.612e-02
## Tipo_de_Cambio 1.331e+01 -1.612e-02 1.090e+00
##
## Correlation matrix of residuals:
## IED_Flujos Exportaciones Empleo Innovación Inseguridad
## IED_Flujos 1.00000 0.03914 -0.07075 -0.1582 0.0483
## Exportaciones 0.03914 1.00000 -0.08014 -0.7146 -0.6362
## Empleo -0.07075 -0.08014 1.00000 0.2654 0.3345
## Innovación -0.15820 -0.71457 0.26535 1.0000 0.2349
## Inseguridad 0.04830 -0.63615 0.33453 0.2349 1.0000
## Salario -0.03247 0.83311 -0.35656 -0.7460 -0.7834
## Educación 0.45827 -0.11153 -0.13874 0.1447 -0.5071
## Tipo_de_Cambio 0.24363 0.92727 -0.29259 -0.7733 -0.5189
## Salario Educación Tipo_de_Cambio
## IED_Flujos -0.03247 0.4583 0.2436
## Exportaciones 0.83311 -0.1115 0.9273
## Empleo -0.35656 -0.1387 -0.2926
## Innovación -0.74596 0.1447 -0.7733
## Inseguridad -0.78340 -0.5071 -0.5189
## Salario 1.00000 0.1894 0.7996
## Educación 0.18941 1.0000 -0.1277
## Tipo_de_Cambio 0.79965 -0.1277 1.0000
# Testing model 1 residuals for stationarity
VAR_model1_residuals<-data.frame(residuals(VAR_model1))
adf.test(VAR_model1_residuals$IED_Flujos)
##
## Augmented Dickey-Fuller Test
##
## data: VAR_model1_residuals$IED_Flujos
## Dickey-Fuller = -9.6101, Lag order = 6, p-value = 0.01
## alternative hypothesis: stationary
After applying the adf test we get a p-value of 0.01<0.05, which means the residuals of model 1 are stationary.
# Testing residuals autocorrelation
Box.test(VAR_model1_residuals$IED_Flujos,lag=,type="Ljung-Box")
##
## Box-Ljung test
##
## data: VAR_model1_residuals$IED_Flujos
## X-squared = 6.8425, df = 1, p-value = 0.008901
The residuals seem to show autocorrelation, the p-value is<0.05.
#Transforming into diff and log values for model 2.
dflujos<-diff(log(flujos))
dexportaciones<-diff(log(exportaciones))
dempleo<-diff(log(empleo))
dinnovacion<-diff(log(innovación))
dinseguridad<-diff(log(inseguridad))
dsalario<-diff(log(salario))
deducación<-diff(log(educación))
dcambio<-diff(log(cambio))
VAR_ts_diff<-cbind(dflujos,dexportaciones,dempleo,dinnovacion,dinseguridad,dsalario,deducación,dcambio)
colnames(VAR_ts_diff)<-cbind("IED_Flujos", "Exportaciones", "Empleo","Innovación","Inseguridad","Salario","Educación","Tipo_de_Cambio")
lag_selection<-VARselect(VAR_ts_diff,lag.max=5,type="const", season=12)
lag_selection$selection
## AIC(n) HQ(n) SC(n) FPE(n)
## 3 3 3 3
lag_selection$criteria
## 1 2 3 4 5
## AIC(n) -4.572704e+01 -5.567824e+01 -5.753743e+02 -5.703346e+02 -5.698622e+02
## HQ(n) -4.487314e+01 -5.448278e+01 -5.738372e+02 -5.684560e+02 -5.676421e+02
## SC(n) -4.360033e+01 -5.270084e+01 -5.715462e+02 -5.656558e+02 -5.643328e+02
## FPE(n) 1.386541e-20 6.634683e-25 1.329300e-250 2.074511e-248 3.378356e-248
When we have a lag of 3 periods we have a lower AIC, so this is what we select.
# Estimating VAR model.
VAR_model2<-VAR(VAR_ts_diff,p=3,type="const",season=12)
summary(VAR_model2)
##
## VAR Estimation Results:
## =========================
## Endogenous variables: IED_Flujos, Exportaciones, Empleo, Innovación, Inseguridad, Salario, Educación, Tipo_de_Cambio
## Deterministic variables: const
## Sample size: 273
## Log Likelihood: 75460.738
## Roots of the characteristic polynomial:
## 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
## Call:
## VAR(y = VAR_ts_diff, p = 3, type = "const", season = 12L)
##
##
## Estimation results for equation IED_Flujos:
## ===========================================
## IED_Flujos = IED_Flujos.l1 + Exportaciones.l1 + Empleo.l1 + Innovación.l1 + Inseguridad.l1 + Salario.l1 + Educación.l1 + Tipo_de_Cambio.l1 + IED_Flujos.l2 + Exportaciones.l2 + Empleo.l2 + Innovación.l2 + Inseguridad.l2 + Salario.l2 + Educación.l2 + Tipo_de_Cambio.l2 + IED_Flujos.l3 + Exportaciones.l3 + Empleo.l3 + Innovación.l3 + Inseguridad.l3 + Salario.l3 + Educación.l3 + Tipo_de_Cambio.l3 + const + sd1 + sd2 + sd3 + sd4 + sd5 + sd6 + sd7 + sd8 + sd9 + sd10 + sd11
##
## Estimate Std. Error t value Pr(>|t|)
## IED_Flujos.l1 6.525e-01 1.768e-15 3.691e+14 <2e-16 ***
## Exportaciones.l1 2.090e+00 6.786e-15 3.079e+14 <2e-16 ***
## Empleo.l1 4.974e+00 1.104e-13 4.507e+13 <2e-16 ***
## Innovación.l1 1.278e+00 7.286e-15 1.754e+14 <2e-16 ***
## Inseguridad.l1 5.522e-02 3.745e-15 1.475e+13 <2e-16 ***
## Salario.l1 1.077e+00 2.554e-15 4.216e+14 <2e-16 ***
## Educación.l1 -8.711e+00 2.119e-14 -4.112e+14 <2e-16 ***
## Tipo_de_Cambio.l1 -5.438e+00 6.536e-15 -8.320e+14 <2e-16 ***
## IED_Flujos.l2 9.306e-01 3.124e-15 2.979e+14 <2e-16 ***
## Exportaciones.l2 3.533e+00 1.256e-14 2.813e+14 <2e-16 ***
## Empleo.l2 -2.524e+01 1.523e-13 -1.657e+14 <2e-16 ***
## Innovación.l2 3.909e+00 5.801e-15 6.737e+14 <2e-16 ***
## Inseguridad.l2 2.502e+00 4.439e-15 5.636e+14 <2e-16 ***
## Salario.l2 -1.919e+00 3.758e-15 -5.107e+14 <2e-16 ***
## Educación.l2 4.747e-01 1.144e-14 4.150e+13 <2e-16 ***
## Tipo_de_Cambio.l2 3.591e-01 9.959e-15 3.606e+13 <2e-16 ***
## IED_Flujos.l3 7.068e-01 2.696e-15 2.621e+14 <2e-16 ***
## Exportaciones.l3 -4.631e+00 7.280e-15 -6.362e+14 <2e-16 ***
## Empleo.l3 2.370e+01 7.544e-14 3.142e+14 <2e-16 ***
## Innovación.l3 -1.772e+00 6.535e-15 -2.711e+14 <2e-16 ***
## Inseguridad.l3 -2.477e-01 2.402e-15 -1.031e+14 <2e-16 ***
## Salario.l3 1.448e+00 3.372e-15 4.293e+14 <2e-16 ***
## Educación.l3 8.641e+00 1.465e-14 5.899e+14 <2e-16 ***
## Tipo_de_Cambio.l3 8.462e-01 5.495e-15 1.540e+14 <2e-16 ***
## const 1.117e-16 1.158e-16 9.650e-01 0.3355
## sd1 -3.261e-01 1.170e-15 -2.788e+14 <2e-16 ***
## sd2 7.421e-16 5.727e-16 1.296e+00 0.1963
## sd3 -3.261e-01 1.185e-15 -2.753e+14 <2e-16 ***
## sd4 7.381e-16 5.669e-16 1.302e+00 0.1942
## sd5 -3.261e-01 1.184e-15 -2.754e+14 <2e-16 ***
## sd6 1.161e-15 5.669e-16 2.047e+00 0.0418 *
## sd7 -3.261e-01 1.188e-15 -2.745e+14 <2e-16 ***
## sd8 1.425e-15 5.669e-16 2.514e+00 0.0126 *
## sd9 -3.261e-01 1.188e-15 -2.745e+14 <2e-16 ***
## sd10 6.945e-16 5.657e-16 1.228e+00 0.2208
## sd11 -3.261e-01 1.181e-15 -2.762e+14 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
##
## Residual standard error: 1.91e-15 on 237 degrees of freedom
## Multiple R-Squared: 1, Adjusted R-squared: 1
## F-statistic: 2.172e+29 on 35 and 237 DF, p-value: < 2.2e-16
##
##
## Estimation results for equation Exportaciones:
## ==============================================
## Exportaciones = IED_Flujos.l1 + Exportaciones.l1 + Empleo.l1 + Innovación.l1 + Inseguridad.l1 + Salario.l1 + Educación.l1 + Tipo_de_Cambio.l1 + IED_Flujos.l2 + Exportaciones.l2 + Empleo.l2 + Innovación.l2 + Inseguridad.l2 + Salario.l2 + Educación.l2 + Tipo_de_Cambio.l2 + IED_Flujos.l3 + Exportaciones.l3 + Empleo.l3 + Innovación.l3 + Inseguridad.l3 + Salario.l3 + Educación.l3 + Tipo_de_Cambio.l3 + const + sd1 + sd2 + sd3 + sd4 + sd5 + sd6 + sd7 + sd8 + sd9 + sd10 + sd11
##
## Estimate Std. Error t value Pr(>|t|)
## IED_Flujos.l1 5.798e-02 9.231e-16 6.281e+13 <2e-16 ***
## Exportaciones.l1 -1.902e-01 3.544e-15 -5.366e+13 <2e-16 ***
## Empleo.l1 1.118e+01 5.764e-14 1.939e+14 <2e-16 ***
## Innovación.l1 -1.905e+00 3.805e-15 -5.006e+14 <2e-16 ***
## Inseguridad.l1 -4.729e-01 1.956e-15 -2.418e+14 <2e-16 ***
## Salario.l1 -5.149e-01 1.334e-15 -3.860e+14 <2e-16 ***
## Educación.l1 5.092e-01 1.106e-14 4.602e+13 <2e-16 ***
## Tipo_de_Cambio.l1 7.707e-01 3.414e-15 2.258e+14 <2e-16 ***
## IED_Flujos.l2 1.182e-01 1.632e-15 7.245e+13 <2e-16 ***
## Exportaciones.l2 1.481e+00 6.559e-15 2.259e+14 <2e-16 ***
## Empleo.l2 -1.129e+01 7.954e-14 -1.419e+14 <2e-16 ***
## Innovación.l2 -1.294e+00 3.030e-15 -4.271e+14 <2e-16 ***
## Inseguridad.l2 -8.220e-01 2.318e-15 -3.545e+14 <2e-16 ***
## Salario.l2 -3.829e-01 1.963e-15 -1.951e+14 <2e-16 ***
## Educación.l2 -7.347e-01 5.974e-15 -1.230e+14 <2e-16 ***
## Tipo_de_Cambio.l2 -2.092e+00 5.201e-15 -4.023e+14 <2e-16 ***
## IED_Flujos.l3 4.124e-01 1.408e-15 2.929e+14 <2e-16 ***
## Exportaciones.l3 1.616e+00 3.802e-15 4.251e+14 <2e-16 ***
## Empleo.l3 -2.593e+00 3.940e-14 -6.583e+13 <2e-16 ***
## Innovación.l3 1.157e+00 3.413e-15 3.389e+14 <2e-16 ***
## Inseguridad.l3 2.682e-01 1.255e-15 2.137e+14 <2e-16 ***
## Salario.l3 -1.580e+00 1.761e-15 -8.970e+14 <2e-16 ***
## Educación.l3 4.903e+00 7.650e-15 6.409e+14 <2e-16 ***
## Tipo_de_Cambio.l3 -5.799e-01 2.870e-15 -2.021e+14 <2e-16 ***
## const -1.008e-16 6.046e-17 -1.667e+00 0.0968 .
## sd1 -2.096e-02 6.109e-16 -3.431e+13 <2e-16 ***
## sd2 3.966e-16 2.991e-16 1.326e+00 0.1860
## sd3 -2.096e-02 6.187e-16 -3.388e+13 <2e-16 ***
## sd4 3.529e-16 2.961e-16 1.192e+00 0.2345
## sd5 -2.096e-02 6.184e-16 -3.389e+13 <2e-16 ***
## sd6 2.261e-16 2.961e-16 7.640e-01 0.4457
## sd7 -2.096e-02 6.204e-16 -3.379e+13 <2e-16 ***
## sd8 3.230e-16 2.961e-16 1.091e+00 0.2764
## sd9 -2.096e-02 6.204e-16 -3.378e+13 <2e-16 ***
## sd10 3.462e-16 2.954e-16 1.172e+00 0.2424
## sd11 -2.096e-02 6.167e-16 -3.399e+13 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
##
## Residual standard error: 9.976e-16 on 237 degrees of freedom
## Multiple R-Squared: 1, Adjusted R-squared: 1
## F-statistic: 4.777e+29 on 35 and 237 DF, p-value: < 2.2e-16
##
##
## Estimation results for equation Empleo:
## =======================================
## Empleo = IED_Flujos.l1 + Exportaciones.l1 + Empleo.l1 + Innovación.l1 + Inseguridad.l1 + Salario.l1 + Educación.l1 + Tipo_de_Cambio.l1 + IED_Flujos.l2 + Exportaciones.l2 + Empleo.l2 + Innovación.l2 + Inseguridad.l2 + Salario.l2 + Educación.l2 + Tipo_de_Cambio.l2 + IED_Flujos.l3 + Exportaciones.l3 + Empleo.l3 + Innovación.l3 + Inseguridad.l3 + Salario.l3 + Educación.l3 + Tipo_de_Cambio.l3 + const + sd1 + sd2 + sd3 + sd4 + sd5 + sd6 + sd7 + sd8 + sd9 + sd10 + sd11
##
## Estimate Std. Error t value Pr(>|t|)
## IED_Flujos.l1 2.705e-02 6.975e-17 3.878e+14 <2e-16 ***
## Exportaciones.l1 -1.019e-02 2.678e-16 -3.807e+13 <2e-16 ***
## Empleo.l1 4.939e-01 4.355e-15 1.134e+14 <2e-16 ***
## Innovación.l1 -9.411e-02 2.875e-16 -3.274e+14 <2e-16 ***
## Inseguridad.l1 -2.634e-02 1.478e-16 -1.782e+14 <2e-16 ***
## Salario.l1 2.613e-03 1.008e-16 2.593e+13 <2e-16 ***
## Educación.l1 -1.877e-01 8.359e-16 -2.245e+14 <2e-16 ***
## Tipo_de_Cambio.l1 -4.242e-02 2.579e-16 -1.645e+14 <2e-16 ***
## IED_Flujos.l2 4.357e-02 1.233e-16 3.534e+14 <2e-16 ***
## Exportaciones.l2 1.788e-01 4.956e-16 3.608e+14 <2e-16 ***
## Empleo.l2 -1.270e+00 6.010e-15 -2.113e+14 <2e-16 ***
## Innovación.l2 2.528e-02 2.289e-16 1.104e+14 <2e-16 ***
## Inseguridad.l2 2.783e-02 1.752e-16 1.589e+14 <2e-16 ***
## Salario.l2 -6.144e-02 1.483e-16 -4.143e+14 <2e-16 ***
## Educación.l2 -1.765e-01 4.514e-16 -3.911e+14 <2e-16 ***
## Tipo_de_Cambio.l2 -1.030e-01 3.930e-16 -2.621e+14 <2e-16 ***
## IED_Flujos.l3 3.990e-02 1.064e-16 3.750e+14 <2e-16 ***
## Exportaciones.l3 -2.919e-02 2.872e-16 -1.016e+14 <2e-16 ***
## Empleo.l3 3.516e-01 2.977e-15 1.181e+14 <2e-16 ***
## Innovación.l3 -5.483e-02 2.579e-16 -2.127e+14 <2e-16 ***
## Inseguridad.l3 -1.555e-02 9.480e-17 -1.640e+14 <2e-16 ***
## Salario.l3 -4.468e-02 1.331e-16 -3.358e+14 <2e-16 ***
## Educación.l3 5.852e-02 5.780e-16 1.013e+14 <2e-16 ***
## Tipo_de_Cambio.l3 4.565e-02 2.168e-16 2.105e+14 <2e-16 ***
## const -5.285e-18 4.568e-18 -1.157e+00 0.2485
## sd1 -3.715e-03 4.616e-17 -8.048e+13 <2e-16 ***
## sd2 3.994e-17 2.260e-17 1.767e+00 0.0784 .
## sd3 -3.715e-03 4.675e-17 -7.947e+13 <2e-16 ***
## sd4 5.033e-17 2.237e-17 2.250e+00 0.0254 *
## sd5 -3.715e-03 4.672e-17 -7.951e+13 <2e-16 ***
## sd6 4.394e-17 2.237e-17 1.964e+00 0.0507 .
## sd7 -3.715e-03 4.687e-17 -7.926e+13 <2e-16 ***
## sd8 4.579e-17 2.237e-17 2.047e+00 0.0418 *
## sd9 -3.715e-03 4.688e-17 -7.925e+13 <2e-16 ***
## sd10 3.561e-17 2.232e-17 1.595e+00 0.1120
## sd11 -3.715e-03 4.659e-17 -7.973e+13 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
##
## Residual standard error: 7.538e-17 on 237 degrees of freedom
## Multiple R-Squared: 1, Adjusted R-squared: 1
## F-statistic: 4.34e+28 on 35 and 237 DF, p-value: < 2.2e-16
##
##
## Estimation results for equation Innovación:
## ===========================================
## Innovación = IED_Flujos.l1 + Exportaciones.l1 + Empleo.l1 + Innovación.l1 + Inseguridad.l1 + Salario.l1 + Educación.l1 + Tipo_de_Cambio.l1 + IED_Flujos.l2 + Exportaciones.l2 + Empleo.l2 + Innovación.l2 + Inseguridad.l2 + Salario.l2 + Educación.l2 + Tipo_de_Cambio.l2 + IED_Flujos.l3 + Exportaciones.l3 + Empleo.l3 + Innovación.l3 + Inseguridad.l3 + Salario.l3 + Educación.l3 + Tipo_de_Cambio.l3 + const + sd1 + sd2 + sd3 + sd4 + sd5 + sd6 + sd7 + sd8 + sd9 + sd10 + sd11
##
## Estimate Std. Error t value Pr(>|t|)
## IED_Flujos.l1 2.612e-01 5.106e-16 5.115e+14 <2e-16 ***
## Exportaciones.l1 1.449e+00 1.960e-15 7.391e+14 <2e-16 ***
## Empleo.l1 -1.359e+01 3.188e-14 -4.262e+14 <2e-16 ***
## Innovación.l1 9.506e-03 2.105e-15 4.517e+12 <2e-16 ***
## Inseguridad.l1 2.228e-01 1.082e-15 2.060e+14 <2e-16 ***
## Salario.l1 -1.548e-02 7.377e-16 -2.099e+13 <2e-16 ***
## Educación.l1 -1.596e+00 6.119e-15 -2.609e+14 <2e-16 ***
## Tipo_de_Cambio.l1 -1.927e+00 1.888e-15 -1.021e+15 <2e-16 ***
## IED_Flujos.l2 3.651e-01 9.024e-16 4.045e+14 <2e-16 ***
## Exportaciones.l2 8.498e-01 3.628e-15 2.342e+14 <2e-16 ***
## Empleo.l2 2.130e+00 4.399e-14 4.841e+13 <2e-16 ***
## Innovación.l2 7.418e-01 1.676e-15 4.427e+14 <2e-16 ***
## Inseguridad.l2 1.420e-01 1.282e-15 1.107e+14 <2e-16 ***
## Salario.l2 -6.899e-01 1.086e-15 -6.354e+14 <2e-16 ***
## Educación.l2 -3.417e-01 3.304e-15 -1.034e+14 <2e-16 ***
## Tipo_de_Cambio.l2 4.961e-02 2.877e-15 1.724e+13 <2e-16 ***
## IED_Flujos.l3 8.596e-03 7.789e-16 1.104e+13 <2e-16 ***
## Exportaciones.l3 -1.032e+00 2.103e-15 -4.906e+14 <2e-16 ***
## Empleo.l3 1.403e+01 2.179e-14 6.440e+14 <2e-16 ***
## Innovación.l3 -1.224e+00 1.888e-15 -6.484e+14 <2e-16 ***
## Inseguridad.l3 -9.167e-02 6.939e-16 -1.321e+14 <2e-16 ***
## Salario.l3 2.612e-01 9.741e-16 2.681e+14 <2e-16 ***
## Educación.l3 5.679e-01 4.231e-15 1.342e+14 <2e-16 ***
## Tipo_de_Cambio.l3 4.432e-01 1.587e-15 2.792e+14 <2e-16 ***
## const -1.025e-18 3.344e-17 -3.100e-02 0.9756
## sd1 -6.885e-02 3.379e-16 -2.038e+14 <2e-16 ***
## sd2 2.113e-16 1.654e-16 1.277e+00 0.2027
## sd3 -6.885e-02 3.422e-16 -2.012e+14 <2e-16 ***
## sd4 2.435e-16 1.638e-16 1.487e+00 0.1383
## sd5 -6.885e-02 3.420e-16 -2.013e+14 <2e-16 ***
## sd6 2.778e-16 1.638e-16 1.696e+00 0.0911 .
## sd7 -6.885e-02 3.431e-16 -2.007e+14 <2e-16 ***
## sd8 3.897e-16 1.638e-16 2.380e+00 0.0181 *
## sd9 -6.885e-02 3.432e-16 -2.006e+14 <2e-16 ***
## sd10 1.666e-16 1.634e-16 1.020e+00 0.3089
## sd11 -6.885e-02 3.411e-16 -2.019e+14 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
##
## Residual standard error: 5.518e-16 on 237 degrees of freedom
## Multiple R-Squared: 1, Adjusted R-squared: 1
## F-statistic: 1.441e+29 on 35 and 237 DF, p-value: < 2.2e-16
##
##
## Estimation results for equation Inseguridad:
## ============================================
## Inseguridad = IED_Flujos.l1 + Exportaciones.l1 + Empleo.l1 + Innovación.l1 + Inseguridad.l1 + Salario.l1 + Educación.l1 + Tipo_de_Cambio.l1 + IED_Flujos.l2 + Exportaciones.l2 + Empleo.l2 + Innovación.l2 + Inseguridad.l2 + Salario.l2 + Educación.l2 + Tipo_de_Cambio.l2 + IED_Flujos.l3 + Exportaciones.l3 + Empleo.l3 + Innovación.l3 + Inseguridad.l3 + Salario.l3 + Educación.l3 + Tipo_de_Cambio.l3 + const + sd1 + sd2 + sd3 + sd4 + sd5 + sd6 + sd7 + sd8 + sd9 + sd10 + sd11
##
## Estimate Std. Error t value Pr(>|t|)
## IED_Flujos.l1 3.379e-01 1.459e-15 2.316e+14 < 2e-16 ***
## Exportaciones.l1 -1.492e+00 5.602e-15 -2.664e+14 < 2e-16 ***
## Empleo.l1 3.740e+01 9.111e-14 4.105e+14 < 2e-16 ***
## Innovación.l1 -2.166e+00 6.014e-15 -3.602e+14 < 2e-16 ***
## Inseguridad.l1 -1.187e+00 3.092e-15 -3.841e+14 < 2e-16 ***
## Salario.l1 4.682e-02 2.108e-15 2.221e+13 < 2e-16 ***
## Educación.l1 -4.448e+00 1.749e-14 -2.543e+14 < 2e-16 ***
## Tipo_de_Cambio.l1 6.411e-01 5.396e-15 1.188e+14 < 2e-16 ***
## IED_Flujos.l2 5.650e-01 2.579e-15 2.191e+14 < 2e-16 ***
## Exportaciones.l2 3.511e+00 1.037e-14 3.386e+14 < 2e-16 ***
## Empleo.l2 -5.163e+01 1.257e-13 -4.106e+14 < 2e-16 ***
## Innovación.l2 6.140e-01 4.789e-15 1.282e+14 < 2e-16 ***
## Inseguridad.l2 9.213e-01 3.665e-15 2.514e+14 < 2e-16 ***
## Salario.l2 -8.627e-01 3.103e-15 -2.781e+14 < 2e-16 ***
## Educación.l2 -1.694e+00 9.443e-15 -1.794e+14 < 2e-16 ***
## Tipo_de_Cambio.l2 -2.425e+00 8.221e-15 -2.949e+14 < 2e-16 ***
## IED_Flujos.l3 7.641e-01 2.226e-15 3.433e+14 < 2e-16 ***
## Exportaciones.l3 5.320e-01 6.009e-15 8.853e+13 < 2e-16 ***
## Empleo.l3 -2.677e+01 6.227e-14 -4.298e+14 < 2e-16 ***
## Innovación.l3 2.074e+00 5.395e-15 3.844e+14 < 2e-16 ***
## Inseguridad.l3 -8.362e-01 1.983e-15 -4.217e+14 < 2e-16 ***
## Salario.l3 -6.161e-01 2.784e-15 -2.213e+14 < 2e-16 ***
## Educación.l3 -3.243e+00 1.209e-14 -2.682e+14 < 2e-16 ***
## Tipo_de_Cambio.l3 -2.292e-01 4.536e-15 -5.052e+13 < 2e-16 ***
## const -1.310e-16 9.557e-17 -1.371e+00 0.17170
## sd1 4.809e-02 9.657e-16 4.980e+13 < 2e-16 ***
## sd2 8.982e-16 4.727e-16 1.900e+00 0.05864 .
## sd3 4.809e-02 9.780e-16 4.917e+13 < 2e-16 ***
## sd4 1.227e-15 4.680e-16 2.621e+00 0.00932 **
## sd5 4.809e-02 9.775e-16 4.920e+13 < 2e-16 ***
## sd6 8.893e-16 4.680e-16 1.900e+00 0.05860 .
## sd7 4.809e-02 9.806e-16 4.904e+13 < 2e-16 ***
## sd8 7.647e-16 4.680e-16 1.634e+00 0.10356
## sd9 4.809e-02 9.807e-16 4.904e+13 < 2e-16 ***
## sd10 9.629e-16 4.670e-16 2.062e+00 0.04029 *
## sd11 4.809e-02 9.747e-16 4.934e+13 < 2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
##
## Residual standard error: 1.577e-15 on 237 degrees of freedom
## Multiple R-Squared: 1, Adjusted R-squared: 1
## F-statistic: 1.376e+29 on 35 and 237 DF, p-value: < 2.2e-16
##
##
## Estimation results for equation Salario:
## ========================================
## Salario = IED_Flujos.l1 + Exportaciones.l1 + Empleo.l1 + Innovación.l1 + Inseguridad.l1 + Salario.l1 + Educación.l1 + Tipo_de_Cambio.l1 + IED_Flujos.l2 + Exportaciones.l2 + Empleo.l2 + Innovación.l2 + Inseguridad.l2 + Salario.l2 + Educación.l2 + Tipo_de_Cambio.l2 + IED_Flujos.l3 + Exportaciones.l3 + Empleo.l3 + Innovación.l3 + Inseguridad.l3 + Salario.l3 + Educación.l3 + Tipo_de_Cambio.l3 + const + sd1 + sd2 + sd3 + sd4 + sd5 + sd6 + sd7 + sd8 + sd9 + sd10 + sd11
##
## Estimate Std. Error t value Pr(>|t|)
## IED_Flujos.l1 -3.574e-01 6.435e-16 -5.554e+14 <2e-16 ***
## Exportaciones.l1 -1.801e+00 2.471e-15 -7.292e+14 <2e-16 ***
## Empleo.l1 3.086e+01 4.018e-14 7.681e+14 <2e-16 ***
## Innovación.l1 -5.610e-01 2.653e-15 -2.115e+14 <2e-16 ***
## Inseguridad.l1 -9.180e-01 1.363e-15 -6.733e+14 <2e-16 ***
## Salario.l1 3.905e-02 9.298e-16 4.200e+13 <2e-16 ***
## Educación.l1 -3.089e+00 7.713e-15 -4.005e+14 <2e-16 ***
## Tipo_de_Cambio.l1 1.695e+00 2.380e-15 7.121e+14 <2e-16 ***
## IED_Flujos.l2 -1.823e-01 1.137e-15 -1.603e+14 <2e-16 ***
## Exportaciones.l2 1.327e+00 4.572e-15 2.903e+14 <2e-16 ***
## Empleo.l2 -1.726e+01 5.545e-14 -3.113e+14 <2e-16 ***
## Innovación.l2 1.912e-01 2.112e-15 9.054e+13 <2e-16 ***
## Inseguridad.l2 4.119e-01 1.616e-15 2.548e+14 <2e-16 ***
## Salario.l2 -5.017e-03 1.368e-15 -3.666e+12 <2e-16 ***
## Educación.l2 -8.147e-01 4.165e-15 -1.956e+14 <2e-16 ***
## Tipo_de_Cambio.l2 -1.454e+00 3.626e-15 -4.009e+14 <2e-16 ***
## IED_Flujos.l3 1.469e-01 9.817e-16 1.497e+14 <2e-16 ***
## Exportaciones.l3 3.755e-02 2.650e-15 1.417e+13 <2e-16 ***
## Empleo.l3 -4.582e+00 2.746e-14 -1.669e+14 <2e-16 ***
## Innovación.l3 1.317e+00 2.379e-15 5.535e+14 <2e-16 ***
## Inseguridad.l3 1.150e-01 8.746e-16 1.315e+14 <2e-16 ***
## Salario.l3 -1.536e+00 1.228e-15 -1.251e+15 <2e-16 ***
## Educación.l3 1.439e+01 5.333e-15 2.699e+15 <2e-16 ***
## Tipo_de_Cambio.l3 4.306e-01 2.001e-15 2.152e+14 <2e-16 ***
## const 5.739e-17 4.215e-17 1.362e+00 0.175
## sd1 1.723e-01 4.259e-16 4.045e+14 <2e-16 ***
## sd2 2.796e-16 2.085e-16 1.341e+00 0.181
## sd3 1.723e-01 4.313e-16 3.994e+14 <2e-16 ***
## sd4 8.587e-17 2.064e-16 4.160e-01 0.678
## sd5 1.723e-01 4.311e-16 3.996e+14 <2e-16 ***
## sd6 2.603e-16 2.064e-16 1.261e+00 0.209
## sd7 1.723e-01 4.325e-16 3.983e+14 <2e-16 ***
## sd8 3.282e-16 2.064e-16 1.590e+00 0.113
## sd9 1.723e-01 4.325e-16 3.983e+14 <2e-16 ***
## sd10 2.634e-16 2.059e-16 1.279e+00 0.202
## sd11 1.723e-01 4.299e-16 4.007e+14 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
##
## Residual standard error: 6.955e-16 on 237 degrees of freedom
## Multiple R-Squared: 1, Adjusted R-squared: 1
## F-statistic: 2.435e+30 on 35 and 237 DF, p-value: < 2.2e-16
##
##
## Estimation results for equation Educación:
## ==========================================
## Educación = IED_Flujos.l1 + Exportaciones.l1 + Empleo.l1 + Innovación.l1 + Inseguridad.l1 + Salario.l1 + Educación.l1 + Tipo_de_Cambio.l1 + IED_Flujos.l2 + Exportaciones.l2 + Empleo.l2 + Innovación.l2 + Inseguridad.l2 + Salario.l2 + Educación.l2 + Tipo_de_Cambio.l2 + IED_Flujos.l3 + Exportaciones.l3 + Empleo.l3 + Innovación.l3 + Inseguridad.l3 + Salario.l3 + Educación.l3 + Tipo_de_Cambio.l3 + const + sd1 + sd2 + sd3 + sd4 + sd5 + sd6 + sd7 + sd8 + sd9 + sd10 + sd11
##
## Estimate Std. Error t value Pr(>|t|)
## IED_Flujos.l1 1.356e-01 2.061e-16 6.580e+14 < 2e-16 ***
## Exportaciones.l1 4.698e-01 7.911e-16 5.939e+14 < 2e-16 ***
## Empleo.l1 -6.989e+00 1.287e-14 -5.432e+14 < 2e-16 ***
## Innovación.l1 5.203e-01 8.494e-16 6.126e+14 < 2e-16 ***
## Inseguridad.l1 2.869e-01 4.366e-16 6.571e+14 < 2e-16 ***
## Salario.l1 3.379e-02 2.977e-16 1.135e+14 < 2e-16 ***
## Educación.l1 -3.589e-01 2.470e-15 -1.453e+14 < 2e-16 ***
## Tipo_de_Cambio.l1 -6.378e-01 7.620e-16 -8.370e+14 < 2e-16 ***
## IED_Flujos.l2 1.219e-01 3.642e-16 3.346e+14 < 2e-16 ***
## Exportaciones.l2 -2.897e-01 1.464e-15 -1.979e+14 < 2e-16 ***
## Empleo.l2 2.537e+00 1.775e-14 1.429e+14 < 2e-16 ***
## Innovación.l2 3.668e-01 6.763e-16 5.424e+14 < 2e-16 ***
## Inseguridad.l2 2.049e-01 5.175e-16 3.959e+14 < 2e-16 ***
## Salario.l2 -5.987e-02 4.381e-16 -1.367e+14 < 2e-16 ***
## Educación.l2 2.268e-03 1.334e-15 1.701e+12 < 2e-16 ***
## Tipo_de_Cambio.l2 5.944e-01 1.161e-15 5.120e+14 < 2e-16 ***
## IED_Flujos.l3 -2.263e-02 3.143e-16 -7.198e+13 < 2e-16 ***
## Exportaciones.l3 -5.785e-01 8.486e-16 -6.817e+14 < 2e-16 ***
## Empleo.l3 3.821e+00 8.794e-15 4.345e+14 < 2e-16 ***
## Innovación.l3 -5.844e-01 7.618e-16 -7.671e+14 < 2e-16 ***
## Inseguridad.l3 -4.706e-02 2.801e-16 -1.681e+14 < 2e-16 ***
## Salario.l3 1.834e-01 3.931e-16 4.666e+14 < 2e-16 ***
## Educación.l3 1.445e+00 1.708e-15 8.463e+14 < 2e-16 ***
## Tipo_de_Cambio.l3 2.294e-01 6.406e-16 3.580e+14 < 2e-16 ***
## const 3.539e-17 1.350e-17 2.623e+00 0.00929 **
## sd1 -4.585e-02 1.364e-16 -3.362e+14 < 2e-16 ***
## sd2 -8.277e-17 6.676e-17 -1.240e+00 0.21628
## sd3 -4.585e-02 1.381e-16 -3.320e+14 < 2e-16 ***
## sd4 -1.074e-16 6.609e-17 -1.626e+00 0.10533
## sd5 -4.585e-02 1.380e-16 -3.322e+14 < 2e-16 ***
## sd6 -5.214e-18 6.609e-17 -7.900e-02 0.93718
## sd7 -4.585e-02 1.385e-16 -3.311e+14 < 2e-16 ***
## sd8 4.201e-17 6.609e-17 6.360e-01 0.52562
## sd9 -4.585e-02 1.385e-16 -3.311e+14 < 2e-16 ***
## sd10 -8.382e-17 6.594e-17 -1.271e+00 0.20496
## sd11 -4.585e-02 1.377e-16 -3.331e+14 < 2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
##
## Residual standard error: 2.227e-16 on 237 degrees of freedom
## Multiple R-Squared: 1, Adjusted R-squared: 1
## F-statistic: 2.624e+29 on 35 and 237 DF, p-value: < 2.2e-16
##
##
## Estimation results for equation Tipo_de_Cambio:
## ===============================================
## Tipo_de_Cambio = IED_Flujos.l1 + Exportaciones.l1 + Empleo.l1 + Innovación.l1 + Inseguridad.l1 + Salario.l1 + Educación.l1 + Tipo_de_Cambio.l1 + IED_Flujos.l2 + Exportaciones.l2 + Empleo.l2 + Innovación.l2 + Inseguridad.l2 + Salario.l2 + Educación.l2 + Tipo_de_Cambio.l2 + IED_Flujos.l3 + Exportaciones.l3 + Empleo.l3 + Innovación.l3 + Inseguridad.l3 + Salario.l3 + Educación.l3 + Tipo_de_Cambio.l3 + const + sd1 + sd2 + sd3 + sd4 + sd5 + sd6 + sd7 + sd8 + sd9 + sd10 + sd11
##
## Estimate Std. Error t value Pr(>|t|)
## IED_Flujos.l1 1.324e-01 7.391e-16 1.791e+14 <2e-16 ***
## Exportaciones.l1 -2.709e-01 2.837e-15 -9.549e+13 <2e-16 ***
## Empleo.l1 1.963e+01 4.615e-14 4.253e+14 <2e-16 ***
## Innovación.l1 -3.010e-01 3.046e-15 -9.880e+13 <2e-16 ***
## Inseguridad.l1 -6.080e-01 1.566e-15 -3.883e+14 <2e-16 ***
## Salario.l1 -2.614e-01 1.068e-15 -2.448e+14 <2e-16 ***
## Educación.l1 -2.763e+00 8.858e-15 -3.120e+14 <2e-16 ***
## Tipo_de_Cambio.l1 5.416e-01 2.733e-15 1.981e+14 <2e-16 ***
## IED_Flujos.l2 1.675e-01 1.306e-15 1.282e+14 <2e-16 ***
## Exportaciones.l2 1.397e+00 5.251e-15 2.660e+14 <2e-16 ***
## Empleo.l2 -1.734e+01 6.368e-14 -2.722e+14 <2e-16 ***
## Innovación.l2 -8.430e-01 2.426e-15 -3.475e+14 <2e-16 ***
## Inseguridad.l2 2.132e-01 1.856e-15 1.149e+14 <2e-16 ***
## Salario.l2 -1.994e-01 1.572e-15 -1.269e+14 <2e-16 ***
## Educación.l2 1.390e+00 4.783e-15 2.906e+14 <2e-16 ***
## Tipo_de_Cambio.l2 -1.820e+00 4.164e-15 -4.371e+14 <2e-16 ***
## IED_Flujos.l3 3.823e-01 1.128e-15 3.391e+14 <2e-16 ***
## Exportaciones.l3 4.600e-01 3.044e-15 1.511e+14 <2e-16 ***
## Empleo.l3 -3.920e+00 3.154e-14 -1.243e+14 <2e-16 ***
## Innovación.l3 1.890e+00 2.733e-15 6.916e+14 <2e-16 ***
## Inseguridad.l3 -1.337e-02 1.005e-15 -1.331e+13 <2e-16 ***
## Salario.l3 -7.649e-01 1.410e-15 -5.425e+14 <2e-16 ***
## Educación.l3 3.168e+00 6.125e-15 5.172e+14 <2e-16 ***
## Tipo_de_Cambio.l3 -2.158e-01 2.298e-15 -9.394e+13 <2e-16 ***
## const -4.141e-17 4.841e-17 -8.550e-01 0.3932
## sd1 1.740e-01 4.891e-16 3.557e+14 <2e-16 ***
## sd2 4.049e-16 2.394e-16 1.691e+00 0.0922 .
## sd3 1.740e-01 4.954e-16 3.512e+14 <2e-16 ***
## sd4 5.382e-16 2.370e-16 2.270e+00 0.0241 *
## sd5 1.740e-01 4.951e-16 3.514e+14 <2e-16 ***
## sd6 2.953e-16 2.370e-16 1.246e+00 0.2140
## sd7 1.740e-01 4.967e-16 3.503e+14 <2e-16 ***
## sd8 3.158e-16 2.370e-16 1.332e+00 0.1840
## sd9 1.740e-01 4.968e-16 3.502e+14 <2e-16 ***
## sd10 4.111e-16 2.365e-16 1.738e+00 0.0835 .
## sd11 1.740e-01 4.937e-16 3.524e+14 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
##
## Residual standard error: 7.988e-16 on 237 degrees of freedom
## Multiple R-Squared: 1, Adjusted R-squared: 1
## F-statistic: 4.552e+29 on 35 and 237 DF, p-value: < 2.2e-16
##
##
##
## Covariance matrix of residuals:
## IED_Flujos Exportaciones Empleo Innovación Inseguridad
## IED_Flujos 3.649e-30 6.177e-31 1.024e-31 9.616e-31 1.722e-30
## Exportaciones 6.177e-31 9.953e-31 6.192e-32 2.681e-31 1.244e-30
## Empleo 1.024e-31 6.192e-32 5.682e-33 3.360e-32 1.109e-31
## Innovación 9.616e-31 2.681e-31 3.360e-32 3.045e-31 5.372e-31
## Inseguridad 1.722e-30 1.244e-30 1.109e-31 5.372e-31 2.487e-30
## Salario 4.880e-31 5.095e-31 3.073e-32 1.427e-31 6.195e-31
## Educación 3.765e-32 -1.566e-31 -9.104e-33 -4.484e-33 -2.442e-31
## Tipo_de_Cambio 6.996e-31 6.929e-31 5.137e-32 2.230e-31 1.164e-30
## Salario Educación Tipo_de_Cambio
## IED_Flujos 4.880e-31 3.765e-32 6.996e-31
## Exportaciones 5.095e-31 -1.566e-31 6.929e-31
## Empleo 3.073e-32 -9.104e-33 5.137e-32
## Innovación 1.427e-31 -4.484e-33 2.230e-31
## Inseguridad 6.195e-31 -2.442e-31 1.164e-30
## Salario 4.837e-31 -4.543e-32 3.717e-31
## Educación -4.543e-32 4.959e-32 -1.235e-31
## Tipo_de_Cambio 3.717e-31 -1.235e-31 6.380e-31
##
## Correlation matrix of residuals:
## IED_Flujos Exportaciones Empleo Innovación Inseguridad Salario
## IED_Flujos 1.0000 0.3241 0.7109 0.91226 0.5715 0.3673
## Exportaciones 0.3241 1.0000 0.8234 0.48704 0.7908 0.7344
## Empleo 0.7109 0.8234 1.0000 0.80779 0.9330 0.5862
## Innovación 0.9123 0.4870 0.8078 1.00000 0.6173 0.3718
## Inseguridad 0.5715 0.7908 0.9330 0.61735 1.0000 0.5649
## Salario 0.3673 0.7344 0.5862 0.37176 0.5649 1.0000
## Educación 0.0885 -0.7048 -0.5424 -0.03649 -0.6954 -0.2934
## Tipo_de_Cambio 0.4585 0.8696 0.8532 0.50586 0.9244 0.6690
## Educación Tipo_de_Cambio
## IED_Flujos 0.08850 0.4585
## Exportaciones -0.70484 0.8696
## Empleo -0.54236 0.8532
## Innovación -0.03649 0.5059
## Inseguridad -0.69538 0.9244
## Salario -0.29336 0.6690
## Educación 1.00000 -0.6944
## Tipo_de_Cambio -0.69440 1.0000
# Testing model 1 residuals for stationarity
VAR_model2_residuals<-data.frame(residuals(VAR_model2))
adf.test(VAR_model2_residuals$IED_Flujos)
##
## Augmented Dickey-Fuller Test
##
## data: VAR_model2_residuals$IED_Flujos
## Dickey-Fuller = -8.7656, Lag order = 6, p-value = 0.01
## alternative hypothesis: stationary
After applying the adf test we get a p-value of 0.01<0.05, which means the residuals of model 2 are stationary.
# Testing residuals autocorrelation
Box.test(VAR_model2_residuals$IED_Flujos,lag=,type="Ljung-Box")
##
## Box-Ljung test
##
## data: VAR_model2_residuals$IED_Flujos
## X-squared = 39.308, df = 1, p-value = 3.619e-10
The residuals seem to show autocorrelation, the p-value is<0.05.
After de diagnostic tests the VAR_Model 2 might generate a great forecast, because it analyzes a stationary data time serie and uses diff and log transformations to smooth the data and make better predictions.
- “Exportaciones.l3” has a negative coefficent, for the
Direct Foreign Investment value (Y), which means the value of this
variable in the past 3 periods is related with a decrease in the actual
dependent variable.
-Empleo.l3 has a positive coefficent, for the Direct Foreign
Investment value (Y), which means the value of this variable in the past
3 periods is related with an increase in the actual dependent
variable.
-Innovación.l3 has a negative coefficent, for the Direct
Foreign Investment value (Y), which means the value of this variable in
the past 3 periods is related with an increase in the actual dependent
variable.
-Inseguridad.l3 has a negative coefficent, for the Direct
Foreign Investment value (Y), which means the value of this variable in
the past 3 periods is related with a decrease in the actual dependent
variable. -Salario.l3 has a positive coefficent, for the Direct
Foreign Investment value (Y), which means the value of this variable in
the past 3 periods is related with an increase in the actual dependent
variable.
-Educación.l3 has a positive coefficent, for the Direct Foreign
Investment value (Y), which means the value of this variable in the past
3 periods is related with an increase in the actual dependent variable.
-Tipo_de_Cambio.l3 has a positive coefficent, for the Direct
Foreign Investment value (Y), which means the value of this variable in
the past 3 periods is related with an increase in the actual dependent
variable.
####- Is there an instantaneous causality between IED_Flujos and the selected explanatory variables? Estimate a Granger Causality Test to either reject or fail to reject the hypothesis of instantaneous causality.
granger_Flujos<-causality(VAR_model2,cause="IED_Flujos")
granger_Flujos
## $Granger
##
## Granger causality H0: IED_Flujos do not Granger-cause Exportaciones
## Empleo Innovación Inseguridad Salario Educación Tipo_de_Cambio
##
## data: VAR object VAR_model2
## F-Test = 9.3248e+29, df1 = 21, df2 = 1896, p-value < 2.2e-16
##
##
## $Instant
##
## H0: No instantaneous causality between: IED_Flujos and Exportaciones
## Empleo Innovación Inseguridad Salario Educación Tipo_de_Cambio
##
## data: VAR object VAR_model2
## Chi-squared = 130.68, df = 7, p-value < 2.2e-16
As we have a p-value<0.05, we can say that the Direct Foreign Investment Flow has a signifficant effect in at least one of the selected variables in model 2.
In the Time Series Model 1 section we got to analyze time series models of Direct Foreign Investment flows in a quarter format. From first sight, an insight was that we get a lower AIC makin the ARMA model, this compating the results with the ARIMA model. The difference between both models is that the ARMA model already assumes that the serie is stationary, while the ARIMA doesn’t. After analyzing both models we selecte the model ARMA and attempted to making a forecast for the next 5 periods. Here we discovered that the future period might have a value between -161109 and 295748, taking into account the point forecast is of 139819.5.