I finally managed to use tauchen function. However, the type of outcome is Discrete Markov Chain stochastic matrix of type Array{Float64,2}:
I tried to multiply a scalar, a vector, or any kind of algebra on it, but Julia returns
MethodError: no method matching length(::MarkovChain{Float64,Array{Float64,2},StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}}})
Is there any way that I can convert the outcome of tauchen as a normal matrix so that I can do some multiplication?
It would be helpful if you posted the code that you tried. i.e. post working code that generates your matrix, along with the code that you tried to use to multiply it by a vector.
ρ= 0.004 # persistence of the shock
σ= 0.0165 # Volatility of the innovation
μ= 0 # Average of the process
N= 5 # Number of points in the grid of shocks
n_std= 3 # number of std deviations away from the mean
shock = tauchen(N,ρ,σ,μ,n_std) # If Tauchen's (1986) method is chosen
shock .+ 2
shock + 2
shock .*2
None of them work and it returns :
MethodError: no method matching length(::MarkovChain{Float64,Array{Float64,2},StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}}})
Closest candidates are:
length(!Matched::DataStructures.EnumerateAll) at C:\Users\1\.julia\packages\DataStructures\TX3PX\src\multi_dict.jl:103
length(!Matched::Plots.GridLayout) at C:\Users\1\.julia\packages\Plots\5srrj\src\layouts.jl:289
length(!Matched::Cmd) at process.jl:638
This code is not runnable unless you specify where you got the tauchen function from. Is it a package? (There is no using statement in the code you quoted.)
Also, you did’t quote the whole error message; what is the backtrace?
thank you so much!!! now it works.
Just one more stupid question. Could you tell me if there are operations like as.matrix() or as.data.frame() in R ??