Discretize AR(1) by Tauchen

Hello,

I try to discretize this AR(1) process: y_t = \rho y_{t-1} + \epsilon_t
where \rho=0.8014, \epsilon_t \sim N (0, 0.1849)

I use Matlab, and my friend uses Python, and we got different result. I don’t know where did I get wrong. I post here both Python and Matlab code.

If anyone discover something wrong, plz kindly let me know. I am really appreciate!

  • With Python: self.mc = qe.markov.tauchen(0.8014,0.43, 2.5, 5)

  • With matlab:
    N = 5
    rho = 0.8014
    sigma=sqrt(0.1849)
    m=2.5
    [Z,Zprob]=tauchen(N,rho,sigma,m)

function [Z,Zprob]= tauchen(N,rho,sigma,m)
Z = zeros(N,1); %column vector of state values in state space, N states
Zprob = zeros(N,N); %transition matrix
Z(N)=2.5sqrt(sigma^2/(1-rho^2));
Z(1)=-Z(N);
zstep=(Z(N)-Z(1))/(N-1);
for i=2:N-1
Z(i)=Z(1)+zstep
(i-1);
end

Assuming * is in between 2.5 and sqrt and the line in Matlab for loop is Z(i)=Z(1)+zstep*(i-1);, I can get the same state values.

Can you try it again?

Hi @Shunsuke-Hori,

Oh I checked again, you are right. They are actually the same…

Thanks a lot!