rcqo | R Documentation |
Random generation for constrained quadratic ordination (CQO).
rcqo(n, p, S, Rank = 1,
family = c("poisson", "negbinomial", "binomial-poisson",
"Binomial-negbinomial", "ordinal-poisson",
"Ordinal-negbinomial", "gamma2"),
eq.maximums = FALSE, eq.tolerances = TRUE, es.optimums = FALSE,
lo.abundance = if (eq.maximums) hi.abundance else 10,
hi.abundance = 100, sd.latvar = head(1.5/2^(0:3), Rank),
sd.optimums = ifelse(es.optimums, 1.5/Rank, 1) *
ifelse(scale.latvar, sd.latvar, 1),
sd.tolerances = 0.25, Kvector = 1, Shape = 1,
sqrt.arg = FALSE, log.arg = FALSE, rhox = 0.5, breaks = 4,
seed = NULL, optimums1.arg = NULL, Crow1positive = TRUE,
xmat = NULL, scale.latvar = TRUE)
n |
Number of sites. It is denoted by |
p |
Number of environmental variables, including an intercept term.
It is denoted by |
S |
Number of species.
It is denoted by |
Rank |
The rank or the number of latent variables or true dimension
of the data on the reduced space.
This must be either 1, 2, 3 or 4.
It is denoted by |
family |
What type of species data is to be returned.
The first choice is the default.
If binomial then a 0 means absence and 1 means presence.
If ordinal then the |
eq.maximums |
Logical. Does each species have the same maximum?
See arguments |
eq.tolerances |
Logical. Does each species have the
same tolerance? If |
es.optimums |
Logical. Do the species have equally spaced optimums?
If |
lo.abundance , hi.abundance |
Numeric. These are recycled to a vector of length |
sd.latvar |
Numeric, of length |
sd.optimums |
Numeric, of length |
sd.tolerances |
Logical. If |
Kvector |
A vector of positive |
Shape |
A vector of positive |
sqrt.arg |
Logical. Take the square-root of the
negative binomial counts?
Assigning |
log.arg |
Logical. Take the logarithm of the gamma random variates?
Assigning |
rhox |
Numeric, less than 1 in absolute value.
The correlation between the environmental variables.
The correlation matrix is a matrix of 1's along the diagonal
and |
breaks |
If |
seed |
If given, it is passed into |
optimums1.arg |
If assigned and |
Crow1positive |
See |
xmat |
The
|
scale.latvar |
Logical. If |
This function generates data coming from a
constrained quadratic
ordination (CQO) model. In particular,
data coming from a species packing model
can be generated
with this function.
The species packing model states that species have equal
tolerances, equal maximums, and optimums which are uniformly
distributed over the latent variable space. This can be
achieved by assigning the arguments es.optimums = TRUE
,
eq.maximums = TRUE
, eq.tolerances = TRUE
.
At present, the Poisson and negative binomial abundances
are generated first using lo.abundance
and
hi.abundance
, and if family
is binomial or ordinal
then it is converted into these forms.
In CQO theory the n
by p
matrix X
is
partitioned into two parts X_1
and X_2
. The matrix
X_2
contains the ‘real’ environmental variables whereas
the variables in X_1
are just for adjustment purposes;
they contain the intercept terms and other variables that one
wants to adjust for when (primarily) looking at the variables
in X_2
. This function has X_1
only being a matrix
of ones, i.e., containing an intercept only.
A n
by p-1+S
data frame with
components and attributes.
In the following the attributes are labelled with double
quotes.
x2 , x3 , x4 , ... , xp |
The environmental variables. This makes up the
|
y1 , y2 , x3 , ... , yS |
The species data. This makes up the
|
"concoefficients" |
The |
"formula" |
The formula involving the species and environmental
variable names.
This can be used directly in the |
"log.maximums" |
The |
"latvar" |
The |
"eta" |
The linear/additive predictor value. |
"optimums" |
The |
"tolerances" |
The |
Other attributes are "break"
,
"family"
, "Rank"
,
"lo.abundance"
, "hi.abundance"
,
"eq.tolerances"
, "eq.maximums"
,
"seed"
as used.
This function is under development and is not finished yet. There may be a few bugs.
Yet to do: add an argument that allows absences to be equal to the first level if ordinal data is requested.
T. W. Yee
Yee, T. W. (2004). A new technique for maximum-likelihood canonical Gaussian ordination. Ecological Monographs, 74, 685–701.
Yee, T. W. (2006). Constrained additive ordination. Ecology, 87, 203–213.
ter Braak, C. J. F. and Prentice, I. C. (1988). A theory of gradient analysis. Advances in Ecological Research, 18, 271–317.
cqo
,
qrrvglm.control
,
cut
,
binomialff
,
poissonff
,
negbinomial
,
gamma2
.
## Not run:
# Example 1: Species packing model:
n <- 100; p <- 5; S <- 5
mydata <- rcqo(n, p, S, es.opt = TRUE, eq.max = TRUE)
names(mydata)
(myform <- attr(mydata, "formula"))
fit <- cqo(myform, poissonff, mydata, Bestof = 3) # eq.tol = TRUE
matplot(attr(mydata, "latvar"), mydata[,-(1:(p-1))], col = 1:S)
persp(fit, col = 1:S, add = TRUE)
lvplot(fit, lcol = 1:S, y = TRUE, pcol = 1:S) # Same plot as above
# Compare the fitted model with the 'truth'
concoef(fit) # The fitted model
attr(mydata, "concoefficients") # The 'truth'
c(apply(attr(mydata, "latvar"), 2, sd),
apply(latvar(fit), 2, sd)) # Both values should be approx equal
# Example 2: negative binomial data fitted using a Poisson model:
n <- 200; p <- 5; S <- 5
mydata <- rcqo(n, p, S, fam = "negbin", sqrt = TRUE)
myform <- attr(mydata, "formula")
fit <- cqo(myform, fam = poissonff, dat = mydata) # I.tol = TRUE,
lvplot(fit, lcol = 1:S, y = TRUE, pcol = 1:S)
# Compare the fitted model with the 'truth'
concoef(fit) # The fitted model
attr(mydata, "concoefficients") # The 'truth'
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.