0

The VAR model generalizes the univariate auto-regressive (AR) model to multiple time series. I would like to implement a Vector Auto-Regression Model that outlines the following formula based on the observation of time t:

x(t) = c + (t-1)∑(i = t + T)* a(i)x(i) + €(t)

a(i) = parameters of the model €(t) = Gaussian noise

The data I'm using is very big so I won't post it, but one of the things I need help with is outputting the adjacency matrix for any synthetic data. This is what I have:

function [ beta, adj,results ] = granger( id, t, X, lambda, lag, param )
%GRANGER Graphical Granger Modeling
% INPUTS:  id = Column with n elements of unique subject identifiers used to indicate
%               measurements from the same subjects.
%           t = Column with n elements of measurement times corresponding to id.
%               NB: AT THE MOMENT ASSUMING EQUISPACED DATA.
%           X = n-by-(p+1) Matrix of covariates corresponding to id and t. 
%          lambda = tunning parameter for the penalty terms.
%          param = Struct of any other parameters you want to pass to your
%               code.
%          lag = value of time lag to look backward from current time.
% OUTPUTS:   bhat  = estimated effects parameters corresponding to X.
%            adj = adjacency matrix among the columns of X.
%            results = Struct of any other results you want to send out
%               from your code.

if nargin<5; param={}; end;

% if ~isfield(param,'maxIt'); param.maxIt = 1000; end %For example, set max iterations as 1000.
% if ~isfield(param,'tol'); param.tol = 0.00001; end; % Convergence tolerance;


a = ucf.x;
b = ucf.y;
end
Derozan
  • 5
  • 1
  • 4
  • If you have Econometrix toolbox, you can try to use its VAR model implementation http://nl.mathworks.com/help/econ/var-models.html, although your (t-1) factor might be a problem – Kostya Dec 09 '14 at 22:59
  • the (t-1) actually goes at the top of the sigma, just didn't know how to write it, and the (i - t +T) is at the bottom of the sigma. – Derozan Dec 10 '14 at 17:12

0 Answers0