The easiest way to perform this analysis is to use a statistical package that features Vector Autoregression and Vector-valued Error Correction Models.
Example: http://www.statsmodels.org/dev/generated/statsmodels.tsa.vec...
Example: http://www.statsmodels.org/dev/generated/statsmodels.tsa.vec...