The parametric diversity model (mdm) is a new method for directly relating diversity to
environmental predictors. It is based on three components: (1) parametric diversity, a new
parametric model of diversity that can represent any configuration of species proportional
abundances, (2) the multinomial logit model (MLM) that can relate species proportional
abundances to complex predictors and (3) the link between parametric diversity and the
likelihood function of the MLM.
The mdm is fitted using the multinom package from nnet.
Parametric diversities and true diversities can also be calculated for data sets using
the functions eds, eds1, ed, ed1.
a formula expression as for regression models, of the form response ~ predictors. The response
should be a matrix with K columns comprising proportions for each of K classes. A log-linear model
is fitted, with coefficients zero for the first class. An offset can be included:
it should be a numeric matrix with K columns. See the documentation of formula() for other details.
data
an optional data frame, list or environment (or object coercible by as.data.frame to a data frame)
containing the variables in the model. If not found in data, the variables are taken from
environment(formula), typically the environment from which mdm is called.
weights
optional case weights in fitting.
subset
expression saying which subset of the rows of the data should be used in the fit.
All observations are included by default.
na.action
a function to filter missing data.
MaxNWts
The maximum allowable number of weights. There is no limit in the code, but MaxNWts
is set to the exact number of required as specified in the formula.
Thus it should not need to be changed when fitting mdm.
maxit
maximum number of iterations. Default 1000.
contrasts
a list of contrasts to be used for some or all of the factors appearing as variables
in the model formula.
Hess
logical for whether the Hessian (the O/E information matrix) should be returned.
censored
If Y is a matrix with K > 2 columns, interpret the entries as one for possible classes,
zero for impossible classes, rather than as counts.
model
logical. If true, the model frame is saved as component model of the returned object.
use.shortcut
logical. If true, and the model is ~1 (a constant) or ~sites (a factor with one level for each site)
then the model is not fitted since the fitted values are known in each case. The first (alpha) model
has fitted values equal to the input data and the second (gamma) model fits the row means.
Fitting the alpha-model using nnet can be prohibitively expensive in computational time and
is unneccessary.
The returned models when use.shortcut == TRUE has the same components as when use.shortcut == FALSE,
and hence can be used in anova tables and plotting.
Using use.shortcut == TRUE can result in saving > 99% of computational time for a collection of models.
...
additional arguments for nnet.
Details
mdm calls multinom which calls nnet.
The variables on the rhs of the formula should be roughly scaled to [0,1]
or the fit will be slow or may not converge at all.
Value
A nnet object with additional components:
deviance
the residual deviance, compared to the full saturated model
(that explains individual observations exactly). Also, minus twice log-likelihood
edf
the (effective) number of degrees of freedom used by the model
AIC
the AIC for this fit
Hessian
if Hess is true
model
if model is true
entropy
the entropy of the fitted values
diversity
the diversity of the fitted values
Note
mdm is a modifed version of multinom in the
nnet package.
References
De'ath, G. (2011) The Multinomial Diversity Model: Linking Shannon Diversity
To Multiple Predictors.
Ripley, B. D. (1996) Pattern Recognition and Neural Networks. Cambridge.
Venables, W. N. and Ripley, B. D. (2002) Modern Applied Statistics with S.
Fourth edition. Springer.
R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> library(MDM)
Loading required package: nnet
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/MDM/mdm.Rd_%03d_medium.png", width=480, height=480)
> ### Name: mdm
> ### Title: Fits the parameteric diversity model
> ### Aliases: mdm
> ### Keywords: mdm
>
> ### ** Examples
>
> library(MDM)
> data(spider6)
> fit0 <- mdm(y2p(spider6[,1:6])~1,data=spider6)
# weights: 12 (5 variable)
> fit1 <- mdm(y2p(spider6[,1:6])~Water,data=spider6)
# weights: 18 (10 variable)
initial value 50.169265
iter 10 value 38.780815
iter 20 value 38.409944
final value 38.409941
converged
> fit2 <- mdm(y2p(spider6[,1:6])~Water+Herbs,data=spider6)
# weights: 24 (15 variable)
initial value 50.169265
iter 10 value 36.791764
iter 20 value 35.415854
iter 30 value 35.415361
final value 35.415361
converged
> fit3 <- mdm(y2p(spider6[,1:6])~Site,data=spider6)
# weights: 174 (140 variable)
> anova(fit0,fit1,fit2,fit3)
Deviances, Entropies and Diversities of Parametric Diversity Models
Response: y2p(spider6[, 1:6])
Model 1: y2p(spider6[, 1:6]) ~ 1
Model 2: y2p(spider6[, 1:6]) ~ Water
Model 3: y2p(spider6[, 1:6]) ~ Water + Herbs
Model 4: y2p(spider6[, 1:6]) ~ Site
DF DF-Diff Dev Dev-Diff Ent Ent-Diff Div Div-Ratio
1 135 94.105 1.6804 5.3680
2 130 5 76.820 17.2856 1.3718 0.30867 3.9424 1.3616
3 125 5 70.831 5.9892 1.2648 0.10695 3.5425 1.1129
4 0 125 60.923 9.9075 1.0879 0.17692 2.9681 1.1935
>
>
>
>
>
>
> dev.off()
null device
1
>