Ana Kolar
2008-Aug-27 16:02 UTC
[R] How to calculate cumulative values for a simple Bernoulli's distribution?
Hi there, I have two questions and believe that there is an extremely easy solution. Being a beginner with R makes thinks a bit more complicated. This is the code: rpois(15,3) n<-15 DATA<-cbind(D,rpois(15,3)) data<-as.data.frame(DATA) colnames(data)<-c("D","X") *# 1. question: is it possible to put the following creation of x in a nicer form?* x<-c(sum(D>0),sum(D>0),sum(D>0),sum(D>0),sum(D>0),sum(D>0),sum(D>0),sum(D>0),sum(D>0),sum(D>0)) p1<-seq(0, 1, 0.1) # Posterior Bernoulli distribution Bn1<-(p1^x*(1-p1)^(n-x))*choose(n,x) bn1<-as.data.frame(Bn1) # Normalized posterior Bernoulli distribution f1<-1/sum(bn1) nbn1<-bn1*f1 nbn1 # Control check that sum is equal to 1 sum(nbn1) *# 2. question: how can I calculate cumulative values for nbn1 distribution? Was looking for the answer on-line but couldn't find anything.* Your help will be greatly appreciated!! Good day to all of you Ana [[alternative HTML version deleted]]