            burn   = 50;  %  use the first burn observations for estimation, then forecast between burn+1 and obs
            count_sim = count_sim+1;
            sim_id = ['m=',num2str(m),' ','hlow=',num2str(hlow),' ','obs=',num2str(obs)];
            disp(sim_id)
            disp([num2str(count_sim),' out of ',num2str(tot_sim)]);
            
            ncoefs = (m)^2+m; % these are the m^2 coefficients in the matrix P and the m in the matrix L
            gamma_mean = ones(m,1);
            % phi_grid_KK        = phi_grid_kernel;
            
            NN_VAR        = m;% # di variabili di cui tenere conto nella previsione
            
            %% PRIOR MEAN AND VARIANCES: DATA ARE STANDARDIZED, SO THE PRIORS CAN BE DEFINED OUTSIDE
            % PRIOR MEAN AND VARIANCES FOR KERNEL BASED ESTIMATOR
            if const==0
                d1   =  diag(gamma_mean);
            else
                d1   = [diag(gamma_mean);zeros(m*(lags-1)+1,m)];
            end
            %% compute matrices for VAR estimation that are constant for all models
            sigmas=ones(1,m); % Data are standardized, so no need for rescaling here
            if const==0
                Omega=kron(diag(1:lags),diag(sigmas));
            else
                Omega=[kron(diag(1:lags),diag(sigmas)) zeros(m*lags,1);        zeros(1,m*lags+1)];
                Omega(end,end)=1/(1e+20);%//very lose prior on the constant like banbura et al.
            end
            OmegaprimeOmega = Omega'*Omega;
            
            %% PRIOR MEAN AND VARIANCES FOR BAYESIAN VAR
            K        = size(d1(:),1);% dimension of the state vector
            %% SIMPLIFY CODE FOR 1 LAG VAR...
            for ll=1:length(phi_grid_KK)
                phi     = phi_grid_KK(ll).^2; %take square because in the kernel VAR you have standard deviations
                if const==0
                    V_i{ll} = eye(m^2,m^2)*phi;
                else
                    temp = [ones(m,m)*phi;ones(1,m)*1000];
                    V_i{ll} = diag(temp(:));
                end
            end
            
