Title: | Additional Diagnostics for FLa4a stock Assessment Models |
---|---|
Description: | A series of extra diagnostics for the FLa4a model, including prediction skill through restrospective prediction of model inputs and runs tests. Contains ggplot-based plot funtions of diagnostics outputs. |
Authors: | Iago Mosqueira [aut, cre] , Henning Winker [aut], European Union [fnd, cph] |
Maintainer: | Iago Mosqueira <[email protected]> |
License: | EUPL |
Version: | 0.1.6 |
Built: | 2024-11-20 05:37:31 UTC |
Source: | https://github.com/flr/a4adiags |
a4aBioidx Computes observed and expected FLIndexBiomass from a4a fits
a4aBioidx(stock, fit, indices)
a4aBioidx(stock, fit, indices)
stock |
Input FLStock object. |
fit |
object a4a fit . |
indices |
Input FLIndices object. |
nyears |
Number if years for retrospective, defaults to 5. |
nsq |
Number of years for average biology and selectivity, defaults to 3. |
fixed.ks |
Is the number of knots is splines with 'year' constant? |
FLIndexBiomass
data(sol274) # models fmod <- ~te(replace(age, age > 8, 8), year, k = c(4, 22)) + s(replace(age, age > 8, 8), k=4) + s(year, k=22, by=as.numeric(age==1)) qmod <- list(~s(age, k=3), ~s(age, k=3)) vmod <- list(~s(age, k=3), ~s(age, k=3), ~s(age, k=3)) srmod <- ~factor(year) # RUN a4a fit <- sca(stock, indices, fmodel=fmod, qmodel=qmod, vmodel=vmod,sr=srmod) idxs = a4aBioidx(stock,fit,indices) idxs$"BTS"@index # observed idxs$"BTS"@index.q # fitted stored here
data(sol274) # models fmod <- ~te(replace(age, age > 8, 8), year, k = c(4, 22)) + s(replace(age, age > 8, 8), k=4) + s(year, k=22, by=as.numeric(age==1)) qmod <- list(~s(age, k=3), ~s(age, k=3)) vmod <- list(~s(age, k=3), ~s(age, k=3), ~s(age, k=3)) srmod <- ~factor(year) # RUN a4a fit <- sca(stock, indices, fmodel=fmod, qmodel=qmod, vmodel=vmod,sr=srmod) idxs = a4aBioidx(stock,fit,indices) idxs$"BTS"@index # observed idxs$"BTS"@index.q # fitted stored here
The output of a4ahcxval
consist of a list with two elements, named 'stocks'
and 'indices'. The first is an object of class FLStocks
, each a peel from
the restrospective run. The second element is a list of FLIndices
object.
The first FLIndices
object, named 'data', is a copy of the input 'indices'
argument, with the additoned catch.n
slot, if originally missing. The next
element, named as the final year of the data set, contains the naive prediction
of the input FLIndices
, while the remaining elements are the result of a
hindcast prediction of the relevant indices, those within the year range of
as set ny nyears
.
a4ahcxval(stock, indices, nyears = 5, nsq = 3, check.ks = FALSE, ...)
a4ahcxval(stock, indices, nyears = 5, nsq = 3, check.ks = FALSE, ...)
stock |
Input FLStock object. |
indices |
Input FLIndices object. |
nyears |
Number if years for retrospective, defaults to 5. |
nsq |
Number of years for average biology and selectivity, defaults to 3. |
... |
Any submodels and other arguments for the call to sca. |
fixed.ks |
Is the number of knots is splines with 'year' constant? |
A list containing elements 'stocks', of class FLStocks, and 'indices', a list of FLIndices objects. See details for structure of this list.
data(sol274) # models fmod <- ~te(replace(age, age > 8, 8), year, k = c(4, 22)) + s(replace(age, age > 8, 8), k=4) + s(year, k=22, by=as.numeric(age==1)) qmod <- list(~s(age, k=3), ~s(age, k=3)) vmod <- list(~s(age, k=3), ~s(age, k=3), ~s(age, k=3)) srmod <- ~factor(year) # RUN xval xval <- a4ahcxval(stock, indices, fmodel=fmod, qmodel=qmod, vmodel=vmod,sr=srmod) # PLOT result plotXval(xval$indices)
data(sol274) # models fmod <- ~te(replace(age, age > 8, 8), year, k = c(4, 22)) + s(replace(age, age > 8, 8), k=4) + s(year, k=22, by=as.numeric(age==1)) qmod <- list(~s(age, k=3), ~s(age, k=3)) vmod <- list(~s(age, k=3), ~s(age, k=3), ~s(age, k=3)) srmod <- ~factor(year) # RUN xval xval <- a4ahcxval(stock, indices, fmodel=fmod, qmodel=qmod, vmodel=vmod,sr=srmod) # PLOT result plotXval(xval$indices)
Plot the runs test result for one or more time series
## S4 method for signature 'a4aFitSA,FLIndices' plotRunstest(fit, obs, combine = TRUE)
## S4 method for signature 'a4aFitSA,FLIndices' plotRunstest(fit, obs, combine = TRUE)
fit |
The result of a model fit. |
obs |
The observations used in the fit. |
combine |
Should ages be combined by addition, defaults to TRUE. |
... |
Extra arguments. |
An object of class ggplot2::gg
data(sol274) plotRunstest(fit, indices)
data(sol274) plotRunstest(fit, indices)
Plot of FLIndices cross-validation by retrospective hindcast
plotXval2(x, y = "missing", order = "inverse")
plotXval2(x, y = "missing", order = "inverse")
x |
An FLIndices object of the original observations. |
y |
A list contaning FLIndices objects returned by a4ahcxval. |
order |
Order in which retrospective runs are stored, defaults to"inverse". |
A ggplot object
# SEE vignette
# SEE vignette
Computes Runs Test p-values
## S4 method for signature 'a4aFitSA,FLIndices' runstest(fit, obs, combine = TRUE)
## S4 method for signature 'a4aFitSA,FLIndices' runstest(fit, obs, combine = TRUE)
fit |
The result of a model fit. |
obs |
The observations used in the fit. |
combine |
Should ages be combined by addition, defaults to TRUE. |
... |
Extra arguments. |
A list with elements 'p.values' and 'pass'.
data(sol274) # Call on a a4aFitSA object runstest(fit, indices) # runstest(index(fit), lapply(indices, index))
data(sol274) # Call on a a4aFitSA object runstest(fit, indices) # runstest(index(fit), lapply(indices, index))
fmod <- ~te(replace(age, age > 8, 8), year, k = c(4, 22)) + s(replace(age, age > 8, 8), k=4) + s(year, k=22, by=as.numeric(age==1))
Objects of class FLStock, FLIndices and a4aFitSA
qmod <- list(~s(age, k=3), ~s(age, k=3))
vmod <- list( ~s(age, k=3), ~s(age, k=3), ~s(age, k=3))
srmod <- ~factor(year)