Title: | PEcAn Allometry Functions |
---|---|
Description: | Synthesize allometric equations or fit allometries to data. |
Authors: | Mike Dietze [aut, cre], Shashank Singh [ctb], University of Illinois, NCSA [cph] |
Maintainer: | Mike Dietze <[email protected]> |
License: | BSD_3_clause + file LICENSE |
Version: | 1.7.3.9000 |
Built: | 2024-11-20 21:36:42 UTC |
Source: | https://github.com/PecanProject/pecan |
Module to fit a common power-law allometric model to a mixture of raw data and allometric equations in a Heirarchical Bayes framework with multiple imputation of the allometric data
allom.BayesFit(allom, nrep = 10000, form = "power", dmin = 0.1, dmax = 500)
allom.BayesFit(allom, nrep = 10000, form = "power", dmin = 0.1, dmax = 500)
allom |
- object (usually generated by query.allom.data) which needs to be a list with two entries: 'field' - contains a list, each entry for which is a data frame with 'x' and 'y'. Can be NULL 'parm' - a single data frame with the following components:
|
nrep |
- number of MCMC replicates |
form |
functional form of the allometry: 'power' vs 'exp' |
dmin |
minimum dbh of interest |
dmax |
maximum dbh of interest |
dependencies: requires MCMCpack and mvtnorm
note: runs 1 chain, but multiple chains can be simulated by multiple function calls
returns MCMC chain and ONE instance of 'data' note: in many cases the estimates are multiply imputed
Michael Dietze
Function for making tree-level Monte Carlo predictions from allometric equations estimated from the PEcAn allometry module
allom.predict( object, dbh, pft = NULL, component = NULL, n = NULL, use = "Bg", interval = "prediction", single.tree = FALSE )
allom.predict( object, dbh, pft = NULL, component = NULL, n = NULL, use = "Bg", interval = "prediction", single.tree = FALSE )
object |
Allometry model object. Option includes
|
dbh |
Diameter at Breast Height (cm) |
pft |
Plant Functional Type. Needs to match the name used in AllomAve. Can be NULL if only one PFT/species exists, otherwise needs to the same length as dbh |
component |
Which component to predict. Can be NULL if only one component was analysed in AllomAve. |
n |
Number of Monte Carlo samples. Defaults to the same number as in the MCMC object |
use |
c('Bg','mu','best') |
interval |
c('none','confidence','prediction') default is prediction |
single.tree |
logical: Is this a DBH time series from one individual tree? If TRUE, will use a fixed error for all draws. |
matrix of Monte Carlo predictions that has n rows and one column per DBH
Michael Dietze, Christy Rollinson
## Not run: object = '~/Dropbox//HF C Synthesis/Allometry Papers & Analysis/' dbh = seq(10,50,by=5) mass = allom.predict(object,dbh,n=100) ## End(Not run)
## Not run: object = '~/Dropbox//HF C Synthesis/Allometry Papers & Analysis/' dbh = seq(10,50,by=5) mass = allom.predict(object,dbh,n=100) ## End(Not run)
Allometry wrapper function that handles loading and subsetting the data, fitting the Bayesian models, and generating diagnostic figures. Set up to loop over multiple PFTs and components. Writes raw MCMC and PDF of diagnositcs to file and returns table of summary stats.
There are two usages of this function. When running 'online' (connected to the PEcAn database), pass the database connection, con, and the pfts subsection of the PEcAn settings. When running 'stand alone' pass the pft list mapping species to species codes and the file paths to the allometry table and field data (optional)
AllomAve( pfts, components = 6, outdir = NULL, con = NULL, field = NULL, parm = system.file("data/Table3_GTR-NE-319.v2.csv", package = "PEcAn.allometry"), ngibbs = 5000, nchain = 3, dmin = 0.1, dmax = 500 )
AllomAve( pfts, components = 6, outdir = NULL, con = NULL, field = NULL, parm = system.file("data/Table3_GTR-NE-319.v2.csv", package = "PEcAn.allometry"), ngibbs = 5000, nchain = 3, dmin = 0.1, dmax = 500 )
pfts |
pft list from PEcAn settings (if con) OR list of pft spcd's If the latter, the names within the list are used to identify PFTs
|
components |
IDs for allometry components from Jenkins et al 2004 Table 5. Default is stem biomass (6). See data(allom.components) |
outdir |
output directory files are written to. Default is getwd() |
con |
database connection |
field |
path(s) to raw data files |
parm |
path to allometry equation file (NULL default loads Jenkins Table 3) |
ngibbs |
number of MCMC iterations (per chain) to run |
nchain |
number of MCMC chains |
dmin |
minimum dbh of interest |
dmax |
maximum dbh of interest |
nested list of parameter summary statistics
Michael Dietze
if(FALSE){ pfts = list(FAGR = data.frame(spcd=531,acronym='FAGR')) allom.stats = AllomAve(pfts,ngibbs=500) ## example of a PFT with multiple species (late hardwood) ## note that if you're just using Jenkins the acronym column is optional pfts = list(LH = data.frame(spcd = c(531,318),acronym=c('FAGR','ACSA3'))) }
if(FALSE){ pfts = list(FAGR = data.frame(spcd=531,acronym='FAGR')) allom.stats = AllomAve(pfts,ngibbs=500) ## example of a PFT with multiple species (late hardwood) ## note that if you're just using Jenkins the acronym column is optional pfts = list(LH = data.frame(spcd = c(531,318),acronym=c('FAGR','ACSA3'))) }
converts length units FROM cm TO specified units converts mass units TO kg FROM specificed units
AllomUnitCoef(x, tp = NULL)
AllomUnitCoef(x, tp = NULL)
x |
units: mm, cm, cm2, m, in, g, kg, lb, Mg |
tp |
diameter type, leave NULL if DBH. Options: 'd.b.h.^2','cbh','crc' |
loads allom files
load.allom(object)
load.allom(object)
object |
Allometry model object. Option includes
|
mcmc outputs in a list by PFT then component
Michael Dietze
## Not run: object = '~/Dropbox//HF C Synthesis/Allometry Papers & Analysis/' allom.mcmc = load.allom(object) ## End(Not run)
## Not run: object = '~/Dropbox//HF C Synthesis/Allometry Papers & Analysis/' allom.mcmc = load.allom(object) ## End(Not run)
Module to grab allometric information from the raw data table Will grab both original field data and tallied equations
query.allom.data(pft_name, variable, con, nsim = 10000)
query.allom.data(pft_name, variable, con, nsim = 10000)
pft_name |
name of Plant Functional Type to be queried |
variable |
name of response variable |
con |
open database connection |
nsim |
number of pseudo-data simulations for estimating SE |
Tallied equation format based on Jenkins et al 2004 USFS General Technical Report NE-319
database is assumed to conform to the PEcAn Schema
Michael Dietze
Extracts PFT- and component-specific data and allometeric equations from the specified files.
read.allom.data(pft.data, component, field, parm, nsim = 10000)
read.allom.data(pft.data, component, field, parm, nsim = 10000)
pft.data |
PFT dataframe
|
component |
allometry ID, Jenkins table 5 |
field |
raw field data |
parm |
allometry equation file, Jenkins table 3 |
nsim |
number of Monte Carlo draws in numerical transforms |
This code also estimates the standard error from R-squared, which is required to simulate pseudodata from the allometric eqns.
field |
PFT-filtered field Data |
parm |
Component- and PFT-filtered Allometric Equations |