Method to simulate multivariate normal parameters for an a4aM object.

# S4 method for numeric,a4aM,missing,missing,missing,missing
mvrnorm(n = 1, mu)

Arguments

n

the number of iterations to be generated

mu

an a4aM object

Value

an a4aM object with n iterations

Examples

mod1 <- FLModelSim(model=~exp(-age-0.5))
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.003), dim=c(2,2,2)))
mod3 <- FLModelSim(model=~1+b*v, params=FLPar(b=0.05))
mObj <- a4aM(shape=mod1, level=mod2, trend=mod3,
 range=c(min=0,max=15,minyear=2000,maxyear=2003,minmbar=0,maxmbar=0))
mObj <- mvrnorm(100, mObj)
# Generate 100 iterations with no trend over time
  m(mObj, v=c(1,1,1,1))
#> An object of class "FLQuant"
#> iters:  100 
#> 
#> , , unit = unique, season = all, area = unique
#> 
#>     year
#> age  2000                 2001                 2002                
#>   0  2.3336e+00(3.09e-01) 2.3336e+00(3.09e-01) 2.3336e+00(3.09e-01)
#>   1  8.5850e-01(1.14e-01) 8.5850e-01(1.14e-01) 8.5850e-01(1.14e-01)
#>   2  3.1582e-01(4.18e-02) 3.1582e-01(4.18e-02) 3.1582e-01(4.18e-02)
#>   3  1.1618e-01(1.54e-02) 1.1618e-01(1.54e-02) 1.1618e-01(1.54e-02)
#>   4  4.2742e-02(5.66e-03) 4.2742e-02(5.66e-03) 4.2742e-02(5.66e-03)
#>   5  1.5724e-02(2.08e-03) 1.5724e-02(2.08e-03) 1.5724e-02(2.08e-03)
#>   6  5.7845e-03(7.66e-04) 5.7845e-03(7.66e-04) 5.7845e-03(7.66e-04)
#>   7  2.1280e-03(2.82e-04) 2.1280e-03(2.82e-04) 2.1280e-03(2.82e-04)
#>   8  7.8285e-04(1.04e-04) 7.8285e-04(1.04e-04) 7.8285e-04(1.04e-04)
#>   9  2.8799e-04(3.82e-05) 2.8799e-04(3.82e-05) 2.8799e-04(3.82e-05)
#>   10 1.0595e-04(1.40e-05) 1.0595e-04(1.40e-05) 1.0595e-04(1.40e-05)
#>   11 3.8976e-05(5.16e-06) 3.8976e-05(5.16e-06) 3.8976e-05(5.16e-06)
#>   12 1.4338e-05(1.90e-06) 1.4338e-05(1.90e-06) 1.4338e-05(1.90e-06)
#>   13 5.2748e-06(6.99e-07) 5.2748e-06(6.99e-07) 5.2748e-06(6.99e-07)
#>   14 1.9405e-06(2.57e-07) 1.9405e-06(2.57e-07) 1.9405e-06(2.57e-07)
#>   15 7.1386e-07(9.46e-08) 7.1386e-07(9.46e-08) 7.1386e-07(9.46e-08)
#>     year
#> age  2003                
#>   0  2.3336e+00(3.09e-01)
#>   1  8.5850e-01(1.14e-01)
#>   2  3.1582e-01(4.18e-02)
#>   3  1.1618e-01(1.54e-02)
#>   4  4.2742e-02(5.66e-03)
#>   5  1.5724e-02(2.08e-03)
#>   6  5.7845e-03(7.66e-04)
#>   7  2.1280e-03(2.82e-04)
#>   8  7.8285e-04(1.04e-04)
#>   9  2.8799e-04(3.82e-05)
#>   10 1.0595e-04(1.40e-05)
#>   11 3.8976e-05(5.16e-06)
#>   12 1.4338e-05(1.90e-06)
#>   13 5.2748e-06(6.99e-07)
#>   14 1.9405e-06(2.57e-07)
#>   15 7.1386e-07(9.46e-08)
#> 
#> units:  NA 
# Generate replicates based on iteration-specific multivariate distributions
# (as defined by params() and vcov())
  params(mod2)
#> An object of class "FLPar"
#> iters:  2 
#> 
#> params
#>             k             t 
#>  0.45(0.0741) 10.50(0.7413) 
#> units:  NA NA 
  vcov(mod2)
#> , , 1
#> 
#>       [,1]  [,2]
#> [1,] 0.004 0.000
#> [2,] 0.000 0.001
#> 
#> , , 2
#> 
#>       [,1]  [,2]
#> [1,] 0.006 0.000
#> [2,] 0.000 0.003
#> 
  m1<-mvrnorm(mod2)
  c(params(m1))
#> [1]  0.280260 10.014835  0.439241 10.947385
# Generate replicates based on a single multivariate distribution (here the
# median of params() and vcov() is used)
  mvrnorm(2,mod2)
#> An object of class "FLModelSim"
#> Slot "model":
#> ~k^0.66 * t^0.57
#> <environment: 0x564e054a79d0>
#> 
#> Slot "params":
#> An object of class "FLPar"
#> iters:  2 
#> 
#> params
#>                 k                 t 
#>  0.38762(0.03457) 10.50066(0.00553) 
#> units:  NA NA 
#> 
#> Slot "vcov":
#> numeric(0)
#> 
#> Slot "distr":
#> [1] "norm"
#> 
  m2<-mvrnorm(2,mod2)
  c(params(m2))
#> [1]  0.4611115 10.5530379  0.5033600 10.4705197