Christian Schulz
2003-Sep-18 12:04 UTC
[R] 2 time dependend states and probability transition matrix
Hi, have got anybody experience or a starting point for me, how i can program a function which calculate me a probability transition matrix with a data.frame and two states. I have some independend variable and a class variable for two states - in example one from Jan2003 and the same variables from June2003. Now i would like to calculate the probability that PERSON X change from classA to classB between this time-period dependend from the independend variables. Until now i think about an "easy" function what use the Bayes-Theorem, but it's too bad that i'm not a mathematican. Thanks for any starting point, idea, link or paper! P.S. I now the msm package, but think it's complex for my intention!? Regards,Christian [[alternative HTML version deleted]]
Spencer Graves
2003-Sep-18 14:25 UTC
[R] 2 time dependend states and probability transition matrix
I don't know if I understand what you want, but I wonder if the following might help: > Ptrans <- data.frame(Jan=LETTERS[rep(1:2, 5)], + June=LETTERS[rep(1:2, each=5)]) > (table(Ptrans$Jan, Ptrans$June)/dim(Ptrans)[1]) A B A 0.3 0.2 B 0.2 0.3 hope this helps. spencer graves Christian Schulz wrote:>Hi, > >have got anybody experience or a starting >point for me, how i can program a function >which calculate me a probability transition matrix with a data.frame and two states. > >I have some independend variable and a class variable >for two states - in example one from Jan2003 and the same variables from June2003. > >Now i would like to calculate the probability that PERSON X change >from classA to classB between this time-period dependend from >the independend variables. > >Until now i think about an "easy" function what use the Bayes-Theorem, but it's too bad that i'm >not a mathematican. > >Thanks for any starting point, idea, link or paper! > >P.S. >I now the msm package, but think it's complex for my intention!? > > >Regards,Christian > > > > [[alternative HTML version deleted]] > >______________________________________________ >R-help at stat.math.ethz.ch mailing list >https://www.stat.math.ethz.ch/mailman/listinfo/r-help > >