search for: rbeta

Displaying 20 results from an estimated 103 matches for "rbeta".

Did you mean: beta
2012 Aug 27
3
How to generate a matrix of Beta or Binomial distribution
...ce random numbers from Beta and Binomial distributions. For Beta distribution, suppose we have two shape vectors shape1 and shape2. I hope to generate a 10000 x 2 matrix X whose i th rwo is a sample from reta(2,shape1[i]mshape2[i]). Of course this can be done via loops: for(i in 1:10000) { X[i,]=rbeta(2,shape1[i],shape2[i]) } However, the above code is time consuming. It would be better to directly generate X without any loops. I tried the following code X<- rbeta(2,shape1,shape2) but it looks not right. So I was wondering if there is an R code doing this. For Binomial distribution, I hav...
2012 Dec 06
1
Anomalous outputs from rbeta when using two different random number seeds
...it behaves very differently, with a much wider distribution of differences between the two distributions. # Beta parameters #distribution 1 u1.a <- 285.14 u1.b <- 190.09 # distribution 2 u2.a <- 223.79 u2.b <- 189.11 #Good example: output is as expected set.seed(80); u1.good <- rbeta(1000, u1.a, u1.b) set.seed(80); u2.good <- rbeta(1000, u2.a, u2.b) #Bad example: output is different to expected set.seed(20); u1.bad <- rbeta(1000, u1.a, u1.b) set.seed(20); u2.bad <- rbeta(1000, u2.a, u2.b) # plot of distributions using set.seed(80), which behaves as expected plot(u2...
1999 Jul 21
1
R 0.64.2 for Windows 95/NT
...installed in "r0642" (by setting c:\rtmp for source directory and c:\ for install directory). After the installation was completed the main program was in r0642 whereas all the documentation in c:\rtmp\r0642. Is this a known bug? Furthermore if I set the install directory to be c:\rbeta instead of c:\ (in the hope that the distribution will be installed in c:\rbeta and not c:\r0642) I end up with the files in c:\rbeta\r0642. E. S. Venkatraman -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~ho...
2011 Apr 07
2
Two functions as parametrs of a function.
...force(fun1) force(fun2) force(n) p1<-unlist(par1) p2<-unlist(par2) force(p1) force(p2) localfun1 <- function() fun1(n, p1) localfun2 <- function() fun2(n, p2) vp<-replicate(nsim,t.test(localfun1(), localfun2())$p.value) return(vp) } f2(fun1=rbeta,par1=list(shape1=2,shape2=2),fun2=rbeta,par2=list(shape1=1,shape2=2)) Thank you for your help. Kenneth
2003 Jul 04
1
Problem with fitdistr for beta
I have the following problem: I have a vector x of data (0<x<=1 ) with a U-shaped histogram and try to fit a beta distribution using fitdistr. In fact, hist(rbeta(100,0.1,0.1)) looks a lot like my data. The equivalent to the example in the manual sometimes work: > a <- rbeta(100,0.1,0.1) > fitdistr(x=a, "beta", start=list(shape1=0.1,shape2=0.1))1) > shape1 shape2 0.09444627 0.12048753 (0.01120670) (0.01550129) but som...
2008 Sep 17
3
Is there a way to not use an explicit loop?
...se each draw to generate a beta distribution. So, like using a beta prior, binomial likelihood, and obtain beta posterior, m many times. I have not found out a way to vectorize draws from a beta distribution, so I have an explicit for loop within my code for( i in 1: m ) { beta.post = rbeta( 10000, draw1[i] + prior.constant , prior.constant + size.a - draw1[i] ) beta.post.mean[i] = mean(beta.post) beta.post.median[i] = median(beta.post) etc.. for other info } Is there a way to vectorize draws from an beta distribution? UC Slug
2011 Mar 20
3
Part of a density plot
Suupose I have y <- rbeta(10000, 2, 5) and I only want to see only the density plot from x = 0 to x = 1 How do I do this? -- Thanks, Jim. [[alternative HTML version deleted]]
2012 Mar 01
2
'break' function in loop
...criteria 2. I guess probably I put the break function under the wrong loop but I cannot fix it. Sorry if the whole script looks quite messy, I will be very appreciate if someone can help me fix this problem or probably give me some advices to write it in a smart way. My attempt: controlall <- rbeta(10000,1.5,6) caseall <- rbeta(10000,1.6,6) results <- NULL results1 <- NULL or <-vector("list",length=10) criteria <- matrix(data=c(1.05,1.15,1.15,1.25),ncol=2,nrow=2) for (k in 1:2) { for (i in 1:1000) { control <- sample(controlall,100) case &...
2011 Oct 01
1
Fitting 3 beta distributions
Hi, I want to fit 3 beta distributions to my data which ranges between 0 and 1. What are the functions that I can easily call and specify that 3 beta distributions should be fitted? I have already looked at normalmixEM and fitdistr but they dont seem to be applicable (normalmixEM is only for fitting normal dist and fitdistr will only fit 1 distribution, not 3). Is that right? Also, my data has 26
2012 Nov 09
1
Counting the numbers of items in vector according to their size
...d to program 10 years ago in C++. I am currently working a project that looks at the distribution of randomly generated beta values. I take 20 random beta values find their sum, repeat 100000 times. Here is my code that it took me 4 hours to get s=numeric(length=100000) for(i in 1:100000){ pop=(rbeta(n=20,shape1=2,shape2=1)) s[i]=sum(pop) } So now I have them all in in vector, I would like to maybe sort or count them to see how many are less than or equal to 10, but am guessing there is a density r function that may be easier then that. -- View this message in context: http://r.789695.n4...
2011 Nov 12
1
Please Help
..., 16, 19, 44, 26, 34, 31, 21, 28, 11, 31, 21, 34, 25, 25,30, 23, 21, 35, 36, 21, 27, 29, 30, 22, 25, 30, 24, 27, 28, 22, 36, 29, 33, 35, 30, 32, 27,26, 25, 27, 23, 21, 39, 33, 24, 21, 19, 34, 32, 28, 27, 28, 23, 20, 24, 29, 21, 22, 31, 28,27, 28, 29, 21, 30, 28, 31, 22, 29, 18)a=c(1:m)*0.1+1.9p<-rbeta(n,a,1)loglik<-numeric(m)for(i in 1:n){p[i]<-rbeta(n,a[i],1)x[i]<-rpois(n,p[i]*30)loglik<-function(x,p)logLik(a=a(i))<-n*log(a)+(log(30)*sum(x))-sum(log(factorial(x)))-30*(sum(p[i]))+sum(x[i]*log(p[i]))+(a[j]-1)*sum(log(p[i]))}But somehow I am not getting the answer please HELPP.S. th...
2002 Jun 17
2
Random Beta variates
I have been trying to use the rbeta() function to generate random beta variates with a particular mean and standard deviaiton for some simulation problems I am working on, however I am unsure of the relationship between the parameters shape1 and shape2 and the mean and standard deviation of the beta distribution. I am guessing that...
2011 Nov 07
3
Correction in error
...urs? gibbs <-function(m,n, theta = 0, lambda = 1){ alpha <- 1.5 beta <- 1.5 gamma <- 1.5 x<- array(0,c(m+1, 3)) x[1,1] <- theta x[1,2] <- lambda x[1,3]<- n for(t in 2:m+1){ x[t,1] <- rbinom(x[t-1,3], 1, x[t-1,1]) x[t,2]<-rbeta(m, x[t-1,1] + alpha, tx[t-1,3] - x[t-1,1] + beta) x[t,3] <- rpois(x[t-1,3] - x[t-1,1],(1 - x[t-1,2])*gamma) } x } gibbs(100, 10) Gyn [[alternative HTML version deleted]]
2013 Mar 10
0
max row
...dbinom(x1,m1, p0L, log=FALSE)* dbinom(y1,n1,p0H, log=FALSE) >>>>}) ? ? ? >>>> >>>>########## add Qm Qn ################################## >>>>set.seed(8) >>>>d1<-do.call(rbind,lapply(seq_len(nrow(d)),function(i){ >>>>Pm<- rbeta(1000,0.2+d[i,"x1"],0.8+d[i,"m1"]-d[i,"x1"]); >>>>Pn<- rbeta(1000,0.2+d[i,"y1"],0.8+d[i,"n1"]-d[i,"y1"]); >>>>Fm<- ecdf(Pm); >>>>Fn<- ecdf(Pn); >>>> >>>>Fmm<- Fm(p1L);...
2005 Jul 27
1
error message running R2WinBUGS
...[i, j], beta[i, j]) alpha[i, j] < - pi[ j]*(1-theta[i])/theta[i] beta[i, j] < -(1-pi[ j])*(1-theta[i])/theta[i] } } for(j in 1 : T ) { pi[ j ] ~dbeta(0.1,0.1)I(0.1,0.9) } for (i in 1:N) { theta[i] ~dbeta(2,10) } } And my R code is as followings: initials1<-list(theta=c(0.2,0.01), pi=rbeta(50, 0.1, 0.1)*0.8+0.1 , p=matrix(rbeta(100, 2, 10)*0.8+0.1,nr=2,nc=50,byrow=TRUE)) inits<-list(initials1 initials1) data<-list(N=2,T=50 ,n=c(100,150),x = structure(.Data = c( 3, 47, 8, 19, 87, 69, 2, 4, 75, 24, 16, 81, 10, 78, 87, 44, 17, 56, 23, 75, 55, 85, 84, 69, 6, 36, 8, 90, 47,...
1997 Apr 10
1
R-beta: R on Windows 3.1
My attempt to get R running in Windows 3.11 didn't go very far. I have read the FAQ and install.tex carefully. What am I missing? Here is the step: 1. From statlib I got rexe.zip (and rbeta.zip, but this one seems for windows 95 only?). 2. On unzipping I got 8 files, including rb1.exe, and a sub- dir win32s, which I copied to windows/system. (There is no setup.exe, which the install program refers to). 3. rb1.exe does not run. (Similar story with rb...
2007 Aug 16
2
(no subject)
hi, i'm new to R and i'm trying to port a quattro pro spreadsheet into R. spreadsheets have optional lower and upper limit parameters on the beta distribution function. i would like to know how to incorporate this with R's pbeta function. thanks in advance, mara. ____________________________________________________________________________________ Park yourself in front of a
2011 Nov 10
1
Gibbs sampler
...s <-function(m,theta = 0.25, lambda =0.55, n =1){ alpha <- 1.5 beta <- 1.5 gamma <- 1.5 x<- array(0,c(m+1, 3)) x[1,1] <- theta x[1,2] <- lambda x[1,3]<- n for(t in 2:(m+1)){ x[t,1] <- rbinom(1, x[t-1,3], x[t-1,1]) x[t,2]<-rbeta(1, x[t-1,1] + alpha, x[t-1,3] - x[t-1,1] + beta) x[t,3] <- rpois(1,(1 - x[t-1,1])*gamma) } x } gibbs(100) it returns only 1 or 2 values of theta, some times NaN, this may be if any theta is greater than 1, which is used as the probability for the next rbinom(), so returns NaN. C...
2012 Mar 09
1
nonparametric densities for bounded distributions
Can anyone recommend a good nonparametric density approach for data bounded (say between 0 and 1)? For example, using the basic Gaussian density approach doesn't generate a very realistic shape (nor should it): > set.seed(1) > dat <- rbeta(100, 1, 2) > plot(density(dat)) (note the area outside of 0/1) The data I have may be bimodal or have other odd properties (e.g. point mass at zero). I've tried transforming via the logit, estimating the density then plotting the curve in the original units, but this seems to do poorly in...
2009 Feb 13
2
Generate random numbers in Fortran
Hi!!! It would like to know if it exists a form to use the functions to generate variates in FORTRAN with the same easiness I use that them in C? Or not? If yes. They would have some example? I would like to use the functions rbeta, rlnorm and others! Sorry my english..rsrsrs Thanks!!!              Fábio Mathias Corrêa    University Federal of the Lavras - Brazil Veja quais são os assuntos do momento no Yahoo! +Buscados [[alternative HTML version deleted]]