From: joris meys <jorismeys_at_gmail.com>

Date: Tue, 18 Nov 2008 23:23:08 +0100

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. Received on Tue 18 Nov 2008 - 22:30:27 GMT

Date: Tue, 18 Nov 2008 23:23:08 +0100

Just for clarification : this is an extension, where you can take the probability of switching to any possible value. Take into account that the p-value in the function rbinom is 1-P for the switching of the sign.

On Tue, Nov 18, 2008 at 11:21 PM, joris meys <jorismeys_at_gmail.com> wrote:

> The function rbinom might be a solution.

*>
**> Try following simple program :
**> vec <- c(-1,1,-1,1,1,-1,-1,1,1)
**>
**> inv <-rbinom(length(vec),1,0.5)
**> inv <-ifelse(inv==0,-1,1)
**>
**> vec2 <- vec*inv #switches sign with p=0.5
**>
**> In this, inv is a random binomial vector, where the probability for
**> being 1 is 0.5 in all positions. Changing the values of 0 in this
**> vector to -1, gives you a vector you can multiply with the original
**> one to change the sign with a probability of 0.5 for all positions
**>
**> Kind regards
**> Joris
**> On Tue, Nov 18, 2008 at 6:11 PM, Salas, Andria Kay <aks2515_at_uncw.edu> wrote:
**>> To clear up a question regarding my earlier posting regarding random changes in a vector:
**>>
**>> Say you have a vector (1, -1, -1, 1, 1, -1). I want each value in the vector to have a probability that it will change signs when this vector is regenerated. For example, probability = 50%. When the vector is regenerated, the first value in the vector (1) has a 50% chance of switching to -1. If I regenerated this vector 10 times, 5 of the times it would switch to -1. Similarly, I need each value in the vector to have this same probability of switching signs when the vector is regenerated, and each value's chances of doing so is independent of the other values. So the second value (-1) also has a 50% chance of switching to 1, and whether or not it does so is independent of if the first value changes from 1 to -1 (also a 50% probability).
**>>
**>> I hope this clears up the confusion, and I would appreciate any help anyone can provide!
**>> ______________________________________________
**>> 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.
**>>
**>
*

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. Received on Tue 18 Nov 2008 - 22:30:27 GMT

Archive maintained by Robert King, hosted by
the discipline of
statistics at the
University of Newcastle,
Australia.

Archive generated by hypermail 2.2.0, at Tue 18 Nov 2008 - 23:30:26 GMT.

*
Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help.
Please read the posting
guide before posting to the list.
*