fit_taper_Kozak: Fit taper equation to QSM

View source: R/traits_from_qsm.R

fit_taper_KozakR Documentation

Fit taper equation to QSM

Description

This function fits a taper equation to trunk sections of a QSM using the Kozak Model (2002, 2007).

Usage

fit_taper_Kozak(
  qsm,
  dbh,
  terminus_diam_cm = 4,
  segment_size = 0.25,
  plot = TRUE,
  start_a0 = 1,
  start_a1 = -1.3,
  start_a2 = 3,
  start_a3 = -5
)

Arguments

qsm

a QSM loaded using '[load_qsm()]'.

dbh

numeric – DBH in cm, required to fit Kozak model. Not calculated from QSM to avoid conflict with other more accurate measurement methods (e.g., 'get_DBH').

terminus_diam_cm

numeric – the minimum trunk diameter (cm) below which the trunk is no longer considered. Default is 4 cm.

segment_size

numeric – the length of segments (m) that QSM cylinders are grouped into. Default is 0.25 m.

plot

boolean – indicates whether model output should be plotted. Plots are found in the output list as object$plot, regardless of this setting.

start_a0

numeric – starting value for a0 parameter in nls fitting. Default is 1.

start_a1

numeric – starting value for a1 parameter in nls fitting. Default is -1.3.

start_a2

numeric – starting value for a2 parameter in nls fitting. Default is 3.

start_a3

numeric – starting value for a3 parameter in nls fitting. Default is -5.

Details

The normalized Kozak equation is:

d(h)/D = a_0 + a_1(h/H) + a_2(h/H)^2 + a_3(h/H)^3

where d(h) is diameter at height h, D is DBH, and H is total tree height. Both diameter and height are normalized to create dimensionless ratios.

The function groups QSM cylinders into segments of 'segment_size' up to 'terminus_diam_cm' which is the minimum diameter at which the trunk ends.

Value

A list with components:

data

Tibble of trunk segment heights and observed diameters used in model fitting.

plot

A 'ggplot2' object showing observed diameters and fitted taper curve.

results

Data frame containing fitted Kozak parameters ('a0'–'a3'), coefficient of determination ('r2'), and root mean squared error ('rmse').

Examples

qsm_file = system.file("extdata", "tree_0744_qsm.txt", package='tReeTraits')
qsm = load_qsm(qsm_file)
fit_taper_Kozak(qsm, dbh = 13.8)

# For a stubborn tree, try different starting values:
fit_taper_Kozak(qsm, dbh = 13.8, start_a0 = 0.9, start_a1 = -1, start_a2 = 2, start_a3 = -3)

tReeTraits documentation built on Sept. 24, 2026, 5:07 p.m.