Skip to content
Prev 318383 / 398503 Next

cumulative sum by group and under some criteria

HI,
#
Pm2<-rbeta(1000, 0.2+1, 0.8+3) #obs4
?length(Pm2)
#[1] 1000


Pn2<-rbeta(1000, 0.2, 0.8+4)
?length(Pn2)
#[1] 1000
Here, you are creating Pm2 or Pn2 from a single observation.

In the code, it is creating 1000 values in total from the combination of values from x, m, 
?Pm2<-rbeta(1000, 0.2+res2$x, 0.8+res2$m-res2$x)
?length(Pm2)
#[1] 1000

A.K.



----- Original Message -----
From: Zjoanna <Zjoanna2013 at gmail.com>
To: r-help at r-project.org
Cc: 
Sent: Tuesday, February 26, 2013 3:13 PM
Subject: Re: [R] cumulative sum by group and under some criteria

Hi Arun

I noticed that the values of Fmm, Fnn, and other corresponding variables
are not correct, for example,? for the 4th obs after you run this code, the
Fmm is 0.40,? but if you use the x, m, y, n in the 4th row to calculate
them, the results are not consistent, same for the 5th obs.

#check
#
Pm2<-rbeta(1000, 0.2+1, 0.8+3) #obs4
Pn2<-rbeta(1000, 0.2, 0.8+4)
Fm2<- ecdf(Pm2)
Fn2<- ecdf(Pn2)
Fmm2<-Fm2(1/4)
Fnn2<-Fn2(0)
Fmm2? #0.582
Fnn2?  #0


Pm2<-rbeta(1000, 0.2+1, 0.8+3) #obs5
Pn2<-rbeta(1000, 0.2+1, 0.8+3)
Fm2<- ecdf(Pm2)
Fn2<- ecdf(Pn2)
Fmm2<-Fm2(1/4)
Fnn2<-Fn2(1/4)
Fmm2 #0.404
Fnn2? #0.416



On Sat, Feb 23, 2013 at 10:53 PM, arun kirshna [via R] <
ml-node+s789695n4659514h45 at n4.nabble.com> wrote:

            
--
View this message in context: http://r.789695.n4.nabble.com/cumulative-sum-by-group-and-under-some-criteria-tp4657074p4659717.html
Sent from the R help mailing list archive at Nabble.com.
??? [[alternative HTML version deleted]]

______________________________________________
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.