0

I am new user in R. In my work, I have to generate binary data(0 or 1) using beta distribution (rbeta command). I have to create a matrix of such data. In some of the columns I want to have more zeros than ones or ones more than zeros. And this should be done taking shaping parameter 1 = shaping parameter 2 =0.5. I tried all combinations. But I am not able to do this. Please let me know the way to do the same. The hint I was provided was: Take probability(0) =some number and probability(1) = 1- probability(0). Then give these parameters to rbeta command. But I did not find such facility with rbeta command. Please let me knoe if there is any way.

Thanking you, Kalyani

kalyani
  • 1
  • 2
  • 1
    If you want to create binary data, shouldn't you better use `rbinom`? Something like `rbinom(n=50, size=2, prob=0.1)`. – Roland Mar 06 '14 at 08:12
  • @Roland Probably he/she wants to simulate a random `prob` first. Thus user3387146, your problem is not well posed. – Stéphane Laurent Mar 06 '14 at 09:24
  • @Roland Thanks for your reply.Actually I want to create a matrix of binary data.The columns represent the features.Now I want make some of these columns containing more 0's or 1's.those are my useful features.columns which are having approx. same number of 0's and 1's are useless features.So while simulating I am generating useless columns taking prob ~o.5.But while simulating useful features I don't want to give probabilities manually(for eg: 0.001or0.95)Thats why I am suggested to choose rbeta command which can generate more 1's or 0's randomly.Is there any such facility? – kalyani Mar 07 '14 at 05:57
  • The beta distribution is not a discrete distribution. Thus it won't give you zeros and ones. Thus, I suggested an alternative. Of course, you can simulate different probabilities, which you can pass to the binomial distribution, but you haven't told us what or how you want to simulate. – Roland Mar 07 '14 at 08:00
  • @Roland Suppose I have to simulate a vector of length 1000, then the command should be like: rbeta(1000,p(0),1-p(0))(0,1). the person who told this command was not sure about syntax.So basically it will randomly pick one prob p(0). then if prob for '0' is greater that for '1' then it will produce more 0 and vice versa. So my question is whether such command is available or not. – kalyani Mar 07 '14 at 08:38
  • You seem to lack the ability to express yourself in statistical terms. I tried to give advice, but can't help you further, since you don't seem to understand what I am saying. – Roland Mar 07 '14 at 08:41

0 Answers0