-
-
Notifications
You must be signed in to change notification settings - Fork 309
Open
Description
This is already accomplished on the Python side in QuantEcon/QuantEcon.py#658
An ongoing discussion for the Julia side is here:
- https://discourse.quantecon.org/t/estimate-markovchain-from-data-using-ml/239
- https://discourse.quantecon.org/t/estimating-markov-chain-probabilities-in-julia-using-proportions/981
@msilva913 proposes
function estimate_markov(X::Vector, nstates::Int64)
P = zeros(nstates, nstates)
n = length(X) - 1
for t = 1:n
# add one each count is observed
P[X[t], X[t+1]] = P[X[t], X[t+1]] + 1
end
for i = 1:nstates
# divide by total number of counts
P[i, :] .= P[i, :]/sum(P[i, :])
end
return P
endNote that this will lead to division by zero errors for states that are never visited. The Python code handles this by dropping such states.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels