Skip to contents

Computes a linear regression model between the reference heights and the detected heights of matched pairs.

Usage

height_regression(lr, ld, matched, plot = TRUE, species = NULL, ...)

Arguments

lr

data.frame or matrix. 3D coordinates (X Y Height) of reference positions

ld

data.frame or matrix. 3D coordinates (X Y Height) of detected positions

matched

data.frame. contains pair indices, typically returned by tree_matching

plot

boolean. indicates whether results should be plotted

species

vector of strings. species for standardized color use by call to species_color

...

arguments to be passed to methods, as in plot

Value

A list with two elements. First one is the linear regression model, second one is a list with stats (root mean square error, bias and standard deviation of detected heights compared to reference heights).

See also

Examples

# create tree locations and heights
ref_trees <- cbind(c(1, 4, 3, 4, 2), c(1, 1, 2, 3, 4), c(15, 18, 20, 10, 11))
def_trees <- cbind(c(2, 2, 4, 4), c(1, 3, 4, 1), c(16, 19, 9, 15))

# tree matching
match1 <- tree_matching(ref_trees, def_trees)

# height regression
reg <- height_regression(ref_trees, def_trees, match1,
  species = c("ABAL", "ABAL", "FASY", "FASY", "ABAL"),
  asp = 1, xlim = c(0, 21), ylim = c(0, 21)
)

summary(reg$lm)
#> 
#> Call:
#> stats::lm(formula = Hm ~ Hl, data = app)
#> 
#> Residuals:
#>       1       2       3       4 
#> -1.9526  0.1611 -0.2180  2.0095 
#> 
#> Coefficients:
#>             Estimate Std. Error t value Pr(>|t|)  
#> (Intercept)   1.5592     4.1631   0.375   0.7440  
#> Hl            0.9621     0.2741   3.510   0.0724 .
#> ---
#> Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#> 
#> Residual standard error: 1.99 on 2 degrees of freedom
#> Multiple R-squared:  0.8604,	Adjusted R-squared:  0.7906 
#> F-statistic: 12.32 on 1 and 2 DF,  p-value: 0.07244
#> 
reg$stats
#> $rmse
#> [1] 1.732051
#> 
#> $bias
#> [1] -1
#> 
#> $sd
#> [1] 1.632993
#>