[R] MSM package and qmatrix
Peter Adamson
peter.adamson at egu.york.ac.uk
Mon Aug 24 17:13:59 CEST 2009
Hi Ross,
For an eleven state model you could define transitions as follows:
transitions_allowed <- matrix(c(
0,1,1,1,1,1,1,1,1,1,1,
1,0,1,1,1,1,1,1,1,1,1,
1,1,0,1,1,1,1,1,1,1,1,
1,1,1,0,1,1,1,1,1,1,1,
1,1,1,1,0,1,1,1,1,1,1,
1,1,1,1,1,0,1,1,1,1,1,
1,1,1,1,1,1,0,1,1,1,1,
1,1,1,1,1,1,1,0,1,1,1,
1,1,1,1,1,1,1,1,0,1,1,
1,1,1,1,1,1,1,1,1,0,1,
1,1,1,1,1,1,1,1,1,1,0
), nrow=11, ncol=11,
byrow=TRUE,
dimnames=list(from=1:11,to=1:11))
In your case - I think you may be getting the error message as you have 23
200 201 203 999 as states and not 1 2 3 4 5 6 7 8 9 10. Try recoding 23 200
201 203 999 to 6 7 8 9 10?
HTH, Peter
Ross Culloch wrote:
>
> Hi R-helpers,
>
> I am having a problem understanding how to construct the qmatrix, i have
> read the help menu for msm but I am still a bit lost. Below is an example
> of one of my transition matrices:
>
> statetable.msm(BEH, ID, data = A1)
>
> to
> from 1 2 3 4 5 23 200 201 203 999
> 1 86 11 2 20 1 9 3 11 1 22
> 2 18 4 4 4 0 1 1 1 0 1
> 3 5 2 0 5 0 0 2 0 0 3
> 4 17 5 5 13 0 4 3 3 0 7
> 5 1 0 1 1 0 0 0 0 0 0
> 23 7 3 0 4 0 3 1 3 0 3
> 200 5 0 2 3 1 2 1 3 0 3
> 201 5 5 3 2 1 0 2 6 1 5
> 203 3 0 0 0 0 0 0 0 0 0
> 999 18 4 0 5 0 5 7 3 1 0
>
>
> Instantaneous transition IS allowed from state r to state s. But what i
> don't understand is what is the logical way to create the initial
> transition matrix - i've tried to just give even numbers to all transition
> possibilities e.g. every transition given 0.1 or 1, but i get the
> following error message:
>
> Error in msm.check.state(nrow(qmatrix), state, cens$censor) :
> State vector contains elements not in 1, 2, ... , 10
>
> Does anyone have any suggestions, i can only assume that this is a simple
> problem that i have overlooked because nobody else seems to have asked it!
>
> Any suggestions on how to construct a qmatrix would be much appreciated,
>
> Berst wishes,
>
> Ross
>
--
View this message in context: http://www.nabble.com/MSM-package-and-qmatrix-tp24796485p25117814.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list