Stephen Nyangoma
2012-Jan-19 18:28 UTC
[R] state multi-state modeling using hidden markov routine in the msm package
Hello Chris, I am trying to fit a 4 state multi-state model using hidden markov routine in the msm package. 1. initial parameters: twoway4.q <- rbind(c(0, 0.25, 0, 0.25), c(0.166, 0, 0.166, 0.166), c(0, 0.25, 0, 0.25), c(0, 0, 0, 0)) ematrix <- rbind( c(0, 0.01, 0, 0), c(0.01, 0, 0.01,0), c(0, 0.1, 0, 0), c(0, 0, 0, 0)) 2. the model: msm_covariates_sexandage <- msm(state ~ duration, subject = SerialNo, data = Data, qmatrix = twoway4.q, ematrix = ematrix,death = 4, obstrue = firstobs, covariates = ~ sex + age, method = "BFGS", control = list(reltol = 1e-10, fnscale = 50000, trace=1,REPORT=1)) msm stops after only 100 iterations and fails to compute the Hessian (See the output below). Why is it stopping at 100 only iterations yet i have specified reltol = 1e-10? One additional information is that when i exclude age, the model converges without any problem. I have tried using age groups instead of actual age but no convergence can be achieved. I have also tried subsetting the data in various biologically meaningful groups but there would be no convergence. 3. the R output:> msm_covariates_sex <- msm(state ~ duration, subject = SerialNo,+ data = Data, qmatrix = twoway4.q, ematrix = ematrix,death = 4, obstrue = firstobs, covariates = ~ sex + age, method = "BFGS", control = list(reltol = 1e-10, fnscale = 50000, trace=1,REPORT=1)) initial value 0.567920 iter 2 value 0.547379 iter 3 value 0.463524 iter 4 value 0.439987 iter 5 value 0.426417 iter 6 value 0.420621 iter 7 value 0.417181 iter 8 value 0.414153 iter 9 value 0.410340 iter 10 value 0.406045 iter 11 value 0.403618 iter 12 value 0.403025 iter 13 value 0.402781 iter 14 value 0.402672 iter 15 value 0.402653 iter 16 value 0.402630 iter 17 value 0.402560 iter 18 value 0.402429 iter 19 value 0.402221 iter 20 value 0.402051 iter 21 value 0.401978 iter 22 value 0.401944 iter 23 value 0.401903 iter 24 value 0.401811 iter 25 value 0.401622 iter 26 value 0.401311 iter 27 value 0.400978 iter 28 value 0.400814 iter 29 value 0.400788 iter 30 value 0.400780 iter 31 value 0.400759 iter 32 value 0.400714 iter 33 value 0.400602 iter 34 value 0.400372 iter 35 value 0.400056 iter 36 value 0.399865 iter 37 value 0.399761 iter 38 value 0.399743 iter 39 value 0.399706 iter 40 value 0.399636 iter 41 value 0.399464 iter 42 value 0.399158 iter 43 value 0.398792 iter 44 value 0.398584 iter 45 value 0.398524 iter 46 value 0.398516 iter 47 value 0.398490 iter 48 value 0.398478 iter 49 value 0.398443 iter 50 value 0.398400 iter 51 value 0.398308 iter 52 value 0.398223 iter 53 value 0.398222 iter 54 value 0.398192 iter 55 value 0.398190 iter 56 value 0.398164 iter 57 value 0.398163 iter 58 value 0.398162 iter 59 value 0.398159 iter 60 value 0.398151 iter 61 value 0.398136 iter 62 value 0.398115 iter 63 value 0.398099 iter 64 value 0.398093 iter 65 value 0.398092 iter 66 value 0.398091 iter 67 value 0.398089 iter 68 value 0.398082 iter 69 value 0.398066 iter 70 value 0.398033 iter 71 value 0.397984 iter 72 value 0.397950 iter 73 value 0.397936 iter 74 value 0.397934 iter 75 value 0.397933 iter 76 value 0.397927 iter 77 value 0.397919 iter 78 value 0.397906 iter 79 value 0.397897 iter 80 value 0.397894 iter 81 value 0.397894 iter 82 value 0.397893 iter 83 value 0.397891 iter 84 value 0.397887 iter 85 value 0.397877 iter 86 value 0.397855 iter 87 value 0.397818 iter 88 value 0.397772 iter 89 value 0.397731 iter 90 value 0.397715 iter 91 value 0.397710 iter 92 value 0.397706 iter 93 value 0.397701 iter 94 value 0.397697 iter 95 value 0.397689 iter 96 value 0.397668 iter 97 value 0.397645 iter 98 value 0.397628 iter 99 value 0.397611 iter 100 value 0.397597 final value 0.397597 stopped after 100 iterations Warning message: In msm(state ~ duration_in_years, subject = SerialNo, data = type1Data, : Could not calculate asymptotic standard errors - Hessian is not positive definite. Optimisation has probably not converged to the maximum likelihood>The University of Dundee is a registered Scottish Charity, No: SC015096 [[alternative HTML version deleted]]