[R] Problem with plotmat package

H @gent@ @end|ng |rom medd@t@|nc@com
Fri Sep 17 02:50:20 CEST 2021


On 09/15/2021 09:40 PM, Jim Lemon wrote:
> Oops, your plot
>
> On Thu, Sep 16, 2021 at 11:39 AM Jim Lemon <drjimlemon using gmail.com> wrote:
>> Hi H,
>> Looking at your example and the help page, it looks to me as though
>> the plot is consistent with the "A" matrix:
>>
>>  Oz
>>     Rain Nice
>> Rain 0.25 0.75
>> Nice 0.60 0.40
>>
>> # help page
>> A  - square coefficient matrix, specifying the links (rows=to, cols=from).
>>
>> In your plot (attached):
>> Rain (col) goes to Rain (row) 0.25
>> Rain (col) goes to Nice (row) 0.6
>> Nice (col) goes to Nice (row) 0.4
>> Nice (col) goes to Rain (row) 0.75
>>
>> This is a bit confusing, but it seems to do what it says it does.
>>
>> Jim
>>
>> On Thu, Sep 16, 2021 at 10:40 AM H <agents using meddatainc.com> wrote:
>>> I am using plotmat 1.6.5 (part of the diagram package) in R 3.6 to plot Markov transition charts but have run into an issue that I was hoping someone could shed light on here. I did e-mail the maintainer over a month ago but have not received a reply.
>>>
>>> The issue is that the directional arrows point in the wrong direction. A brief example:
>>>
>>> stateNames <- c("Rain", "Nice")
>>> Oz <- matrix(c(0.25, 0.75, 0.6, 0.4), nrow = 2, byrow = TRUE)
>>> rownames(Oz) <- stateNames; colnames(Oz) <- stateNames
>>> plotmat(Oz, pos = c(1, 1), lwd = 1, box.lwd = 2, cex.txt = 0.8, box.size = 0.1, box.type = "circle", box.prop = 0.5, box.col = "light yellow", arr.length = 0.2, arr.width = 0.2, self.cex = 0.4, self.shifty = 0.01, self.shiftx = 0.13, main = "")
>>>
>>> In the above example both arrows seem to point in the direction opposite to what I expect. Has anyone encountered this and know how to fix it?
>>>
>>> Thanks.
>>>
>>> ______________________________________________
>>> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>>> and provide commented, minimal, self-contained, reproducible code.

I am sorry but I think you have it wrong. A transition probability matrix for the rain/nice scenario would be written:

Rain, Nice

Rain |0.25, 0.75|

Nice |0.60, 0.40|

If you sum the transition probabilities for rain or nice, they should each add to 1. Logic dictates if the only two states are rain and nice, and rain continues the next day with a probability of 0.25, nice must have a probability of 0.75. Likewise, the sum of probabilities for nice weather to change to rain, 0.6, and remain the same, 0.4 must add up to 1.

I find that the arrow directions are the opposite of what I expect.



More information about the R-help mailing list