Menu

CFT

Mathieu Fortin
Attachments
CFT_0.1.6.pdf (82581 bytes)
CFT_0.2.0.pdf (82512 bytes)
DistEst1.png (7990 bytes)
DistMonteCarlo1.png (6149 bytes)

The CFT package for R

IMPORTANT

The dissimilarity indices have migrated to an independent package called betadiv. All the information is available here.

References

Fortin, M. 2020. Package CFT. Version 0.1.6. PDF documentation.
Fortin, M. 2021. Package CFT. Version 0.2.0. PDF documentation.

Introduction

The CFT package is meant to provide a connection to a Java library that implements forest-related models in the Canadian context. At the moment, two features are available through the CFT package:

  • Variance estimators for greenhouse gas emissions (Fortin 2021)
  • A model of merchantable volume for 26 tree species in Québec, Canada (Fortin et al. 2007 (doi.org))

Requirements

To properly work, the CFT package requires the installation of the J4R package, which ensures the connection to Java. Please see the J4R webpage for more information about the installation of J4R and its requirements.

How to install the CFT package

The CFT package relies on the J4R package. To make it work you will have to go through the following steps:

1- Install the J4R package by copying this line of code in your R console:

install.packages("https://sourceforge.net/projects/repiceasource/files/latest", repos = NULL,  type="source")

2- Then download and install the CFT package by copying this line of code in your R console:

install.packages("https://sourceforge.net/projects/mrnfforesttools/files/latest", repos = NULL,  type="source")

Examples

Estimating beta diversity

The dissimilarity indices have migrated to an independent package called betadiv. All the information is available here.

Variance estimators for greenhouse gas emissions in national reporting

The estimation of greenhouse gas emissions often involves the product of two or more estimates. Several estimators of the variance of this product exist. The CFT contains functions and classes that implement these estimators. The createEstimate function requires two arguments, one for the mean and the other for the variance. An optional argument is the distribution of the estimate, which can be either dist="normal", dist="uniform" or dist="lognormal". By default, this distribution is assumed to be normal. The function returns an object of the class estimate as follows:

> library(CFT)
> est1 <- createEstimate(mean = 5, variance = 20)
> class(est1)
[1] "estimate"
attr(,"package")
[1] "CFT"
> summary(est1)
[1] "Mean = 5 ; Variance = 20 ; Distribution = normal"
>

In this example, the object est1 is a normally-distirbuted estimate with mean 5 and variance 20. The estimate can be plotted using the plotEstimate function:

> plotEstimate(est1)
>

which yields a graph similar to this one:

If we create another estimate called est2 and we are interested in the product of est1 by est2, the function multiplyEstimate can be used to obtain an estimate of the product and its variance:

> est2 <- createEstimate(mean = 4, variance = 8)
> product <- multiplyEstimates(est1,est2)
> summary(product)
[1] "Mean = 20 ; Variance = 360 ; Distribution = unknown"
>

The multiplyEstimate function implements five variance estimators

  1. a naive variance estimator
  2. a propagation-based estimator
  3. Goodman's estimator
  4. a Monte Carlo estimator
  5. a rescaled Monte Carlo estimator

By default, the function relies on Goodman's estimator. However, the user can decide to use the naive variance estimator as follows:

> product.naive <- multiplyEstimates(est1, est2, method="Naive")
> summary(product.naive)
[1] "Mean = 20 ; Variance = 680 ; Distribution = unknown"
>

The Monte Carlo and rescaled Monte Carlo estimators are both based on resampling. By default the number of realizations is set to 5000. The user can change the number of realizations through the realMC argument as in the following example:

> product.mc <- multiplyEstimates(est1, est2, method = "MonteCarlo", realMC = 10000)
> summary(product.mc)
[1] "Mean = 19.6712569018852 ; Variance = 657.241031072833 ; Distribution = empirical"
> 

The product.mc object is an instance of the monteCarloEstimate which is derived from the estimate class. This estimate can be plotted through the plotEstimate function which displays the realizations of the product in a histogram:

> plotEstimate(product.mc)
>

If the product of interest implies more than two variables, there can be entered in the multiplyEstimate function. For instance, if we create a third estimate, the function can estimate the product of these three estimates as follows:

> est3 <- createEstimate(mean = 3, variance = 3)
> product.goodman <- multiplyEstimates(est1,est2,est3)
> summary(product.goodman)
[1] "Mean = 60 ; Variance = 3360 ; Distribution = unknown"
> 

Theoretical developments and some simulation studies have shown that Goodman's and the rescaled Monte Carlo variance estimators are unbiased whereas the others tend to overestimate the true variance.

A model of merchantable volume for 26 tree species

The model is implemented through a single function called getUnderbarkMerchantableVolumeDm3. The function requires three arguments: a species code, tree DBH (cm) and height (m). For instance, the species code "SAB" stands for balsam fir and the following line

getUnderbarkMerchantableVolumeDm3("SAB", 18, 15)

will return the underbark merchantable volume in dm3 of a balsam fir tree with 18 cm in DBH and 15 m in height.

The species codes are the usual codes in the province of Québec. Those recognized by the model are shown in the following table.

Latin name Common name Species code
Abies balsamea Balsam fir SAB
Acer rubrum Red maple ERR
Acer saccharum Sugar maple ERS
Betula populifolia Grey birch BOG
Betula alleghaniensis Yellow birch BOJ
Betula papyrifera White birch BOP
Fagus grandifolia American beech HEG
Fraxinus americana American ash FRA
Fraxinus nigra Black ash FRN
Larix laricina American larch MEL
Ostrya virginiana American hophornbeam OSV
Picea glauca White spruce EPB
Picea mariana Black spruce EPN
Picea rubens Red spruce EPR
Pinus banksiana Jack pine PIG
Pinus resinosa Red pine PIR
Pinus strobus White pine PIB
Populus balsamifera Balsam poplar PEB
Populus grandidentata Large-tooth aspen PEG
Populus tremuloides Trembling aspen PET
Prunus serotina Black cherry CET
Quercus rubra Red oak CHR
Thuja occidentalis Eastern white cedar THO
Tilia americana American basswood TIL
Tsuga canadensis Eastern hemlock PRU
Ulmus americana American elm ORA

Version history

Date Version released Features and bugs fixed Comments
2021-08-13 0.2.0 The volume model of Fortin et al. (2007) (pubs.cif-ifc.org) has been integrated into the package.
2020-07-30 0.1.6 The dissimilarity indices have migrated in a new package called betadiv.
2020-04-26 0.1.5 The BioSim client has migrated into a subproject.
2020-03-17 0.1.4 Feature #3 and upgrade to J4R 1.0.5 Implementation of climate models in BioSim client
2020-01-17 0.1.3 Feature #2 and upgrade to J4R 1.0.4
2019-11-04 0.1.2 Upgrade to J4R 1.0.2 Refactoring in the dissimilarity functions, adding the variance estimators for greenhouse gas emissions
2019-07-24 0.1.1 Upgrade to J4R 1.0.1
2019-04-16 0.1.0 First beta version

MongoDB Logo MongoDB