Hi all,

I have written a simple function, based on sample(), to create Null models
from actual data - a sample (?!) is below. My question is 1. How exactly
does the probability weighting work? I find the help file a bit convoluted,
which states "If* replace* is false, these probabilities are applied
sequentially, that is the probability of choosing the next item is
proportional to the weights amongst the remaining items." So does it (a) use
the probability weighting for each value sequentially, and that's why length
of both sample and probability file needs to be equal (so in the example
dataset below, the probability of sampling value "7.04" at each iterative
sample() selection, is equal to probability "0.912" , weight "9.45" by
"0.735" and so forth), or does it (b) use each probability values once, and
averages the remaining probability for the next sample()'s selection?

I am really looking to do method "a", and preliminary tests with dummy data
suggest it is in fact "a", but I need to be 100% sure.

Thanks in advance,
Bernard

Centre for Invasion Biology
Department of Botany and Zoology
Stellenbosch University
Private Bag X1
Matieland 7602
South Africa

bwtcoetzee@gmail.com
tel: +27 21 8082832
website: http://tinyurl.com/253m4os
33°55'54.82"S 18°51'48.34"E

# Null Function, i.e. "null.func(n1, median)"

null.func<-function(n1, test= c(median)){
  for (i in 1:length(n1[1,])){
    reps=10001
    output<-vector()
      while (length(output)<reps) {
      null.temp<-sample(n1[,2],length(n1[,i][is.na(n1[,i])==FALSE]),prob=
n1[,3],replace=FALSE)
      if (length(output)==0) {output<-test(null.temp,na.rm = TRUE)} else
{output<-c(output, test(null.temp,na.rm = TRUE))}
      }
print(output) ### And then one can do all sorts of analysis on this
output... (combine, create quantiles, calculate deviation etc.)
}
}

# SAMPLE DATASET "n1". Log transformed body weights. Null models are created
for each site, by sampling the 'actual' data, by the # species richness
("length()") of each site.

   sortcol actual probs site1 site2 site3  1 7.04 0.912 7.04 7.04 7.04  2
9.45 0.735 9.45 9.45 9.45  3 6.47 0.733 6.47 6.47 6.47  4 7.89 0.364 7.61
7.61 7.63  5 7.61 0.782 8.19 7.63 8.19  6 7.63 0.557 4.91 8.19 4.91  7 8.19
0.619 3.85 4.91 3.35  8 6.87 0.011 3.57 3.35 3.85  9 4.91 0.897
3.85 3.57  10 3.35 0.918
4.51 5.58  11 3.85 0.746
3.57 7.64  12 4.06 0.254
5.58 3.97  13 3.52 0.352
7.64 10.78  14 4.51 0.617

4.49  15 3.57 0.971

8.65  16 3.62 0.685

9.13  17 5.58 1.000

8.13  18 7.64 0.978


 19 5.68 0.468


 20 5.30 0.388

	[[alternative HTML version deleted]]

