function y = pars2theta(pars)
% convert parameters to theta

pars_scale = [ones(9,1);  0.1;0.1;0.1;  ones(6,1);  10; 0.1;   1;1;0.1;0.1;  0.1];
phi = reshape(pars.Phi,[],1);
lam = log(-pars.dlamQ./(1+pars.dlamQ)) ; 
ltri = tril(ones(3));
sigma = chol(pars.omega,'lower') ;
sigma = sigma(ltri==1) ;
kinfQ = pars.kinfQ;
sige = log(pars.sige2);
ap = [pars.gamma(2:3) ; pars.Xbar(2:3)];
sigtau = log(pars.sigtau2);

y = [phi; lam; sigma; kinfQ; sige; ap; sigtau].*pars_scale;






