如何在matlab中编写向量自回归模型?

如何在matlab中编写向量自回归模型?,matlab,machine-learning,data-mining,autoregressive-models,causality,Matlab,Machine Learning,Data Mining,Autoregressive Models,Causality,VAR模型将单变量自回归(AR)模型推广到多重时间序列。我想实现一个向量自回归模型,该模型基于对时间t的观察,概述了以下公式: x(t)=c+(t-1)∑(i=t+t)*a(i)x(i)+欧元(t) a(i)=模型参数 欧元(t)=高斯噪声 我使用的数据非常大,所以我不会发布它,但我需要帮助的一件事是输出任何合成数据的邻接矩阵。这就是我所拥有的: function [ beta, adj,results ] = granger( id, t, X, lambda, lag, param ) %G

VAR模型将单变量自回归(AR)模型推广到多重时间序列。我想实现一个向量自回归模型,该模型基于对时间t的观察,概述了以下公式:

x(t)=c+(t-1)∑(i=t+t)*a(i)x(i)+欧元(t)

a(i)=模型参数 欧元(t)=高斯噪声

我使用的数据非常大,所以我不会发布它,但我需要帮助的一件事是输出任何合成数据的邻接矩阵。这就是我所拥有的:

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
函数[beta,adj,results]=granger(id,t,X,lambda,lag,param)
%GRANGER图形GRANGER建模
%INPUTS:id=包含n个元素的列,这些元素是唯一的主题标识符,用于指示
%来自同一受试者的测量结果。
%t=具有n个测量时间元素的列,对应于id。
%注:目前假设数据间隔相等。
%X=对应于id和t的协变量的n乘以-(p+1)矩阵。
%lambda=惩罚条款的tunning参数。
%param=要传递给用户的任何其他参数的结构
%代码。
%滞后=从当前时间向后看的时间滞后值。
%输出:bhat=对应于X的估计效应参数。
%adj=X列之间的邻接矩阵。
%结果=要发送的任何其他结果的结构
%从你的代码。

如果你有计量经济学工具箱,你可以尝试使用它的VAR模型实现,尽管你的(t-1)因子可能是一个问题,(t-1)实际上位于西格玛的顶部,只是不知道如何编写,(i-t+t)位于西格玛的底部。