Universidad Rafael Landívar

Facultad de Ciencias Economicas y Empresariales

Econometría II Sección 2

Examen Teórico (30 puntos)

1. ¿Que es un modelo VAR?

Un modelo de vectores autorregresivos es un modelo de ecuaciones de predicción. En un modelo VAR se conoce el numero de variables y su grado de correlación entre ellas. El modelo VAR es autorregresivo, esto quiere decir que, los valores futuros pronosticados por el modelo dependen de los valores pasados (valores de rezago).

2. ¿Qué parámetros utiliza el modelo VAR?

El modelo de vectores autorregresivos utiliza como parámetros valores de rezago, es decir, valores pasados de la o las variables que conforman el modelo.

3. ¿Para que sirve un modelo VAR?

El modelo de vectores autorregresivos sirve para pronosticar valores futuros. El modelo VAR transforma la autorregresion de una sola variable a un vector de multiples variales temporales.

4. ¿Qué es un modelo SVAR?

EL modelo SVAR se refiere a el modelo VAR estructrual. Este tipo de modelo se utiliza para establecer una relación de causa entre las variables generadoras del modelo. Esto se realiza con el fin de generar restricciones que le permitan al modelo obtener resultados mas aproximados.

5. ¿Para qué sirve realizar un modelo SVAR?

El modelo de vectores autorregresivos estructurales sirve para estimar la relacion temporal entre las variables por medio de la identificacion de supuestos que permitan establecer relaciones causales entre dichas variables.

6. ¿Qué información podemos obtener de la distribucion de la varianza?

El análisis de la distribucipon de la varianza permite separar la varianza del error de prediccion de cada una de las variables que compo en los componentes que le son atribuidos a cada uno de los shocks que experimenta el sistema.

Exámen Práctico (70 puntos)

1. Utilizando los datos uschange de la librería fpp2, utilice las columnas Savings, Unemployment y Production. Utilizando los modelos VAR genere una predicción de los siguientes 2 años.

