function out = var_dim

% Order of variables in y(t) = [y1(t)' y2(t)' E_t y2(t+1)']'
% non-expectational y1(t) (n1 x 1)

i_ = 1; 

out.y       = i_; i_ = i_ + 1;
out.r_F     = i_; i_ = i_ + 1;  
out.r_star  = i_; i_ = i_ + 1; 
out.r       = i_; i_ = i_ + 1;  
out.l       = i_; i_ = i_ + 1;  
out.nx      = i_; i_ = i_ + 1;  
out.ca      = i_; i_ = i_ + 1;    
out.b_F     = i_; i_ = i_ + 1; 
out.w       = i_; i_ = i_ + 1;
out.kk      = i_; i_ = i_ + 1; 
out.g       = i_; i_ = i_ + 1;
out.b       = i_; i_ = i_ + 1; 
out.tau_c   = i_; i_ = i_ + 1;
out.tau_w   = i_; i_ = i_ + 1; 
out.tr      = i_; i_ = i_ + 1;
out.tax     = i_; i_ = i_ + 1;
out.z       = i_; i_ = i_ + 1;
out.zeta    = i_; i_ = i_ + 1;  
out.zeta_L  = i_; i_ = i_ + 1; 
out.zeta_I  = i_; i_ = i_ + 1; 
out.zeta_b  = i_; i_ = i_ + 1; 
out.vg      = i_; i_ = i_ + 1;  
out.by_star = i_; i_ = i_ + 1; 
out.s       = i_; i_ = i_ + 1;
out.lag1_g  = i_; i_ = i_ + 1;
out.lag1_tau_c  = i_; i_ = i_ + 1;
out.lag1_tau_w  = i_; i_ = i_ + 1;
out.lag1_tau_K  = i_; i_ = i_ + 1;
out.lag1_tr  = i_; i_ = i_ + 1;

% Observables
out.dy_obs      = i_; i_ = i_ + 1; 
out.dinvest_obs = i_; i_ = i_ + 1; 
out.dc_obs      = i_; i_ = i_ + 1; 
out.nx_obs      = i_; i_ = i_ + 1; 
out.dw_obs      = i_; i_ = i_ + 1; 
out.r_obs       = i_; i_ = i_ + 1; 
out.r_star_obs  = i_; i_ = i_ + 1; 
out.gy_obs      = i_; i_ = i_ + 1; 
out.by_obs      = i_; i_ = i_ + 1; 
out.rev_c_y_obs = i_; i_ = i_ + 1; 
out.rev_w_y_obs = i_; i_ = i_ + 1; 
out.rev_K_y_obs = i_; 

n1 = i_ ;  i_ = i_ + 1;

% expectational y2(t) (n2 x 1)
out.invest = i_; i_ = i_ + 1;  
out.lambda = i_; i_ = i_ + 1;
out.c      = i_; i_ = i_ + 1;  
out.phi    = i_; i_ = i_ + 1;  
out.tau_K  = i_; i_ = i_ + 1;
out.r_K    = i_; i_ = i_ + 1;    
out.p_b    = i_;

n2 = i_ - n1; i_ = i_ + 1;

out.E_invest = i_; i_ = i_ + 1; 
out.E_lambda = i_; i_ = i_ + 1;
out.E_c      = i_; i_ = i_ + 1;
out.E_phi    = i_; i_ = i_ + 1;
out.E_tau_K  = i_; i_ = i_ + 1;
out.E_r_K    = i_; i_ = i_ + 1;    
out.E_p_b    = i_;

% Shocks
j_ = 1; 
out.shock.ez     =  j_ ;  j_ = j_ + 1; 
out.shock.erstar =  j_ ;  j_ = j_ + 1;
out.shock.ezeta  =  j_ ;  j_ = j_ + 1;
out.shock.eL     =  j_ ;  j_ = j_ + 1;
out.shock.eI     =  j_ ;  j_ = j_ + 1;
out.shock.eb     =  j_ ;  j_ = j_ + 1;
out.shock.eg     =  j_ ;  j_ = j_ + 1; 
out.shock.ectau  =  j_ ;  j_ = j_ + 1;
out.shock.ewtau  =  j_ ;  j_ = j_ + 1;
out.shock.eKtau  =  j_ ;  j_ = j_ + 1;
out.shock.etau   =  j_ ;   

ns = j_ ;   % number of shocks

% Dimenstions to save

s     = 1;           % number of leads
k     = n2*s;        % dimension of expectations revisions
n     = n1 + n2 + k; % dimension of Sims matrices

const = n1 + n2 + 1;
n_    = n1 + n2 ;    % dimension of KP matrices

out.dim.n1       = n1 ; 
out.dim.n2       = n2 ; 
out.dim.k        = k ; 
out.dim.n        = n ; 
out.dim.n_       = n_ ; 
out.dim.const    = const ;
out.dim.ns       = ns ; 