function fv=decomp_var(data,L)
y=data;
N=cols(data);
x=[];
for j=1:L
    x=[x lagmatrix(data,j)];
end
x=[x ones(rows(y),1)];
y=y(L+1:end,:);
x=x(L+1:end,:);
K=cols(x);
T=rows(y);
B=x\y;
E=y-x*B;
S=(E'*E)/(T-K);
A0=chol(S);
H=100;
mse=0;
for j=1:N
    shock=zeros(1,N);
    shock(j)=1;
    imp=irfsimx(B,N,L,A0,shock,H,1);
    mse=mse+cumsum(imp.^2);
end
shock=zeros(1,N);
 shock(1)=1;
    imp=irfsimx(B,N,L,A0,shock,H,1);
    fv=cumsum(imp.^2)./mse;