library(vars)
## Warning: package 'vars' was built under R version 4.1.3
## Loading required package: MASS
## Loading required package: strucchange
## Loading required package: zoo
## 
## Attaching package: 'zoo'
## The following objects are masked from 'package:base':
## 
##     as.Date, as.Date.numeric
## Loading required package: sandwich
## Loading required package: urca
## Loading required package: lmtest
library(tidyverse)
## -- Attaching packages --------------------------------------- tidyverse 1.3.1 --
## v ggplot2 3.3.5     v purrr   0.3.4
## v tibble  3.1.6     v dplyr   1.0.7
## v tidyr   1.2.0     v stringr 1.4.0
## v readr   2.1.2     v forcats 0.5.1
## -- Conflicts ------------------------------------------ tidyverse_conflicts() --
## x stringr::boundary() masks strucchange::boundary()
## x dplyr::filter()     masks stats::filter()
## x dplyr::lag()        masks stats::lag()
## x dplyr::select()     masks MASS::select()
library(ggfortify)
library(forecast)
## Registered S3 method overwritten by 'quantmod':
##   method            from
##   as.zoo.data.frame zoo
## Registered S3 methods overwritten by 'forecast':
##   method                 from     
##   autoplot.Arima         ggfortify
##   autoplot.acf           ggfortify
##   autoplot.ar            ggfortify
##   autoplot.bats          ggfortify
##   autoplot.decomposed.ts ggfortify
##   autoplot.ets           ggfortify
##   autoplot.forecast      ggfortify
##   autoplot.stl           ggfortify
##   autoplot.ts            ggfortify
##   fitted.ar              ggfortify
##   fortify.ts             ggfortify
##   residuals.ar           ggfortify
library(seasonal)
## 
## Attaching package: 'seasonal'
## The following object is masked from 'package:tibble':
## 
##     view
library(tseries)
library(fpp2)
## -- Attaching packages ---------------------------------------------- fpp2 2.4 --
## v fma       2.4     v expsmooth 2.3
## 
# Cargar datos
series<-uschange
?uschange
## starting httpd help server ...
##  done
uschange
##         Consumption      Income  Production      Savings Unemployment
## 1970 Q1  0.61598622  0.97226104 -2.45270031   4.81031150          0.9
## 1970 Q2  0.46037569  1.16908472 -0.55152509   7.28799234          0.5
## 1970 Q3  0.87679142  1.55327055 -0.35870786   7.28901306          0.5
## 1970 Q4 -0.27424514 -0.25527238 -2.18545486   0.98522964          0.7
## 1971 Q1  1.89737076  1.98715363  1.90973412   3.65777061         -0.1
## 1971 Q2  0.91199291  1.44733417  0.90153584   6.05134180         -0.1
## 1971 Q3  0.79453885  0.53181193  0.30801942  -0.44583221          0.1
## 1971 Q4  1.64858747  1.16012514  2.29130441  -1.53087186          0.0
## 1972 Q1  1.31372218  0.45701150  4.14957387  -4.35859438         -0.2
## 1972 Q2  1.89147495  1.01662441  1.89062398  -5.05452579         -0.1
## 1972 Q3  1.53071400  1.90410126  1.27335290   5.80995904         -0.2
## 1972 Q4  2.31829471  3.89025866  3.43689207  16.04471706         -0.3
## 1973 Q1  1.81073916  0.70825266  2.79907636  -5.34886849         -0.3
## 1973 Q2 -0.04173996  0.79430954  0.81768862   8.42603436          0.0
## 1973 Q3  0.35423556  0.43381827  0.86899693   2.75879565         -0.1
## 1973 Q4 -0.29163216  1.09380979  1.47296187  11.14642986          0.1
## 1974 Q1 -0.87702794 -1.66168482 -0.88248358  -2.53351449          0.2
## 1974 Q2  0.35113555 -0.93835321  0.07427919  -6.59264464          0.3
## 1974 Q3  0.40959770  0.09448779 -0.41314971   0.51717884          0.5
## 1974 Q4 -1.47580863 -0.12259599 -4.06411893  11.34339540          1.3
## 1975 Q1  0.83225762 -0.16369546 -6.85103912  -5.47619069          1.4
## 1975 Q2  1.65583461  4.53650956 -1.33129558  24.30960536          0.2
## 1975 Q3  1.41942029 -1.46376532  2.42435972 -17.65616104         -0.4
## 1975 Q4  1.05437932  0.76166351  2.16904208   0.64809041         -0.2
## 1976 Q1  1.97998024  1.16825761  3.02720471  -2.95006644         -0.6
## 1976 Q2  0.91391607  0.51729906  1.27881101  -1.47455755          0.0
## 1976 Q3  1.05532326  0.73370026  1.30386487  -0.06754475          0.0
## 1976 Q4  1.29889825  0.59458339  1.77537765  -3.57672239          0.2
## 1977 Q1  1.13637586 -0.03108003  2.05516067  -9.16055658         -0.4
## 1977 Q2  0.54994073  1.23808955  3.05838507   9.09050404         -0.2
## 1977 Q3  0.94985262  1.51880293  1.10308888   7.94495719         -0.4
## 1977 Q4  1.49599724  1.91456240  0.63346850   6.69627648         -0.4
## 1978 Q1  0.57549599  0.70266687 -0.29339056   2.92296383         -0.1
## 1978 Q2  2.11120960  0.98314132  3.94815264  -6.81114259         -0.4
## 1978 Q3  0.41796279  0.71992620  0.87114701   4.79207162          0.1
## 1978 Q4  0.79792710  0.78553605  1.78447991   2.37118400          0.0
## 1979 Q1  0.50584598  1.05755946  0.42594327   7.77418337         -0.2
## 1979 Q2 -0.05775339 -0.86765105 -0.20491944  -5.28634896         -0.1
## 1979 Q3  0.97730010  0.47100340 -0.29723637  -1.84549644          0.2
## 1979 Q4  0.26826982  0.44037974  0.33560928   4.04959810          0.1
## 1980 Q1 -0.15391875  0.33827686  0.41056141   5.86168864          0.3
## 1980 Q2 -2.27411019 -1.46388507 -4.30076832   8.24322919          1.3
## 1980 Q3  1.07188123  1.21301507 -1.64181977   5.70775044         -0.1
## 1980 Q4  1.31644941  1.94243865  3.78045520   9.15098787         -0.3
## 1981 Q1  0.52472770 -0.26813406  0.24627687  -5.68139002          0.2
## 1981 Q2 -0.01728203 -0.02363025  0.30977573   0.88183993          0.1
## 1981 Q3  0.40165150  2.02680183  0.91707444  15.99035721          0.1
## 1981 Q4 -0.75287620  0.19560628 -2.25457797   7.80550650          0.9
## 1982 Q1  0.65938376  0.11969888 -2.07131293  -3.34243955          0.5
## 1982 Q2  0.36854173  0.57548997 -1.24766384   2.19400166          0.6
## 1982 Q3  0.76954464  0.53484410 -1.40050430   0.03499563          0.5
## 1982 Q4  1.80876006  0.44938311 -1.90375664  -9.57651468          0.7
## 1983 Q1  0.96802954  0.85588425  1.14655720   0.34595460         -0.5
## 1983 Q2  1.95946831  0.70632719  2.17942248 -10.17004699         -0.2
## 1983 Q3  1.73949442  1.49810999  3.36771897   0.21217916         -0.9
## 1983 Q4  1.56389332  2.13138911  2.58168445   8.21600068         -0.9
## 1984 Q1  0.84526442  2.02348788  2.89709545  13.86918150         -0.5
## 1984 Q2  1.41504495  1.64921136  1.53821324   4.38900229         -0.6
## 1984 Q3  0.76546608  1.36163845  0.72128740   6.51686089          0.1
## 1984 Q4  1.31380062  0.81927319  0.04115557  -2.87544931          0.0
## 1985 Q1  1.68655320 -0.23895759  0.32353159 -18.71008389         -0.1
## 1985 Q2  0.93436990  1.90677905  0.07020996  11.82871950          0.2
## 1985 Q3  1.90256675 -0.33536283 -0.14046924 -23.57393474         -0.3
## 1985 Q4  0.25656565  1.14181151  0.57978813  11.36628338         -0.1
## 1986 Q1  0.84304279  1.23951110  0.58132135   5.86126836          0.2
## 1986 Q2  1.11177390  1.31938549 -0.57641778   3.27551734          0.0
## 1986 Q3  1.79499406  0.70477150  0.37249329 -10.09044542         -0.2
## 1986 Q4  0.63768446  0.17977925  1.13734778  -4.82920131         -0.4
## 1987 Q1  0.01569397  0.81973366  1.30758228  12.46424452          0.0
## 1987 Q2  1.37731686 -0.97505791  1.75000563 -29.52866718         -0.4
## 1987 Q3  1.15225712  1.80185055  1.84366200  12.32810406         -0.3
## 1987 Q4  0.21016439  1.32743427  2.40645058  16.63076101         -0.2
## 1988 Q1  1.76316026  1.44861875  0.92013121  -0.96896505          0.0
## 1988 Q2  0.73053714  1.02084894  0.87316353   5.67776867         -0.3
## 1988 Q3  0.85083233  0.95820336  0.38103668   3.64649867          0.0
## 1988 Q4  1.13789838  0.96207024  0.70292025  -0.19730358         -0.1
## 1989 Q1  0.46064152  1.22693023  0.43372685  10.01461545         -0.3
## 1989 Q2  0.46937808 -0.29489091 -0.36675732  -8.15576525          0.3
## 1989 Q3  0.98950145  0.67822897 -0.62142121  -2.48622554          0.0
## 1989 Q4  0.43942767  0.80025832  0.42443392   5.44681102          0.1
## 1990 Q1  0.85543417  0.83939484  0.68265169   2.87544931         -0.2
## 1990 Q2  0.31230451  0.59572848  0.77446547   5.10951644          0.0
## 1990 Q3  0.40261313  0.03740765  0.41944800  -3.17767248          0.7
## 1990 Q4 -0.75910716 -0.79479735 -1.57345296  -0.17953326          0.4
## 1991 Q1 -0.34535008  0.21183290 -1.91422028   6.49315257          0.5
## 1991 Q2  0.83564224  0.69043356  0.59131506  -0.30920615          0.1
## 1991 Q3  0.48439843  0.36205181  1.36255645  -0.14086493          0.0
## 1991 Q4 -0.02626579  0.85100324  0.21710308  11.34193010          0.4
## 1992 Q1  1.85996999  2.12421067 -0.13365365   7.23265150          0.1
## 1992 Q2  0.68354371  1.04095059  1.76874773   5.46708666          0.4
## 1992 Q3  1.07661214  0.43562041  0.76167388  -5.93646090         -0.2
## 1992 Q4  1.18372396  0.34210852  1.05024577  -5.88618856         -0.2
## 1993 Q1  0.37817936  0.55877186  0.87901471   2.63464703         -0.4
## 1993 Q2  0.89392729  0.17627103  0.21755108  -6.91664675          0.0
## 1993 Q3  1.09813766  0.05868803  0.40135891 -11.99337844         -0.3
## 1993 Q4  0.88122025  0.65496353  1.49618275  -1.83708870         -0.2
## 1994 Q1  1.14064791  0.69846579  1.22213656  -5.18600629          0.0
## 1994 Q2  0.77176225  1.05367166  1.78250275   5.15609751         -0.4
## 1994 Q3  0.77214364  0.59247377  1.26718100  -2.42215898         -0.2
## 1994 Q4  1.07014805  1.38110661  2.04370404   6.32351898         -0.4
## 1995 Q1  0.26420505  0.94873528  1.02552601  10.11514398         -0.1
## 1995 Q2  0.89311141  0.22780635  0.33785685 -10.60541172          0.2
## 1995 Q3  0.91264702  0.88957006  0.90043887  -0.11570727          0.0
## 1995 Q4  0.70025425  0.57591998  0.87467273  -2.90726686          0.0
## 1996 Q1  0.92360967  0.95255663  0.69285195   2.55933958         -0.1
## 1996 Q2  1.07997887  0.95161791  2.11134752  -0.75802112         -0.2
## 1996 Q3  0.60055799  0.79369738  1.24418680   3.33843952         -0.1
## 1996 Q4  0.78298122  0.52035746  1.35396890  -3.33843952          0.2
## 1997 Q1  1.04949253  0.99858552  1.86714700   0.61269338         -0.2
## 1997 Q2  0.45219855  0.85103564  1.48763922   6.17532322         -0.2
## 1997 Q3  1.69654264  1.18352222  2.28632066  -7.22796452         -0.1
## 1997 Q4  1.18062797  1.42325742  2.48091341   5.43456565         -0.2
## 1998 Q1  1.02693626  2.10753052  1.10343775  19.35335228          0.0
## 1998 Q2  1.75069399  1.38767133  0.65122238  -4.81709478         -0.2
## 1998 Q3  1.30596977  1.01464427  0.72551955  -3.12983982          0.1
## 1998 Q4  1.45888615  0.80893032  1.44421674  -9.14923404         -0.2
## 1999 Q1  0.94821191  0.89173174  1.10341663   1.88735718         -0.2
## 1999 Q2  1.46971415  0.24722185  0.98574261 -23.49652903          0.1
## 1999 Q3  1.12921436  0.66729226  0.90279881  -9.86264835         -0.1
## 1999 Q4  1.45748895  1.46092242  1.75533234   2.35825225         -0.2
## 2000 Q1  1.51106759  1.95061335  0.99682019  12.28684080          0.0
## 2000 Q2  0.95508878  1.03174349  1.23293805   1.28001748          0.0
## 2000 Q3  0.96797647  1.16178668 -0.10225268   2.57390229         -0.1
## 2000 Q4  0.88629738  0.33725343 -0.20388383 -13.16296208          0.0
## 2001 Q1  0.42159086  0.84865826 -1.35143911  13.22491995          0.4
## 2001 Q2  0.25689982 -0.08818148 -1.25954437  -6.89043916          0.2
## 2001 Q3  0.36381084  2.33678920 -1.44101744  41.66826457          0.5
## 2001 Q4  1.51630321 -1.24443353 -1.06013675 -56.75209674          0.7
## 2002 Q1  0.29958257  2.40331419  0.70916406  50.75796205          0.0
## 2002 Q2  0.50899032  0.50559877  1.54280957   0.87861837          0.1
## 2002 Q3  0.69667241 -0.12828194  0.59478143 -14.70397426         -0.1
## 2002 Q4  0.53634306  0.47941927 -0.05776556   1.58733492          0.3
## 2003 Q1  0.43826169  0.27834026  0.53922789   0.49744834         -0.1
## 2003 Q2  1.10719086  1.43729445 -0.69876172   7.00891625          0.4
## 2003 Q3  1.46377882  1.62544947  0.60727351   6.18413150         -0.2
## 2003 Q4  0.77334046  0.40353864  1.00599126  -6.89274778         -0.4
## 2004 Q1  0.96768535  0.72653162  0.65792806  -2.96152040          0.1
## 2004 Q2  0.64760607  0.98056746  0.57461780   8.30885627         -0.2
## 2004 Q3  0.95117167  0.52450113  0.56330030  -8.99318286         -0.2
## 2004 Q4  1.02041702  1.24238706  1.38522763   6.23585017          0.0
## 2005 Q1  0.76172556 -0.96827007  1.39435718 -42.28191228         -0.2
## 2005 Q2  1.08136588  0.78835467  0.50586367 -18.27592893         -0.2
## 2005 Q3  0.77186494  0.51136949 -0.50305848  -7.87665229          0.0
## 2005 Q4  0.37591485  0.82191843  0.93365010  20.37236078         -0.1
## 2006 Q1  1.11522822  2.25904474  0.95057853  37.40653542         -0.2
## 2006 Q2  0.53100554  0.14987813  0.59636010 -12.34810568         -0.1
## 2006 Q3  0.58208747  0.28490722  0.33552773 -10.55276140         -0.1
## 2006 Q4  1.01434389  1.30059162  0.25603401   6.03100080         -0.1
## 2007 Q1  0.52486184  0.65373993  0.91794957   6.60516929          0.0
## 2007 Q2  0.33874119  0.19260870  1.19594247  -7.23648452          0.2
## 2007 Q3  0.44391875  0.26238732  0.22356909  -9.00674555          0.1
## 2007 Q4  0.12505584  0.08392938  0.16424632   2.32887238          0.3
## 2008 Q1 -0.20652548  0.71926565 -0.42872571  29.83728599          0.1
## 2008 Q2  0.16783443  2.08693775 -1.41297022  46.43989041          0.5
## 2008 Q3 -0.72499446 -2.32611860 -3.26349945 -32.53252494          0.5
## 2008 Q4 -1.21068558  0.64019534 -4.35417741  36.31240490          1.2
## 2009 Q1 -0.34354370 -0.18888849 -5.75045075   0.92306020          1.4
## 2009 Q2 -0.45174364  0.70899368 -3.00372447  16.09059408          0.8
## 2009 Q3  0.60491332 -1.10343180  1.39880419 -24.49229966          0.3
## 2009 Q4 -0.01115014 -0.13213193  1.54400617   0.84829220          0.1
## 2010 Q1  0.53481740  0.10094986  1.88006931  -5.54399051          0.0
## 2010 Q2  0.81040406  1.29229259  2.05402479  11.65612884         -0.5
## 2010 Q3  0.64501881  0.49678098  1.42683671  -0.35208609          0.1
## 2010 Q4  1.01833874  0.69495229  0.37927209  -3.27335958         -0.2
## 2011 Q1  0.50041315  1.21571502  0.50174040  14.33860193         -0.3
## 2011 Q2  0.20141978 -0.15658108  0.21878696  -4.07705131          0.1
## 2011 Q3  0.43372599  0.52891255  1.01113866   2.72250400         -0.1
## 2011 Q4  0.33593895  0.06074719  0.85151692  -3.45447712         -0.5
## 2012 Q1  0.60108995  1.62204885  0.88651817  17.62530510         -0.3
## 2012 Q2  0.16942956  0.76689543  0.62923586   8.96949710          0.0
## 2012 Q3  0.26416034 -0.05071452  0.07880166  -3.04922177         -0.4
## 2012 Q4  0.27877186  2.59106697  0.63305509  29.04670355          0.1
## 2013 Q1  0.46861292 -4.26525047  0.67713243 -68.78826698         -0.4
## 2013 Q2  0.20545802  0.58146541  0.30744961   7.81647729          0.0
## 2013 Q3  0.46641787  0.58328912  0.23440888   3.49400682         -0.3
## 2013 Q4  0.83917367  0.21494896  0.79208722 -11.27661450         -0.5
## 2014 Q1  0.47345118  1.10369487  0.54709166  13.52020248          0.0
## 2014 Q2  0.93375698  1.29390492  1.33801074   8.24404770         -0.6
## 2014 Q3  0.91687178  0.99853396  0.62352731   2.46195256         -0.2
## 2014 Q4  1.12533250  1.04641801  0.90355427  -1.51305022         -0.3
## 2015 Q1  0.59624005  0.49040680 -0.46710878  -0.75840017         -0.2
## 2015 Q2  0.70814389  0.95495949 -0.69702162   5.02391773         -0.1
## 2015 Q3  0.66496956  0.80166267  0.38060610   3.18092976         -0.3
## 2015 Q4  0.56167978  0.74006260 -0.84554638   3.48278601          0.0
## 2016 Q1  0.40468216  0.51902540 -0.41793048   2.23653405          0.0
## 2016 Q2  1.04770741  0.72372078 -0.20331883  -2.72150106         -0.1
## 2016 Q3  0.72959779  0.64470081  0.47491844  -0.57285793          0.0
autoplot(uschange[,3:5])

