www.gusucode.com > econ 案例源码程序 matlab代码 > econ/FitAVARModelExample.m
%% Fit a VAR Model % This example uses two series: the consumer price index (CPI) and the % unemployment rate (UNRATE) from the data set |Data_USEconmodel|. %% % Obtain the two time series, and convert them for stationarity: % Copyright 2015 The MathWorks, Inc. load Data_USEconModel cpi = DataTable.CPIAUCSL; cpi = log(cpi); dCPI = diff(cpi); unem = DataTable.UNRATE; Y = [dCPI,unem(2:end)]; %% % Create a VAR model: Spec = vgxset('n',2,'nAR',4,'Constant',true) %% % Fit the model to the data using |vgxvarx|: [EstSpec,EstStdErrors,logL,W] = vgxvarx(Spec,Y); vgxdisp(EstSpec)