m.Rd
Method to compute natural mortality.
# S4 method for class 'a4aM'
m(object, grMod = "missing", ...)
a a4aM
object
a a4aGr
object from which the growth parameter K can be extracted
placeholder for covariates of the models. The names must match formula variables (not parameters), with the exception of the a4aGr
individual growth model. To use a growth model, it must be called grMod
and be of class a4aGr
, in which case the parameters will be matched. The main objective is to be able to use K
from von Bertalanffy models in M.
an FLQuant
object
The method uses the range slot to define the quant and year dimensions of the resulting M
FLQuant
. The name for the quant dimension is taken as the name of a variable that is present in the shape
formula, but not in the params
slot of the shape
model. If more than one such variable exists, then there is a problem with the shape
model definition.
age <- 0:15
k <- 0.4
shp <- eval(as.list(~exp(-age-0.5))[[2]], envir=list(age=age))
lvl <- eval(as.list(~1.5*k)[[2]], envir=list(k=k))
M <- shp*lvl/mean(shp)
# Now set up an equivalent a4aM object
mod1 <- FLModelSim(model=~exp(-age-0.5))
mod2 <- FLModelSim(model=~1.5*k, params=FLPar(k=0.4))
m1 <- a4aM(shape=mod1, level=mod2)
# set up the age range for the object...
range(m1, c("min", "max")) <- c(0,15)
# ...and the age range for mbar
range(m1, c("minmbar", "maxmbar")) <- c(0,15)
m(m1)
#> An object of class "FLQuant"
#> , , unit = unique, season = all, area = unique
#>
#> year
#> age 0
#> 0 6.07e+00
#> 1 2.23e+00
#> 2 8.21e-01
#> 3 3.02e-01
#> 4 1.11e-01
#> 5 4.09e-02
#> 6 1.50e-02
#> 7 5.53e-03
#> 8 2.04e-03
#> 9 7.49e-04
#> 10 2.76e-04
#> 11 1.01e-04
#> 12 3.73e-05
#> 13 1.37e-05
#> 14 5.05e-06
#> 15 1.86e-06
#>
#> units: NA
mean(m(m1)[ac(0:15)])
#> [1] 0.6
all.equal(M, c(m(m1)))
#> [1] TRUE
# another example m
range(m1, c("min", "max")) <- c(2,15)
range(m1, c("minmbar", "maxmbar")) <- c(2,4)
m(m1)
#> An object of class "FLQuant"
#> , , unit = unique, season = all, area = unique
#>
#> year
#> age 0
#> 2 1.20e+00
#> 3 4.41e-01
#> 4 1.62e-01
#> 5 5.96e-02
#> 6 2.19e-02
#> 7 8.07e-03
#> 8 2.97e-03
#> 9 1.09e-03
#> 10 4.02e-04
#> 11 1.48e-04
#> 12 5.44e-05
#> 13 2.00e-05
#> 14 7.36e-06
#> 15 2.71e-06
#>
#> units: NA
mean(m(m1)[ac(2:4)])
#> [1] 0.6
# example with specified iters (i.e. not simulated from a statistical distribution)...
mod2 <- FLModelSim(model=~k^0.66*t^0.57,
params=FLPar(matrix(c(0.4,10,0.5,11), ncol=2, dimnames=list(params=c("k","t"), iter=1:2))),
vcov=array(c(0.004,0.,0.,0.001,0.006,0.,0.,0.002), dim=c(2,2,2)))
m2 <- a4aM(shape=mod1, level=mod2)
range(m2, c("min", "max")) <- c(2,10)
m(m2)
#> An object of class "FLQuant"
#> iters: 2
#>
#> , , unit = unique, season = all, area = unique
#>
#> year
#> age 0
#> 2 2.256002(0.336016)
#> 3 0.829937(0.123613)
#> 4 0.305317(0.045475)
#> 5 0.112320(0.016729)
#> 6 0.041320(0.006154)
#> 7 0.015201(0.002264)
#> 8 0.005592(0.000833)
#> 9 0.002057(0.000306)
#> 10 0.000757(0.000113)
#>
#> units: NA
# ...and with randomly generated iters (based on the medians for params(mod2) and vcov(mod2))
m3 <- a4aM(shape=mod1, level=mvrnorm(100, mod2))
range(m3, c("min", "max")) <- c(0,15)
m(m3)
#> An object of class "FLQuant"
#> iters: 100
#>
#> , , unit = unique, season = all, area = unique
#>
#> year
#> age 0
#> 0 2.22e+00(2.51e-01)
#> 1 8.18e-01(9.22e-02)
#> 2 3.01e-01(3.39e-02)
#> 3 1.11e-01(1.25e-02)
#> 4 4.07e-02(4.59e-03)
#> 5 1.50e-02(1.69e-03)
#> 6 5.51e-03(6.22e-04)
#> 7 2.03e-03(2.29e-04)
#> 8 7.46e-04(8.41e-05)
#> 9 2.74e-04(3.09e-05)
#> 10 1.01e-04(1.14e-05)
#> 11 3.71e-05(4.19e-06)
#> 12 1.37e-05(1.54e-06)
#> 13 5.02e-06(5.67e-07)
#> 14 1.85e-06(2.09e-07)
#> 15 6.80e-07(7.67e-08)
#>
#> units: NA
# example with a trend
mod3 <- FLModelSim(model=~1+b*v, params=FLPar(b=0.05))
mObj <- a4aM(shape=mod1, level=mvrnorm(100, mod2), trend=mod3,
range=c(min=0,max=15,minyear=2000,maxyear=2003,minmbar=0,maxmbar=0))
m(mObj, v=1:4)
#> An object of class "FLQuant"
#> iters: 100
#>
#> , , unit = unique, season = all, area = unique
#>
#> year
#> age 2000 2001 2002
#> 0 2.37e+00(2.42e-01) 2.48e+00(2.53e-01) 2.59e+00(2.65e-01)
#> 1 8.72e-01(8.89e-02) 9.13e-01(9.31e-02) 9.55e-01(9.73e-02)
#> 2 3.21e-01(3.27e-02) 3.36e-01(3.42e-02) 3.51e-01(3.58e-02)
#> 3 1.18e-01(1.20e-02) 1.24e-01(1.26e-02) 1.29e-01(1.32e-02)
#> 4 4.34e-02(4.42e-03) 4.55e-02(4.63e-03) 4.75e-02(4.84e-03)
#> 5 1.60e-02(1.63e-03) 1.67e-02(1.70e-03) 1.75e-02(1.78e-03)
#> 6 5.87e-03(5.99e-04) 6.15e-03(6.27e-04) 6.43e-03(6.56e-04)
#> 7 2.16e-03(2.20e-04) 2.26e-03(2.31e-04) 2.37e-03(2.41e-04)
#> 8 7.95e-04(8.10e-05) 8.33e-04(8.49e-05) 8.70e-04(8.87e-05)
#> 9 2.92e-04(2.98e-05) 3.06e-04(3.12e-05) 3.20e-04(3.26e-05)
#> 10 1.08e-04(1.10e-05) 1.13e-04(1.15e-05) 1.18e-04(1.20e-05)
#> 11 3.96e-05(4.03e-06) 4.15e-05(4.23e-06) 4.33e-05(4.42e-06)
#> 12 1.46e-05(1.48e-06) 1.52e-05(1.55e-06) 1.59e-05(1.63e-06)
#> 13 5.36e-06(5.46e-07) 5.61e-06(5.72e-07) 5.87e-06(5.98e-07)
#> 14 1.97e-06(2.01e-07) 2.06e-06(2.10e-07) 2.16e-06(2.20e-07)
#> 15 7.25e-07(7.39e-08) 7.59e-07(7.74e-08) 7.94e-07(8.09e-08)
#> year
#> age 2003
#> 0 2.71e+00(2.76e-01)
#> 1 9.96e-01(1.02e-01)
#> 2 3.66e-01(3.74e-02)
#> 3 1.35e-01(1.37e-02)
#> 4 4.96e-02(5.06e-03)
#> 5 1.82e-02(1.86e-03)
#> 6 6.71e-03(6.84e-04)
#> 7 2.47e-03(2.52e-04)
#> 8 9.08e-04(9.26e-05)
#> 9 3.34e-04(3.41e-05)
#> 10 1.23e-04(1.25e-05)
#> 11 4.52e-05(4.61e-06)
#> 12 1.66e-05(1.70e-06)
#> 13 6.12e-06(6.24e-07)
#> 14 2.25e-06(2.30e-07)
#> 15 8.28e-07(8.44e-08)
#>
#> units: NA