# Plot de serie de datos
ts.plot(uschange[,c(3,4,5)], xlab="Tiempo",col=c(3,4,5))

# Busqueda de parametros
selection <-VARselect(uschange[,c(3,4,5)], lag.max=15,type="const")
selection$selection
## AIC(n)  HQ(n)  SC(n) FPE(n) 
##      2      2      1      2
# Creacion del modelo
modelo1<-VAR(uschange[,c(3,4,5)],p=2,type=c("const"))
modelo1
## 
## VAR Estimation Results:
## ======================= 
## 
## Estimated coefficients for equation Production: 
## =============================================== 
## Call:
## Production = Production.l1 + Savings.l1 + Unemployment.l1 + Production.l2 + Savings.l2 + Unemployment.l2 + const 
## 
##   Production.l1      Savings.l1 Unemployment.l1   Production.l2      Savings.l2 
##     0.443231138    -0.009833695    -1.253057668    -0.057492433    -0.010006992 
## Unemployment.l2           const 
##     0.530690891     0.350422160 
## 
## 
## Estimated coefficients for equation Savings: 
## ============================================ 
## Call:
## Savings = Production.l1 + Savings.l1 + Unemployment.l1 + Production.l2 + Savings.l2 + Unemployment.l2 + const 
## 
##   Production.l1      Savings.l1 Unemployment.l1   Production.l2      Savings.l2 
##     -2.05568244     -0.29606465     -6.81463534      1.78019819     -0.02382193 
## Unemployment.l2           const 
##      7.99531280      1.67866777 
## 
## 
## Estimated coefficients for equation Unemployment: 
## ================================================= 
## Call:
## Unemployment = Production.l1 + Savings.l1 + Unemployment.l1 + Production.l2 + Savings.l2 + Unemployment.l2 + const 
## 
##   Production.l1      Savings.l1 Unemployment.l1   Production.l2      Savings.l2 
##    -0.036884554     0.002444545     0.337627743     0.025596317     0.001637642 
## Unemployment.l2           const 
##     0.197630824    -0.001302766
summary(modelo1,equation="Savings")
## 
## VAR Estimation Results:
## ========================= 
## Endogenous variables: Production, Savings, Unemployment 
## Deterministic variables: const 
## Sample size: 185 
## Log Likelihood: -1000.283 
## Roots of the characteristic polynomial:
## 0.6559 0.4112 0.399 0.399 0.3189 0.3189
## Call:
## VAR(y = uschange[, c(3, 4, 5)], p = 2, type = c("const"))
## 
## 
## Estimation results for equation Savings: 
## ======================================== 
## Savings = Production.l1 + Savings.l1 + Unemployment.l1 + Production.l2 + Savings.l2 + Unemployment.l2 + const 
## 
##                 Estimate Std. Error t value Pr(>|t|)    
## Production.l1   -2.05568    1.08290  -1.898 0.059272 .  
## Savings.l1      -0.29606    0.07501  -3.947 0.000114 ***
## Unemployment.l1 -6.81464    4.25954  -1.600 0.111405    
## Production.l2    1.78020    1.05732   1.684 0.093996 .  
## Savings.l2      -0.02382    0.07441  -0.320 0.749235    
## Unemployment.l2  7.99531    4.35419   1.836 0.067991 .  
## const            1.67867    1.19945   1.400 0.163393    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## 
## Residual standard error: 13.01 on 178 degrees of freedom
## Multiple R-Squared: 0.1321,  Adjusted R-squared: 0.1028 
## F-statistic: 4.515 on 6 and 178 DF,  p-value: 0.0002765 
## 
## 
## 
## Covariance matrix of residuals:
##              Production  Savings Unemployment
## Production        1.441  -1.5606     -0.26799
## Savings          -1.561 169.1681      0.55216
## Unemployment     -0.268   0.5522      0.09667
## 
## Correlation matrix of residuals:
##              Production  Savings Unemployment
## Production      1.00000 -0.09996      -0.7181
## Savings        -0.09996  1.00000       0.1365
## Unemployment   -0.71807  0.13654       1.0000
summary(modelo1,equation="Unemployment")
## 
## VAR Estimation Results:
## ========================= 
## Endogenous variables: Production, Savings, Unemployment 
## Deterministic variables: const 
## Sample size: 185 
## Log Likelihood: -1000.283 
## Roots of the characteristic polynomial:
## 0.6559 0.4112 0.399 0.399 0.3189 0.3189
## Call:
## VAR(y = uschange[, c(3, 4, 5)], p = 2, type = c("const"))
## 
## 
## Estimation results for equation Unemployment: 
## ============================================= 
## Unemployment = Production.l1 + Savings.l1 + Unemployment.l1 + Production.l2 + Savings.l2 + Unemployment.l2 + const 
## 
##                  Estimate Std. Error t value Pr(>|t|)   
## Production.l1   -0.036885   0.025887  -1.425  0.15595   
## Savings.l1       0.002445   0.001793   1.363  0.17453   
## Unemployment.l1  0.337628   0.101825   3.316  0.00111 **
## Production.l2    0.025596   0.025275   1.013  0.31258   
## Savings.l2       0.001638   0.001779   0.921  0.35848   
## Unemployment.l2  0.197631   0.104087   1.899  0.05922 . 
## const           -0.001303   0.028673  -0.045  0.96381   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## 
## Residual standard error: 0.3109 on 178 degrees of freedom
## Multiple R-Squared: 0.3155,  Adjusted R-squared: 0.2925 
## F-statistic: 13.68 on 6 and 178 DF,  p-value: 9.504e-13 
## 
## 
## 
## Covariance matrix of residuals:
##              Production  Savings Unemployment
## Production        1.441  -1.5606     -0.26799
## Savings          -1.561 169.1681      0.55216
## Unemployment     -0.268   0.5522      0.09667
## 
## Correlation matrix of residuals:
##              Production  Savings Unemployment
## Production      1.00000 -0.09996      -0.7181
## Savings        -0.09996  1.00000       0.1365
## Unemployment   -0.71807  0.13654       1.0000
summary(modelo1,equation="Production")
## 
## VAR Estimation Results:
## ========================= 
## Endogenous variables: Production, Savings, Unemployment 
## Deterministic variables: const 
## Sample size: 185 
## Log Likelihood: -1000.283 
## Roots of the characteristic polynomial:
## 0.6559 0.4112 0.399 0.399 0.3189 0.3189
## Call:
## VAR(y = uschange[, c(3, 4, 5)], p = 2, type = c("const"))
## 
## 
## Estimation results for equation Production: 
## =========================================== 
## Production = Production.l1 + Savings.l1 + Unemployment.l1 + Production.l2 + Savings.l2 + Unemployment.l2 + const 
## 
##                  Estimate Std. Error t value Pr(>|t|)    
## Production.l1    0.443231   0.099938   4.435 1.61e-05 ***
## Savings.l1      -0.009834   0.006923  -1.420  0.15722    
## Unemployment.l1 -1.253058   0.393103  -3.188  0.00169 ** 
## Production.l2   -0.057492   0.097578  -0.589  0.55648    
## Savings.l2      -0.010007   0.006867  -1.457  0.14681    
## Unemployment.l2  0.530691   0.401838   1.321  0.18831    
## const            0.350422   0.110694   3.166  0.00182 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## 
## Residual standard error: 1.2 on 178 degrees of freedom
## Multiple R-Squared: 0.409,   Adjusted R-squared: 0.389 
## F-statistic: 20.53 on 6 and 178 DF,  p-value: < 2.2e-16 
## 
## 
## 
## Covariance matrix of residuals:
##              Production  Savings Unemployment
## Production        1.441  -1.5606     -0.26799
## Savings          -1.561 169.1681      0.55216
## Unemployment     -0.268   0.5522      0.09667
## 
## Correlation matrix of residuals:
##              Production  Savings Unemployment
## Production      1.00000 -0.09996      -0.7181
## Savings        -0.09996  1.00000       0.1365
## Unemployment   -0.71807  0.13654       1.0000
# Validacion del modelo
# >PortManteu Test > 0.05
serial.test(modelo1, lags.pt=15, type="PT.asymptotic")
## 
##  Portmanteau Test (asymptotic)
## 
## data:  Residuals of VAR object modelo1
## Chi-squared = 138.69, df = 117, p-value = 0.08351
roots(modelo1)
## [1] 0.6558793 0.4112444 0.3989926 0.3989926 0.3189046 0.3189046
normality.test(modelo1, multivariate.only=FALSE)
## $Production
## 
##  JB-Test (univariate)
## 
## data:  Residual of Production equation
## Chi-squared = 44.717, df = 2, p-value = 1.949e-10
## 
## 
## $Savings
## 
##  JB-Test (univariate)
## 
## data:  Residual of Savings equation
## Chi-squared = 149.08, df = 2, p-value < 2.2e-16
## 
## 
## $Unemployment
## 
##  JB-Test (univariate)
## 
## data:  Residual of Unemployment equation
## Chi-squared = 33.933, df = 2, p-value = 4.282e-08
## 
## 
## $JB
## 
##  JB-Test (multivariate)
## 
## data:  Residuals of VAR object modelo1
## Chi-squared = 187.43, df = 6, p-value < 2.2e-16
## 
## 
## $Skewness
## 
##  Skewness only (multivariate)
## 
## data:  Residuals of VAR object modelo1
## Chi-squared = 3.8415, df = 3, p-value = 0.2791
## 
## 
## $Kurtosis
## 
##  Kurtosis only (multivariate)
## 
## data:  Residuals of VAR object modelo1
## Chi-squared = 183.59, df = 3, p-value < 2.2e-16
#Prueba grafica
plot(modelo1, names="Savings")

