Package 'PEcAn.allometry'

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

Help Index


allom.BayesFit

Description

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

Usage

allom.BayesFit(allom, nrep = 10000, form = "power", dmin = 0.1, dmax = 500)

Arguments

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:

n

sample size

a

eqn coefficient

b

eqn coefficient

c

eqn coefficient

d

eqn coefficient

e

eqn coefficient

se

standard error

eqn

sample size

Xmin

smallest tree sampled (cm)

Xmax

largest tree sampled (cm)

Xcor

units correction on X

Ycor

units correction on Y

Xtype

type of measurement on the X

spp

- USFS species code

nrep

- number of MCMC replicates

form

functional form of the allometry: 'power' vs 'exp'

dmin

minimum dbh of interest

dmax

maximum dbh of interest

Details

dependencies: requires MCMCpack and mvtnorm

note: runs 1 chain, but multiple chains can be simulated by multiple function calls

Value

returns MCMC chain and ONE instance of 'data' note: in many cases the estimates are multiply imputed

Author(s)

Michael Dietze


allom.predict

Description

Function for making tree-level Monte Carlo predictions from allometric equations estimated from the PEcAn allometry module

Usage

allom.predict(
  object,
  dbh,
  pft = NULL,
  component = NULL,
  n = NULL,
  use = "Bg",
  interval = "prediction",
  single.tree = FALSE
)

Arguments

object

Allometry model object. Option includes

'list of mcmc'

- mcmc outputs in a list by PFT then component

'vector of file paths'

- path(s) to AllomAve RData files

'directory where files are located

-

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.

Value

matrix of Monte Carlo predictions that has n rows and one column per DBH

Author(s)

Michael Dietze, Christy Rollinson

Examples

## 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)

AllomAve

Description

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)

Usage

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
)

Arguments

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

'acronym'

- USDA species acronyms (see plants.usda.gov), used with FIELD data (vector)

'spcd'

- USFS species codes, use with PARM data (vector)

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

Value

nested list of parameter summary statistics

Author(s)

Michael Dietze

Examples

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')))
}

AllomUnitCoef

Description

converts length units FROM cm TO specified units converts mass units TO kg FROM specificed units

Usage

AllomUnitCoef(x, tp = NULL)

Arguments

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'


load.allom

Description

loads allom files

Usage

load.allom(object)

Arguments

object

Allometry model object. Option includes

'vector of file paths'

- path(s) to AllomAve RData files

'directory where files are located

-

Value

mcmc outputs in a list by PFT then component

Author(s)

Michael Dietze

Examples

## Not run: 
  object = '~/Dropbox//HF C Synthesis/Allometry Papers & Analysis/'
  allom.mcmc = load.allom(object)


## End(Not run)

nu

Description

converts factors to numeric

Usage

nu(x)

Arguments

x

data


query.allom.data

Description

Module to grab allometric information from the raw data table Will grab both original field data and tallied equations

Usage

query.allom.data(pft_name, variable, con, nsim = 10000)

Arguments

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

Details

Tallied equation format based on Jenkins et al 2004 USFS General Technical Report NE-319

database is assumed to conform to the PEcAn Schema

Author(s)

Michael Dietze


read.allom.data

Description

Extracts PFT- and component-specific data and allometeric equations from the specified files.

Usage

read.allom.data(pft.data, component, field, parm, nsim = 10000)

Arguments

pft.data

PFT dataframe

acronym

USDA species acronyms, used with FIELD data (vector)

spcd

USFS species codes, use with TALLY data (vector)

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

Details

This code also estimates the standard error from R-squared, which is required to simulate pseudodata from the allometric eqns.

Value

field

PFT-filtered field Data

parm

Component- and PFT-filtered Allometric Equations