tprDiameterCpp: Function to extract diameters from Taper curve using Rcpp

tprDiameterCppR Documentation

Function to extract diameters from Taper curve using Rcpp

Description

This function uses Rcpp and C-code to implement the diameter estimation of package TapeR to allow for faster estimation if no interval information is required.

Usage

tprDiameterCpp(obj, Hx, bark = TRUE, cp = TRUE, mono = TRUE, Rfn = NULL)

## S4 method for signature 'tprTrees'
tprDiameterCpp(obj, Hx, bark = TRUE, cp = TRUE, mono = TRUE, Rfn = NULL)

Arguments

obj

object of class 'tprTrees'

Hx

vector of heights for which diameter are required

bark

should diameter over or under bark be returned?

cp

cartesian product, i.e. apply all Hx to all trees, defaults to TRUE

mono

logical to decide whether a supporting diameter should be added in case the taper curve is regarded as non-monotonic. Defaults to TRUE.

Rfn

setting for residuals error matrix, defaults to "sig2", see details.

Details

Function evaluates taper curves at required height Hx. By default (cp==TRUE), the taper curve is evaluated at Hx for each tree. If cp==FALSE, each tree is evaluated at exactly one Hx (recycled if necessary). This feature is intended for situations where diameter in relative heights are required. Then, the recycling of one height Hx (e.g. 1.3m) is not possible, since relative heights depend on absolute tree height, which might be different for each tree. Hence a call like tprDiameter(obj, Hx=0.3*Ht(obj), cp=FALSE) is necessary.

Value

a vector, in case only one diameter (i.e. Hx) is required per tree (cp=FALSE) or a matrix of size length(trees) x length(Hx) (cp=TRUE).

Methods (by class)

  • tprDiameterCpp(tprTrees): method for class 'tprTrees'

See Also

tprDiameter if confidence or prediction intervals are required.

Examples

obj <- tprTrees(spp=c(1 , 3),
                Hm=list(c(1.3, 5), c(1.3, 5)),
                Dm=list(c(27, 25), c(27, 25)),
                Ht=c(27, 27))
Hx <- seq(0, 1, 0.1)
tprDiameterCpp(obj, Hx = Hx)
tprDiameterCpp(obj, Hx = Hx, bark=FALSE)
tprDiameterCpp(obj, Hx = c(1, 2), bark=FALSE, cp=FALSE)


require(rbenchmark)
benchmark(tprDiameter(obj, Hx, bark = TRUE),
          tprDiameterCpp(obj, Hx, bark = TRUE),
          replications = 10000)[,1:4]


TapeS documentation built on March 31, 2023, 7:19 p.m.