There are two functions: (1) simCTMC.m is used to simulate jump times and the corresponding states that are jumped to, given a Q-matrix and a desired number of periods. (2) simCTMC_t.m uses the output of simCTMC.m to generate a time series simulation for the states.
Dana (2021). Simulate Continuous-Time Markov Chains (https://www.mathworks.com/matlabcentral/fileexchange/79649-simulate-continuous-time-markov-chains), MATLAB Central File Exchange. Retrieved .
zk chen, could you elaborate on the errors you encountered?
Here's an example you can run:
Q = [-0.08 0.04 0.04; 0.01 -0.05 0.04; 0.01 0.01 -0.02]; % Q matrix
nsim = 3; % number of parallel simulations to run
T = 50; % length of simulation
[jmptout,sttout] = simCTMC(Q,T,nsim); % get jump times and states after each jump
tvc = linspace(0,T,100)'; % dates at which to determine state in simulation
stt_time = simCTMC_t(tvc,jmptout,sttout); % simulations
plot(stt_time') % plot the three simulations on the same axis
I could not use it due to there exist some errors. Would you please make a example to perform simCTMC?
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!