Re: [R] Proba( Ut+2=1 / ((Ut+1==1) && (Ut==1))) ?

From: Dimitris Rizopoulos <dimitris.rizopoulos_at_med.kuleuven.ac.be>
Date: Tue 26 Apr 2005 - 02:22:37 EST

maybe something like this:

x <- sample(c(1, -1), 100, TRUE)
y <- rle(x)
##
ind1 <- y$length[y$value == 1]
sum(ind1[ind1 > 2] - 2)
ind2 <- y$length[y$value == -1]
##
sum(ind1[ind1 > 2] - 2)

could be helpful.

Best,
Dimitris



Dimitris Rizopoulos
Ph.D. Student
Biostatistical Centre
School of Public Health
Catholic University of Leuven

Address: Kapucijnenvoer 35, Leuven, Belgium

Tel: +32/16/336899
Fax: +32/16/337015
Web: http://www.med.kuleuven.ac.be/biostat/
     http://www.student.kuleuven.ac.be/~m0390867/dimitris.htm


> Dear all,
>
> First I apologize if my question is quite simple,
> but i'm very newbie with R.
>
> I have vectors of the form v = c(1,1,-1,-1,-1,1,1,1,1,-1,1)
> (longer than this one of course).
> The elements are only +1 or -1.
>
> I would like to calculate :
> - the frequencies of -1 occurences after 2 consecutives -1
> - the frequencies of +1 occurences after 2 consecutives +1
>
> It looks probably something like :
> Proba( Ut+2=1 / ((Ut+1==1) && (Ut==1)))
>
> could someone please give me a little hint about how
> i should/could begin to proceed ?
>
> Thanks
> (Thanks also to the R creators/contributors, this soft
> seems really great !)
>
> ______________________________________________
> 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
>



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 Tue Apr 26 02:25:15 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:31:25 EST