tprDiameterCpp {TapeS} | R 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 |
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 |
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]