% Calibrated parameter values

clear;
beta=0.99;
sigma=1;
chi=1.55;
eta=0;
theta=2.064;
omega=0.5;
alpha=3;
delta=1.5;
rho=0.5;

% Calculate kappa 

kappa=(1-omega)*(1-beta*omega)/(alpha*omega);

% Define state space matrices

A0=zeros(3,3);
A0(1,1)=1;
A0(2,2)=1;
A0(2,3)=sigma^-1;
A0(3,3)=beta;

A1=zeros(3,3);
A1(1,1)=rho;
A1(2,1)=sigma^-1;
A1(2,2)=1;
A1(2,3)=sigma^-1*delta;
A1(3,2)=-kappa;
A1(3,3)=1;

B0=zeros(3,1);
B0(1,1)=1;

% Calculate alternative state space matrices

A=inv(A0)*A1;
B=inv(A0)*B0;

% Jordan decomposition of A

[p,lambda] = eig(A);
pstar = inv(p);

% Sort eigenvalues and eigenvectors in ascending order

val=diag(lambda);
t=sortrows([val p'],1);
lambda=diag(t(:,1));
p=t(:,2:4)';
pstar=inv(p);