function beta=drawvarnewx_2(Y0,X0,sigmain,N,L,EX)

%conditional mean of the VAR coefficients
  mstar=vec(X0\Y0);  %ols on the appended data
  xx=X0'*X0;
  ixx=invpd(xx);  %inv(X0'X0) to be used later in the Gibbs sampling algorithm

      vstar=kron(sigmain,ixx);
cvstar=cholx(vstar); 
beta=mstar+(randn(1,N*(N*L+EX))*cvstar)';

   
 