dev.off()
## null device 
##           1
par(mar=c(1,1,1,1))
acf(residuals(modelo1)[,1])
pacf(residuals(modelo1)[,1])

#Formula
modelo1$varresult$Savings$coefficients
##   Production.l1      Savings.l1 Unemployment.l1   Production.l2      Savings.l2 
##     -2.05568244     -0.29606465     -6.81463534      1.78019819     -0.02382193 
## Unemployment.l2           const 
##      7.99531280      1.67866777
modelo1$varresult$Unemployment$coefficients
##   Production.l1      Savings.l1 Unemployment.l1   Production.l2      Savings.l2 
##    -0.036884554     0.002444545     0.337627743     0.025596317     0.001637642 
## Unemployment.l2           const 
##     0.197630824    -0.001302766
modelo1$varresult$Production$coefficients
##   Production.l1      Savings.l1 Unemployment.l1   Production.l2      Savings.l2 
##     0.443231138    -0.009833695    -1.253057668    -0.057492433    -0.010006992 
## Unemployment.l2           const 
##     0.530690891     0.350422160
# Comparacion con otros modelos
modelo2<-VAR(uschange[,1:2],p=2,type=c("const"))
modelo3<-VAR(uschange[,1:2],p=3,type=c("const"))

aic1<-summary(modelo1)$logLik
aic1
## [1] -1000.283
aic2<-summary(modelo2)$logLik
aic2
## [1] -388.9931
aic3<-summary(modelo3)$logLik
aic3
## [1] -380.1549
autoplot(uschange[,c(3,4,5)])

2. Utilizando un modelo SVAR, realice una predicción sobre el modelo generado anteriormente y realice una predicción sobre los siguientes 2 años.

3. Realice un análisis comparativo de la diferencia encontrada entre los dos modelos generados y anote sus resultados.