'CTMC problem: How to calculate mean MLE, bias, mean SE, SE and CI for a Continuous Time Markov Chain simulation dataset in R?
Given a 3-state CTMC, I would like to generate 1000 datasets and record all their transitions and transition times on the time duration [0,100] for a 3-state continuous-time Markov chain with transition rate matrix and find the MLE for all parameters and their mean, SE, SD and bias of the MLEs and CI for each parameter. I'm using the MSM package in R, I'm not sure if the first-step is correct. And What to do next to find the mean, SE,etc.? Thank you!
Here's the code:
qmatrix<-rbind(c( -1.55,0.5,0.7),c(1.0,-2.5,0.8),c(0.55,2.0,-1.5 ))
sim.msm(qmatrix, maxtime=100, covs=NULL, beta=NULL, obstimes=0, start=1, mintime=0)
Here's the output:
$states
[1] 1 2 3 2 3 2 1 3 2 1 3 2 1 2 3 1 2 3 2 1 2 1 2 3 2 1 3 2 1 3 2 1 3 2 3 2 1 3 2 1 3 2 3 2 1 3 1 3 2 1 3 2 1 3 2 3 2
[58] 3 2 3 2 3 2 3 1 3 2 1 2 3 2 3 1 2 3 2 1 3 2 1 3 2 1 3 1 2 1 2 1 3 2 1 2 3 2 1 2 1 3 2 3 1 2 1 2 3 2 1 3 1 3 1 3 2
[115] 3 2 1 3 1 3 1 2 1 2 1 2 3 1 3 2 3 2 1 3 1 3 2 1 2 3 2 1 3 2 3 2 3 1 3 2 1 3 2 1 3 2 3 1 2 1 2 3 1 3 2 1 2 3 1 3 2
[172] 1 2 1 2 3 2 3 2 1 2 1 3 2 3 2 3 2 3 2 1 2 3 2 1 3 2 1 1
$times
[1] 0.000000 1.337596 1.362191 1.476702 1.555734 1.861048 1.872354 2.028488 2.424991 2.656919
[11] 3.442822 3.536488 3.748460 5.456584 5.613555 5.660168 5.867178 6.011677 6.085615 6.141217
[21] 7.500027 7.831883 8.741804 9.022980 9.075131 10.008952 10.587310 10.724296 11.720231 11.773875
[31] 11.975656 12.256983 12.472417 12.783526 12.848953 12.953589 14.743587 15.832113 15.874583 16.017451
[41] 16.461453 16.731139 16.874843 17.035627 17.597629 19.856766 19.872131 20.431187 20.702377 21.098359
[51] 21.137319 21.365903 22.790554 23.148535 23.442444 24.257172 24.621436 24.831465 26.093660 26.308910
[61] 27.453272 27.582364 27.698166 27.937213 27.940383 28.397250 28.721288 28.729847 28.830485 30.165057
[71] 30.321897 30.447654 30.452361 30.777617 31.018373 32.301805 32.993770 33.191359 33.729895 33.871943
[81] 34.119537 34.194971 34.253327 35.725821 35.884895 36.925904 38.274757 39.107009 39.277357 40.227662
[91] 40.609264 40.901967 42.510962 43.171889 43.605517 44.313961 44.541594 45.683055 46.879402 46.905675
[101] 47.481479 48.257792 48.544124 48.971349 49.013105 50.707812 51.074451 52.061199 52.154260 52.612230
[111] 53.565019 53.728064 54.495656 54.786598 54.873416 54.988014 55.234529 55.423862 57.328118 57.928870
[121] 57.960640 59.943583 59.961192 60.841125 61.443912 62.087233 62.219001 62.265142 62.461134 62.830230
[131] 62.984355 63.351908 63.423539 63.728888 64.180341 64.459818 64.909733 65.034425 66.138596 66.606237
[141] 67.459424 67.593525 67.802345 68.291826 68.787457 68.811446 69.303668 69.435817 70.666894 70.754037
[151] 70.858464 71.311939 71.769933 74.052097 75.697696 76.148180 76.389240 77.002067 77.510761 77.748987
[161] 78.974831 79.153566 79.814880 79.959816 80.409660 80.762432 84.893508 85.828107 86.498693 87.739144
[171] 87.963883 87.989974 88.628014 89.716151 90.027518 90.383951 90.439742 90.730203 90.772182 90.906435
[181] 91.088374 91.281104 91.716445 91.885433 92.063158 92.063926 93.110963 94.336095 95.043027 95.661818
[191] 96.170785 98.203715 98.548922 98.566083 98.910060 99.289348 99.358420 99.579823 100.000000
$qmatrix
[,1] [,2] [,3]
[1,] -1.55 0.5 0.7
[2,] 1.00 -2.5 0.8
[3,] 0.55 2.0 -1.5
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
