<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Vector Autoregressive models in SAS Forecasting and Econometrics</title>
    <link>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/Vector-Autoregressive-models/m-p/706554#M4029</link>
    <description>&lt;P&gt;I am estimating a VAR model with only 2 variable X1 and returns for stocks. Currently, I estimate using PROC VARMAX with a BY statement. I then get the averages across all stocks. My code is :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;*Estimating the model;
	dm 'odsresults; clear';ods _all_ close; run; quit;
	ods output ParameterEstimates=parameterEstimates covInnovation=cov ARRoots=ARRoots;;
	proc varmax data=test_sample ;
		by stock;
			model X Return /p=10 method=LS lagmax=10 print=(estimates covpe roots);
			output lead=0;
		run;quit;
	options nomprint;

* Extract the relevant variances and covariances;
	data cov1 (keep=stock var_X); set cov; where variable="X"; var_X=X; run;
	data cov2 (keep=stock var_return); set cov; where variable="return"; var_return=return; run;
	data cov3 (keep=stock covar_X_return); set cov; where variable="X"; covar_X_return=return; run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I then use these &lt;U&gt;cov&lt;/U&gt; datasets as well as the &lt;U&gt;parameterestimates &lt;/U&gt;dataset to compute the Impulse Response function for each stock ( I create a random shock and then compute the dynamics with 100 time period). I then get the average across all stocks to get the final numbers for the model. I dont post the code here because I dont want to confuse the readers.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My questions are:&lt;/P&gt;
&lt;P&gt;1. Is there a quick step to estimate the VAR across multiple stocks (or groups such as stock-date)?&lt;/P&gt;
&lt;P&gt;2.&amp;nbsp; what is a quick way to produce the Impulse Response Function? That is 1 set of results for multiple stocks, NOT for each individual stock because I want to estimate for the market as a whole. Note that I would want to see the dynamics for a window that is longer than the number of lag used in the model.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;IFRAME class="ginger-extension-definitionpopup" style="display: none;"&gt;&lt;/IFRAME&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 17 Dec 2020 07:40:25 GMT</pubDate>
    <dc:creator>somebody</dc:creator>
    <dc:date>2020-12-17T07:40:25Z</dc:date>
    <item>
      <title>Vector Autoregressive models</title>
      <link>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/Vector-Autoregressive-models/m-p/706554#M4029</link>
      <description>&lt;P&gt;I am estimating a VAR model with only 2 variable X1 and returns for stocks. Currently, I estimate using PROC VARMAX with a BY statement. I then get the averages across all stocks. My code is :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;*Estimating the model;
	dm 'odsresults; clear';ods _all_ close; run; quit;
	ods output ParameterEstimates=parameterEstimates covInnovation=cov ARRoots=ARRoots;;
	proc varmax data=test_sample ;
		by stock;
			model X Return /p=10 method=LS lagmax=10 print=(estimates covpe roots);
			output lead=0;
		run;quit;
	options nomprint;

* Extract the relevant variances and covariances;
	data cov1 (keep=stock var_X); set cov; where variable="X"; var_X=X; run;
	data cov2 (keep=stock var_return); set cov; where variable="return"; var_return=return; run;
	data cov3 (keep=stock covar_X_return); set cov; where variable="X"; covar_X_return=return; run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I then use these &lt;U&gt;cov&lt;/U&gt; datasets as well as the &lt;U&gt;parameterestimates &lt;/U&gt;dataset to compute the Impulse Response function for each stock ( I create a random shock and then compute the dynamics with 100 time period). I then get the average across all stocks to get the final numbers for the model. I dont post the code here because I dont want to confuse the readers.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My questions are:&lt;/P&gt;
&lt;P&gt;1. Is there a quick step to estimate the VAR across multiple stocks (or groups such as stock-date)?&lt;/P&gt;
&lt;P&gt;2.&amp;nbsp; what is a quick way to produce the Impulse Response Function? That is 1 set of results for multiple stocks, NOT for each individual stock because I want to estimate for the market as a whole. Note that I would want to see the dynamics for a window that is longer than the number of lag used in the model.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;IFRAME class="ginger-extension-definitionpopup" style="display: none;"&gt;&lt;/IFRAME&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Dec 2020 07:40:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Forecasting-and-Econometrics/Vector-Autoregressive-models/m-p/706554#M4029</guid>
      <dc:creator>somebody</dc:creator>
      <dc:date>2020-12-17T07:40:25Z</dc:date>
    </item>
  </channel>
</rss>

