From: Jeremy Hetzel <jthetzel_at_gmail.com>

Date: Wed, 20 Apr 2011 11:25:34 -0700 (PDT)

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 Wed 20 Apr 2011 - 18:27:50 GMT

Date: Wed, 20 Apr 2011 11:25:34 -0700 (PDT)

Kevin,

The following follows John's suggestion, but without the loop. It's quick for me.

Jeremy T. Hetzel

Boston University

## Create an empty matrix with appropriate dimensions permutations <- matrix(ncol = n, nrow = rep)

## Look at the matrix

dim(permutations)

head(permutations)

## Find the column means

means <- apply(permutations, 1, mean)

means

On Wednesday, April 20, 2011 1:56:35 PM UTC-4, John Kane wrote:

*>
*

> There is probably a better way to do this but a for loop like this should

*> work. You would just need to change the numbers to yours and then add on the
**> locations
**> =========================================================
**>
**> scores <- 1:5
**> mydata <- matrix(data=NA, nrow=5, ncol=10)
**>
**> for(i in 1:10) {
**> mydata[,i] <- sample(scores, 5, replace=FALSE)
**> }
**>
**> =========================================================
**> --- On Wed, 4/20/11, Kevin Matthews <kevin-m..._at_uiowa.edu> wrote:
**>
**> From: Kevin Matthews <kevin-m..._at_uiowa.edu>
**> Subject: Re: [R] Random Relabelling
**> To: "John Kane" <jrkr..._at_yahoo.ca>
**> Cc: r-h..._at_r-project.org
**> Received: Wednesday, April 20, 2011, 1:22 PM
**>
**> I have a map of Iowa of with 4000 locations. At each location, I have a
**> cancer mortality rate. I need to test my null hypothesis; that the spatial
**> distribution of the mortality rates is random. For this test, I need to
**> establish a spatial reference distribution.
**>
**>
**> My reference distribution will be created by some random relabelling
**> algorithm. The 4000 locations would remain fixed, but the observed
**> mortality rates would be randomly redistributed. Then, I want 1000
**> permutations of the same algorithm. For each of those 1000 times, I would
**> record the redistributed mortality rate at each location. Then, I would
**> calculate the mean of the 1000 points. The result would be a spatial
**> reference distribution with a mean value of the random permutations at each
**> of the 4000 locations.
**>
**> Thanks for the response,Kevin
**>
**> On Wed, Apr 20, 2011 at 11:08 AM, John Kane <jrkr..._at_yahoo.ca> wrote:
**>
**>
**> Can you explain this a bit more. At the moment I don't see what you are
**> trying to achieve. "calculate the mean of the 1000 values at each of the
**> 4000 points" does not seem to make sense.
**>
**> --- On Wed, 4/20/11, kmatthews <kevin-m..._at_uiowa.edu> wrote:
**>
**> > From: kmatthews <kevin-m..._at_uiowa.edu>
**>
**> > Subject: [R] Random Relabelling
**>
**> > To: r-h..._at_r-project.org
**>
**> > Received: Wednesday, April 20, 2011, 10:04 AM
**>
**> > I have 4000 observations that I need
**>
**> > to randomly relabel 1000 times and then
**>
**> > calculate the mean of the 1000 values at each of the 4000
**>
**> > points. Any ideas
**>
**> > for where to begin?
**>
**> >
**>
**> > Thanks
**>
**> > Kevin
**>
**> >
**>
**>
**> [[alternative HTML version deleted]]
**>
**> ______________________________________________
**> R-h..._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 Wed 20 Apr 2011 - 18:27:50 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 Mon 25 Apr 2011 - 15:30:32 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.
*