Re: [R] Markov transition matrices , missing transitions for certain years

From: Chris Stubben <stubben_at_lanl.gov>
Date: Tue, 19 Apr 2011 08:00:14 -0700 (PDT)

To keep the table dimensions the same, try changing the columns to factors...

boxes$y97<-factor(boxes$y97, 1:4)
boxes$y98<-factor(boxes$y98, 1:4)
boxes$y99<-factor(boxes$y99, 1:4)

...

> table(boxes$y98, boxes$y97)
   

    1 2 3 4
  1 1 0 1 0
  2 0 0 0 0
  3 0 0 0 0
  4 1 0 0 1
> table(boxes$y99, boxes$y98)
   

    1 2 3 4
  1 1 0 0 1
  2 0 0 0 0
  3 0 0 0 0
  4 1 0 0 1

Chris

Abby_UNR wrote:
>
> My problem is that there are 16 possible transitions, but not all possible
> transitions occur at each time step. Therefore, don't think I could do
> something easy like create a table for each time step and add them
> together, for example:
>

>> t1.boxes <- table(boxes$y98, boxes$y97)
>> t1.boxes

>
> 1 3 4
> 1 1 1 0
> 4 1 0 1
>> t2.boxes <- table(boxes$y99, boxes$y98)
>> t2.boxes

>
> 1 4
> 1 1 1
> 4 1 1
>> 

>
>
--
View this message in context: http://r.789695.n4.nabble.com/Markov-transition-matrices-missing-transitions-for-certain-years-tp3459072p3460651.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
R-help_at_r-project.org mailing list
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.
Received on Tue 19 Apr 2011 - 18:05:10 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 20 Apr 2011 - 09:20:31 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive