View source: R/mastifFunctions.R
| mastif | R Documentation |
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.
mastif( inputs, formulaFec = NULL, formulaRep = NULL,
ng = NULL, burnin = NULL )
## S3 method for class 'mastif'
print(x, ...)
## S3 method for class 'mastif'
summary(object, verbose = TRUE, latex = FALSE, ...)
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. |
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')
Returns an object of class "mast", which is a list containing the following components:
|
|
chains |
|
parameters |
If
|
prediction |
If |
James S Clark, jimclark@duke.edu
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.
mastSim simulates data
A more detailed vignette is can be obtained with:
browseVignettes('mastif')
website 'http://sites.nicholas.duke.edu/clarklab/code/'.
# 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.