function y = theta2pars(theta)
% convert theta to parameters including
% kinfQ, dlamQ, a, p, sigtau2, Sigma, lamQ, Phi, sige2

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];
theta = theta./pars_scale;
pars.Phi = reshape(theta(1:9),3,3);
dlamQ = -exp(theta(10:12))./(1 + exp(theta(10:12)));
lamQ = 1 + cumsum(dlamQ) ;
pars.lamQ = lamQ;
pars.dlamQ = dlamQ;
sigma = [theta(13) 0 0 ; theta(14) theta(16) 0; theta(15) theta(17) theta(18)]; 
pars.omega = sigma*sigma'; 
pars.kinfQ = theta(19);
pars.sigtau2 = exp(theta(25));
pars.a = theta(21:22);
pars.p = theta(23:24);
pars.gamma = [1-sum(pars.a); pars.a];
pars.Xbar = [-sum(pars.p); pars.p];
pars.sige2 = exp(theta(20));
pars.Sigma_tilde = pars.omega - (pars.gamma * pars.gamma')*pars.sigtau2 ;
y = pars ;

