Re: [R] generating markov chain

From: Ingmar Visser <I.Visser_at_uva.nl>
Date: Mon 06 Feb 2006 - 22:45:37 EST


Linda,
That depends on what you want to do. There are a number of packages dealing with Markov type models: msm, depmix and hmm.discnp, and then there are all the graphical models packages, some of which can do similar stuff. Hth, ingmar

> From: "linda.s" <samrobertsmith@gmail.com>
> Date: Mon, 6 Feb 2006 03:37:13 -0800
> To: Ingmar Visser <I.Visser@uva.nl>
> Cc: Norman Goodacre <taranpen@yahoo.co.uk>, <r-help@stat.math.ethz.ch>
> Subject: Re: [R] generating markov chain
> 
> On 2/6/06, Ingmar Visser <I.Visser@uva.nl> wrote:

>> You can use the following, with x your transition matrix
>> y=numeric(100)
>> x=matrix(runif(16),4,4)
>> for(i in 2:100) {
>> y[i]=which(rmultinom(1, size = 1, prob = x[y[i-1], ])==1)
>> }
>> hth, ingmar
>>
>> -----Original Message-----
>> From: r-help-bounces@stat.math.ethz.ch
>> [mailto:r-help-bounces@stat.math.ethz.ch]On Behalf Of Norman Goodacre
>> Sent: maandag 6 februari 2006 5:26
>> To: r-help@stat.math.ethz.ch
>> Subject: [R] generating markov chain
>>
>>
>> Dear help group,
>>
>> Just fyi a markov chain is a sequence of transitions between states (say
>> A,T,G,C - on a gene) with a given probability for each transition. In this
>> case there'd be 16 different kinds, each with a different weight.
>> Given a transition matrix (4x4) filled with all transition probabilities
>> of course, how can I generate a random sequence of a given length, say 200?
>>
>> -Norman Goodacre
> Sorry, I am very new to this issue.
> Is there any tutorial to do Markov Chain?
> Thanks,
> Linda.

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Mon Feb 06 23:12:52 2006

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:42:24 EST