diagnostic_metrics()
View source ↗On this page
Describe how well a fit matches the survey index, with in-sample errors and information criteria.
Usage
diagnostic_metrics(data.CatL, model_result)
Arguments
| Argument | Default | Description |
|---|---|---|
data.CatL | required | Survey index table, with the length labels in the first column and one column per time step. |
model_result | required | An ACL or ALSCL fit. |
Value
A data frame with the columns Metric and Value. The metrics are MSE, MAE, MAD, MASE, RMSE, Rsquared, MAPE, SMAPE, Explained Variance Score, Max Error, AIC, BIC and SD_log_resid (the standard deviation of the log residuals); diagnose_model() defines them. A metric that is not defined for the data is NA.
Details
These in-sample metrics use the finite positive survey observations only. The fitted values are the medians of the survey index on the original scale, exp(Elog_index) (where Elog_index is the fitted log index), without a lognormal mean correction. MASE divides MAE by the mean absolute change between adjacent time steps within each length bin, over the pairs in which both observations are positive. AIC and BIC count the estimated scalar parameters; compare them only between fits of the same observations with comparable likelihoods. Use hindcast_model() to score predictions of observations left out of the fit.
data.CatL can be a data frame, a matrix or a tibble; fitting, diagnostics and comparison read it the same way. Factor columns that hold numbers as text are read by their labels, not by their internal level codes. Observations, missing values, time labels or an order of length bins that differ from those of the fit are an error.
Additional details from R help
Only finite positive observations are included. MASE divides MAE by the pooled absolute one-step differences within each length-bin time series; pairs containing missing or zero observations are excluded. MAD is the mean absolute deviation of observations about their mean. These are in-sample diagnostics. The time labels, the order of the length bins, the positive observations and their values must match those that the fitted result records; for a result without these records the alignment cannot be fully checked. Nonfinite predictions at observed cells are rejected, including overflow when converting log predictions to the response scale.
Examples
Run the setup before the example. Fitting examples require an R-compatible C++ toolchain; simulation and export examples may write files.
Example setup
library(ALSCL)
library(ggplot2)
library(patchwork)
data("YTF_example")
x <- YTF_example
inputs <- x[c("data.CatL", "data.wgt", "data.mat")]
dat <- x$data.CatL
a <- run_acl(x, silent = TRUE)
b <- run_alscl(x, silent = TRUE)
# Use objects defined above
diagnostic_metrics(dat, b)