Description Usage Arguments Author(s) References See Also Examples
explore coexistence patch number/density for a single scenario of a pair of parameters, for the case of multiple species modeling
1 | sta.mpaircomparison(coexistence, coenum, spnum, parameters)
|
coexistence |
list of data generated by sta.mcoexistence() function |
coenum |
coexisting species number in a patch you want to explore across the scenarios. Should be >=2 and <=total species number |
spnum |
number of species in the model |
parameters |
a parameter sampling point vector,for example parameters=c(.2,.5,.9), indicating three sampling points in a single parameter. The function will thus compare the number of patches where coexistence emerged (coexisting species number>=2) under the cases when each of the pairwise parameters (for example, growth rate and the competition ability of a species)=0.2,0.5 and 0.9 respectively. |
Youhua Chen <yhchen@zoology.ubc.ca>
Chen YH (2012) coexist: an R package for performing species coexistence modeling and analysis under asymmetric dispersal and fluctuating source-sink dynamics. http://code.google.com/p/coexist.
sta.mcomparison
,
batch.mpaircomp
,
sta.paircomparison
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | ##---- Should be DIRECTLY executable !! ----
##-- ==> Define data, use random,
##-- or do help(data=index) for the standard data sets.
## The function is currently defined as
function (coexistence, coenum, spnum, parameters = parspace)
{
if (coenum > spnum | coenum <= 1) {
cat("wrong number", "\n")
coenum = spnum
}
parnum <- dim(coexistence)[2] - 2 * spnum
comparisonlist <- list()
length(comparisonlist) <- parnum * (parnum - 1)/2
varlist <- comparisonlist
namesvector <- vector()
length(namesvector) <- length(comparisonlist)
count = 0
for (p1 in 1:(parnum - 1)) {
for (p2 in (p1 + 1):parnum) {
if (!is.list(parameters)) {
conum <- matrix(0, ncol = length(parameters),
nrow = length(parameters))
colnames(conum) = paste("=", parameters, sep = "")
rownames(conum) = paste("=", parameters, sep = "")
varmat <- conum
count = count + 1
for (i in 1:length(parameters)) {
for (j in 1:length(parameters)) {
temp <- coexistence[which(coexistence[, 2 *
spnum + p1] == parameters[i] & coexistence[,
2 * spnum + p2] == parameters[j]), ]
if (length(temp) == 0) {
conum[i, j] = 0
varmat[i, j] = 0
}
else {
conum[i, j] <- mean(temp[, spnum + coenum])
varmat[i, j] <- var(temp[, spnum + coenum])
}
}
}
}
else {
conum <- matrix(0, ncol = length(parameters[[p2]]),
nrow = length(parameters[[p1]]))
colnames(conum) = paste("=", parameters[[p2]],
sep = "")
rownames(conum) = paste("=", parameters[[p1]],
sep = "")
varmat <- conum
count = count + 1
for (i in 1:length(parameters[[p2]])) {
for (j in 1:length(parameters[[p1]])) {
temp <- coexistence[which(coexistence[, 2 *
spnum + p1] == parameters[[p2]][i] & coexistence[,
2 * spnum + p2] == parameters[[p1]][j]),
]
if (length(temp) == 0) {
conum[i, j] = 0
varmat[i, j] = 0
}
else {
conum[i, j] <- mean(temp[, spnum + coenum])
varmat[i, j] <- var(temp[, spnum + coenum])
}
}
}
}
comparisonlist[[count]] <- conum
namesvector[count] <- paste(colnames(coexistence)[2 *
spnum + p1], colnames(coexistence)[2 * spnum +
p2], sep = "-")
varlist[[count]] <- varmat
}
}
names(comparisonlist) <- namesvector
names(varlist) <- namesvector
return(list(mean = comparisonlist, var = varlist))
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.