function  param_save(rhoQE,thetapi,thetax,phipi,phix)

z= 0.33; % Targeted share of impatient types
Pis = 1; %% SS Trend inflation
betta=0.995; % Discount factor for Parent
Rss = Pis/betta; % SS short rate (2% at an annualized frequency)
Rres= Rss; % SS rate on reserves
sp = 2/400; % Targeted spread (2% annually)
Rbs = sp + Rss; %% SS long rate
bettab=1/Rbs                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     ; % Discount factor for Child
epsip=11; % ss markup 10 percent
pms = (epsip-1)/epsip;  %% SS markup
ws = pms; %% SS wage

Ls =1; % targeted SS total labor
Lps = Ls; % targeted SS labor for parent
Lbs = Ls; % targeted SS labor for child


phip=0.75; %% Calvo price
pstars= (( 1-phip*Pis^(epsip-1))/(1-phip))^(1/(1-epsip)); %% SS reset price
vps = (1-phip)*pstars^(-epsip)/(1-phip*Pis^(epsip)) ; %% SS price dispersion
Ys = Ls/vps; % SS output




Cbs =  z*Ys; % SS consumption impatient
Cps =  (1-z)*Ys; % SS counsumption patient
sigm=1; % EIS
chi=1; % inverse Frisch elasticity
psi = ws * Lps^(-chi)*Cps^(-sigm); % Labor disutility scaling parameter (target Lp= (1-z)*L)
psib = ws * Lbs^(-chi)*Cbs^(-sigm); % Labor disutiltiy scaling parameter for child (target Lb=(1-z)*L)

r = 0.1; % SS reserve/output ratio
res=r * Ys; % SS reserves
Omegas= betta* (Rbs-Rss);
kappa = 1-1/40; % ten year duration of the long bond
Qs = (Rbs-kappa)^(-1); %% SS long bond price
b1 = 0.7; % SS ratio of FI bond to total holdings
b2 = 0.3; % SS ratio of CB bond to total holdings
bCBs = res / Qs; % SS CB bond holdings 
bs = bCBs / b2; %% SS Total bond holdings
bFIs = bs - bCBs; %% SS FI bond holdings
QEs= Qs * bCBs; % CB's balance sheet size 10% of output

Thetas = 5; % ss target of the risk-weighted leverage ratio
bar_XFIs = Qs * bFIs/Thetas; % Fixed equity of FI (0.0467) 
XFIs = bar_XFIs + kappa*Qs*bFIs; % Transfer to FI

% Xbs = (Rbs* Qs*Pis^(-1)*bs); % Transfer to Children
Xbs = Cbs - Qs*bs - ws*Ls*z + Rbs*Qs*bs;

ss= Qs*bFIs*(1-kappa*Pis^(-1)) + res - bar_XFIs; %% SS deposits/savingQEs= Qs * bCBs; % CB's balance sheet size 10% of output

% Checks
Ds = Ys - ws*Lps; % Production dividends
DFIs = Rbs*Qs*bFIs + Rres*res - Rss*ss; % FI dividends
Ts = - Rbs*Qs*bCBs + Rres*res; % Lump-sum transfer (should be negative bc it is a transfer)


% Taylor rule
rhoR = 0.6;
phipi = phipi;
phix = phix;

% QE rule
rhoQE=rhoQE;
thetapi = thetapi;
thetax= thetax;
%sq= 0.01* (Ys / res); % have to check: normalize shocks so that reserves increase by an amount equivalent to one percent of output on impact


% Shock process
rhoT=0.8;
rhoA=0.8;
sa=0.01;
st=0.01;
sq=0.01;
sr=1/400;

% save parameters
gamma = (1-phip)*(1-phip*betta)/phip; % Elasticity of inflation wrt real marginal cost (NKPC slope)
zeta = (chi*(1-z)+sigm)/(1-z); % Elasticity of real marginal cost wrt output gap (NKPC slope)



save param_work_ZLB  sigm chi Ls Lps Lbs Ys Cps Cbs z betta bettab Rss Rres Rbs sp kappa Qs QEs bs bCBs bFIs b1 b2 ...
                        Thetas XFIs bar_XFIs Xbs Omegas res ss ...
                        epsip Pis vps pstars phip pms ws psi psib ...
                        rhoR phipi phix sr rhoQE  rhoT rhoA thetapi thetax sq sa st Ds DFIs Ts
