mastif {mastif} | R Documentation |
Gibbs sampler for mast data
Description
Estimates productivity and dispersion of seeds observed at seed traps, using information on locations, and covariates that could explain source strength. Data can be simulated with mastSim
.
Usage
mastif( inputs, formulaFec = NULL, formulaRep = as.formula("~diam"),
ng = NULL, burnin = NULL )
## S3 method for class 'mastif'
print(x, ...)
## S3 method for class 'mastif'
summary(object, verbose = TRUE, latex = FALSE, ...)
Arguments
inputs |
|
formulaFec |
R |
formulaRep |
R |
ng |
|
burnin |
|
object |
currently, also an object of |
verbose |
if |
latex |
if |
x |
object of |
... |
further arguments not used here. |
Details
inputs
includes the following:
specNames
is a character vector
containing names of species, specNames
, that appear in the treeData$species
column.
seedNames
is a character vector
of seed types that appear as column names in seedData
.
treeData
is a data.frame
holding tree information, including predictors and tree-year identification. Required columns are plot
, tree
, species
, year
, diam
, and any other predictors for fecundity or maturation.
seedData
is a data.frame
holding seed counts with seed trap and year identification. Required columns are plot
, trap
, year
, and seedNames
, the latter holding seed counts.
xytree
is a data.frame
holding tree locations. Required columns are plot
, tree
, x
, and y
.
xytrap
is data.frame
holding seed trap locations. Required columns are plot
, trap
, x
, and y
.
formulaFec
and formulaRep
specify the models for plant fecundity and maturation. Variables listed in formulas appear as column headings in treeData
. Note that formulaFec
and formulaRep
begin with ~
, not y ~
. The response matrix
is constructed from seed types in seedData
.
The treeData$tree
column has values that are unique for a tree within a plot
. These reference the same unique identifiers in xytree$tree
. In addition to these identifiers, the data.frame xytree
holds columns x
and y
for map locations.
The character vector seedNames
holds the names of columns in seedData
for seed counts. The elements of seedNames
are seed types produced by one or more of the species in specNames
. seedData
must also include columns for trap
, plot
, and year
, which link with columns in xytrap
, which additionally includes columns x
and y
.
predList
includes the names of plots
and years
to be predicted. It can include a numeric
value mapMeters
for the distance between lattice points in the prediction grid. See examples.
yearEffect
is a list
indicating the column names in treeData
for random groups in year effects or AR(p) models. See examples.
randomEffect
is a list
indicating the column names in treeData
for random groups in fecundity estimates, the character randGroups
and the formulaRan
for random effects. The formulaRan
must be a subset of predictors from formulaFec
. See examples.
modelYears
is a numeric vector
of years to include in the analysis.
ng
is the number of Gibbs steps. burnin
is the number of initial steps, must be less than ng
.
Additional arguments to inputs
can include prior parameters; default values are:
priorDist = 10
is a prior mean dispersal distance in meters.
priorVDist = 1
is the prior variance on mean dispersal distance in meters.
minDist = 2
and maxDist = 60
are the minimum and maximum values for the mean dispersal kernel in meters.
minDiam = 2
is the minimum diameter that a tree could be reproductively mature, in cm.
sigmaMu = .5
and sigmaWt = nrow(inputs$treeData)
are the prior mean and the prior weight on log fecundity variance.
maxF = 1e+8
, maximum fecundity, helps stabilize analysis of especially noisy data.
More detailed vignettes can be obtained with:
browseVignettes('mastif')
Value
Returns an object of class "mast"
, which is a list containing the following components:
inputs |
|
chains |
|
parameters |
If
|
prediction |
If |
Author(s)
James S Clark, jimclark@duke.edu
References
Clark, J.S., C. Nunes, and B. Tomasek. 2019. Foodwebs based on unreliable foundations: spatio-temporal masting merged with consumer movement, storage, and diet. Ecological Monographs, e01381. Qiu, T., ..., and J. S. Clark. 2023. Mutualist dispersers and the global distribution of masting: mediation by climate and fertility. Nature Plants, https://doi.org/10.1038/s41477-023-01446-5.
See Also
mastSim
simulates data
A more detailed vignette is can be obtained with:
browseVignettes('mastif')
website 'http://sites.nicholas.duke.edu/clarklab/code/'.
Examples
# simulate data (see \link{\code{mastSim}})
seedNames <- specNames <- 'acerRubr'
sim <- list(nyr=10, ntree=20, nplot=5, ntrap=40,
specNames = specNames, seedNames = seedNames)
inputs <- mastSim(sim) # simulate data
inputs$predList <- list( mapMeters = 3, plots = inputs$plots[1],
years = inputs$years )
output <- mastif( inputs = inputs, ng = 3000, burnin = 2000 )
# mastPlot(output)
# for Liriodendron
d <- "https://github.com/jimclarkatduke/mast/blob/master/liriodendronExample.rData?raw=True"
repmis::source_data(d)
formulaFec <- as.formula( ~ diam ) # fecundity model
formulaRep <- as.formula( ~ diam ) # maturation model
yearEffect <- list(groups = 'species')
randomEffect <- list(randGroups = 'treeID',
formulaRan = as.formula( ~ 1 ) )
inputs <- list( specNames = specNames, seedNames = seedNames,
treeData = treeData, seedData = seedData,
xytree = xytree, xytrap = xytrap,
yearEffect = yearEffect, randomEffect = randomEffect )
output <- mastif(inputs = inputs, formulaFec, formulaRep, ng = 1000,
burnin = 400 )
summary(output)
# plot output:
# mastPlot(output)