This functions wraps BIOMASS::modelHD(), which you can see for more options and details.

model_height(data, method = c("log1", "log2", "weibull", "michaelis"))

Arguments

data

A ForestGEO-like census-dataframe.

method

A character string. One of these:

  • log 1 (equivalent to a power model): log(H) = a + b * log(D)

  • log 2: log(H) = a + b * log(D) + c * log(D)^2

  • weibull: H = a * (1 - exp(-(D / b) ^ c))

  • michaelis: H = (A * D) / (B + D)

Value

A list with these elements:

  • input: list of the data used to construct the model (list(H, D)).

  • model: outputs of the model (same outputs as given by stats::lm(), stats::nls()).

  • RSE: Residual Standard Error of the model.

  • RSElog: Residual Standard Error of the log model (NULL if other model).

  • residuals: Residuals of the model.

  • coefficients: Coefficients of the model.

  • R.squared: R^2 of the model.

  • formula: Formula of the model.

  • method: Name of the method used to construct the model.

  • predicted: Predicted height values.

Details

All the back transformations for log-log models are done using the Baskerville correction (\(0.5 * RSE^2\), where RSE is the Residual Standard Error).

See also

Examples

data <- fgeo.biomass::scbi_tree1[1:30, ] str(model_height(data))
#> ℹ Using `method` log1 (other methods: log2, weibull, michaelis). #> List of 10 #> $ input :List of 2 #> ..$ H: num [1:30] 22.1 20.1 19.3 43.7 38.2 ... #> ..$ D: num [1:30] 27.9 23.7 22.2 135 87 ... #> $ model :List of 12 #> ..$ coefficients : Named num [1:2] 1.539 0.453 #> .. ..- attr(*, "names")= chr [1:2] "(Intercept)" "I(log(D)^1)" #> ..$ residuals : 'AsIs' Named num [1:30] 0.049230.... 0.026485.... 0.016387.... 0.016116.... 0.080607.... ... #> .. ..- attr(*, "names")= chr [1:30] "1" "2" "3" "4" ... #> ..$ effects : 'AsIs' Named num [1:30] -17.0169.... 2.107877.... 0.007487.... 0.014138.... 0.076945.... ... #> .. ..- attr(*, "names")= chr [1:30] "(Intercept)" "I(log(D)^1)" "" "" ... #> ..$ rank : int 2 #> ..$ fitted.values: 'AsIs' Named num [1:30] 3.047747.... 2.973807.... 2.944175.... 3.762282.... 3.563161.... ... #> .. ..- attr(*, "names")= chr [1:30] "1" "2" "3" "4" ... #> ..$ assign : int [1:2] 0 1 #> ..$ qr :List of 5 #> .. ..$ qr : num [1:30, 1:2] -5.477 0.183 0.183 0.183 0.183 ... #> .. .. ..- attr(*, "dimnames")=List of 2 #> .. .. .. ..$ : chr [1:30] "1" "2" "3" "4" ... #> .. .. .. ..$ : chr [1:2] "(Intercept)" "I(log(D)^1)" #> .. .. ..- attr(*, "assign")= int [1:2] 0 1 #> .. ..$ qraux: num [1:2] 1.18 1.06 #> .. ..$ pivot: int [1:2] 1 2 #> .. ..$ tol : num 1e-07 #> .. ..$ rank : int 2 #> .. ..- attr(*, "class")= chr "qr" #> ..$ df.residual : int 28 #> ..$ xlevels : Named list() #> ..$ call : language lm(formula = formula, data = data) #> ..$ terms :Classes 'terms', 'formula' language I(log(H)) ~ I(log(D)^1) #> .. .. ..- attr(*, "variables")= language list(I(log(H)), I(log(D)^1)) #> .. .. ..- attr(*, "factors")= int [1:2, 1] 0 1 #> .. .. .. ..- attr(*, "dimnames")=List of 2 #> .. .. .. .. ..$ : chr [1:2] "I(log(H))" "I(log(D)^1)" #> .. .. .. .. ..$ : chr "I(log(D)^1)" #> .. .. ..- attr(*, "term.labels")= chr "I(log(D)^1)" #> .. .. ..- attr(*, "order")= int 1 #> .. .. ..- attr(*, "intercept")= int 1 #> .. .. ..- attr(*, "response")= int 1 #> .. .. ..- attr(*, ".Environment")=<environment: 0x24b6a90> #> .. .. ..- attr(*, "predvars")= language list(I(log(H)), I(log(D)^1)) #> .. .. ..- attr(*, "dataClasses")= Named chr [1:2] "numeric" "numeric" #> .. .. .. ..- attr(*, "names")= chr [1:2] "I(log(H))" "I(log(D)^1)" #> ..$ model :'data.frame': 30 obs. of 2 variables: #> .. ..$ I(log(H)) : 'AsIs' num [1:30] 3.096977.... 3.000292.... 2.960563.... 3.778398.... 3.643769.... ... #> .. ..$ I(log(D)^1): 'AsIs' num [1:30] 3.328626.... 3.165475.... 3.100092.... 4.905274.... 4.465908.... ... #> .. ..- attr(*, "terms")=Classes 'terms', 'formula' language I(log(H)) ~ I(log(D)^1) #> .. .. .. ..- attr(*, "variables")= language list(I(log(H)), I(log(D)^1)) #> .. .. .. ..- attr(*, "factors")= int [1:2, 1] 0 1 #> .. .. .. .. ..- attr(*, "dimnames")=List of 2 #> .. .. .. .. .. ..$ : chr [1:2] "I(log(H))" "I(log(D)^1)" #> .. .. .. .. .. ..$ : chr "I(log(D)^1)" #> .. .. .. ..- attr(*, "term.labels")= chr "I(log(D)^1)" #> .. .. .. ..- attr(*, "order")= int 1 #> .. .. .. ..- attr(*, "intercept")= int 1 #> .. .. .. ..- attr(*, "response")= int 1 #> .. .. .. ..- attr(*, ".Environment")=<environment: 0x24b6a90> #> .. .. .. ..- attr(*, "predvars")= language list(I(log(H)), I(log(D)^1)) #> .. .. .. ..- attr(*, "dataClasses")= Named chr [1:2] "numeric" "numeric" #> .. .. .. .. ..- attr(*, "names")= chr [1:2] "I(log(H))" "I(log(D)^1)" #> ..- attr(*, "class")= chr "lm" #> $ residuals : num [1:30] 0.991 0.459 0.249 0.553 2.841 ... #> $ coefficients: num [1:2, 1:4] 1.5392 0.4532 0.0631 0.0177 24.393 ... #> ..- attr(*, "dimnames")=List of 2 #> .. ..$ : chr [1:2] "(Intercept)" "I(log(D)^1)" #> .. ..$ : chr [1:4] "Estimate" "Std. Error" "t value" "Pr(>|t|)" #> $ R.squared : num 0.959 #> $ formula : language lm(formula = formula, data = data) #> $ method : chr "log1" #> $ predicted : num [1:30] 21.1 19.6 19.1 43.2 35.4 ... #> $ RSE : num 3.43 #> $ RSElog : num 0.0824
out <- model_height(data, method = "log2")
#> ℹ Using `method` log2 (other methods: log1, weibull, michaelis).
# Avoid too much output str(out[-2])
#> List of 9 #> $ input :List of 2 #> ..$ H: num [1:30] 22.1 20.1 19.3 43.7 38.2 ... #> ..$ D: num [1:30] 27.9 23.7 22.2 135 87 ... #> $ residuals : num [1:30] -0.179 -0.162 -0.146 0.494 0.439 ... #> $ coefficients: num [1:3, 1:4] 0.0849 1.238 -0.0994 0.0265 0.014 ... #> ..- attr(*, "dimnames")=List of 2 #> .. ..$ : chr [1:3] "(Intercept)" "I(log(D)^1)" "I(log(D)^2)" #> .. ..$ : chr [1:4] "Estimate" "Std. Error" "t value" "Pr(>|t|)" #> $ R.squared : num 1 #> $ formula : language lm(formula = formula, data = data) #> $ method : chr "log2" #> $ predicted : num [1:30] 22.3 20.3 19.5 43.3 37.8 ... #> $ RSE : num 0.227 #> $ RSElog : num 0.00771
# Glimpse what wasn't shown above lapply(out[2], names)
#> $model #> [1] "coefficients" "residuals" "effects" "rank" #> [5] "fitted.values" "assign" "qr" "df.residual" #> [9] "xlevels" "call" "terms" "model" #>