fit_vbgrowth | R Documentation |
Estimate von Bertanlaffy growth parameters from lengths and ages
fit_vbgrowth(
Par,
Ages,
Lengths,
par_logspace = TRUE,
ReturnType = c("NLL", "Pred"),
sdFactor = 1
)
Par |
A list of von Bertanlaffy growth parameters in log space ordered as follows: K, Linf, L0, CV0, and CV1. Names will be assigned if they are not provided. |
Ages |
A vector of ages in years. Values of |
Lengths |
A vector of Lengths in cm. Lengths can be |
par_logspace |
TRUE/FALSE Indicates if the values in the |
ReturnType |
A single character value with |
sdFactor |
The number of standard deviations to include in the low and high calculations. The default is 1.0. |
Estimate von Bertanlaffy growth parameters from length and age data or predicted lengths given ages and input parameters.
Depending on ReturnType, either the negative log likelihood is returned based
on fits to the data or a matrix of three columns with low, predicted, and high
values for each combination of length and age. Distance of the low and high
from the predicted value depends on the sdFactor
, allowing confidence
intervals based on normal theory or other theories to be created.
## Not run:
bio_dat <- data.frame(
Age = rep(0:30, each = 20),
Length_cm = rnorm(n = 31 * 20, mean = 50, sd = 5)
)
pars_in <- lapply(FUN = log, X = list(
"K" = 0.13,
"Linf" = 55,
"L0" = 5,
"CV0" = 0.1,
"CV1" = 0.1
))
solve <- optim(
fn = estgrowth.vb, par = unlist(pars_in), hessian = FALSE,
Ages = bio_dat[, "Age"],
Lengths = bio_dat[, "Length_cm"]
)
predictions <- estgrowth.vb(
Par = solve$par, ReturnType = "Pred",
sdFactor = 1,
Ages = bio_dat[, "Age"],
Lengths = bio_dat[, "Length_cm"]
)
plot(bio_dat$Age, predictions[, "Lhat_pred"],
xlab = "Age (years)", ylab = "Predicted length (cm)"
)
exp(solve$par)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.