ma-methods: Model averaging (experimental)

maR Documentation

Model averaging (experimental)

Description

Method to average across a set of models. This is still experimental. Use with care.

Usage

ma(object, ...)

## S4 method for signature 'a4aFitSAs'
ma(object, stock, FUN, nsim = 1000)

Arguments

object

an a4aFits object with the fits to be averaged across

...

additional argument list that might never be used

stock

a stock object with the original data used for fitting

FUN

a function to compute the weights, which must return a named vector with weights. Note the weights will be normalized to sum 1 by ma()

nsim

a numeric with the number of simulations to be drawn

Value

an FLStock object with iterations defined by nsim

Examples

data(ple4)
data(ple4.indices)
fmod <- ~ factor(age) + s(year, k=20)
qmod <- c(list(~ s(age, k = 4)), rep(list(~s(age, k=4)), 5))
f1 <- sca(ple4, ple4.indices, fmodel=fmod, qmodel=qmod, fit = "assessment")
qmod <- c(list(~ s(age, k = 4) + year), rep(list(~s(age, k=4)), 5))
f2 <- sca(ple4, ple4.indices, fmodel=fmod, qmodel=qmod, fit = "assessment")
# AIC weighting
aicwt <- function(object){
 ICs <- -1 * sapply(object, AIC)
 exp( 0.5 * (ICs - max(ICs)))
}
stock.sim <- ma(a4aFitSAs(list(f1=f1, f2=f2)), ple4, aicwt, nsim = 100)
# equal weighting
eqwt <- function(object){
 v <- rep(1, length(object))
 names(v) <- names(object)
 v
}
stock.sim <- ma(a4aFitSAs(list(f1=f1, f2=f2)), ple4, eqwt, nsim = 100)

flr/FLa4a documentation built on Dec. 21, 2024, 9:28 p.m.