Create Foodweb model object
fw_problem.Rd
Create an object of class fw_problem
that can be used for interaction
inference.
Arguments
- A
interaction matrix. A square matrix describing interactions of the system (see details). If
NULL
,A
is derived fromU
.- B
biomass vector.
- R
reproduction/mortality vector.
- U
unknown interactions. A data frame that includes the position of unknown/known interactions. If
NULL
,U
is derived fromA
.- sdB
vector of standard deviation biomass (see
limSolve::xsample()
).- x
an R object.
- ...
extra arguments (ignored so far, might be use to custom xsample at some point).
Value
An object of class fw_problem
which is a named list of 7 elements:
A: interaction matrix
B: biomass vector
R: mortality rate vector
U: unknown interaction(s)
SdB: biomass variation
model: the underlying model
Details
In most cases, only A
needs to be defined and should include:
1 when interactions are present and positive,
-1 when interactions are present and negative,
0 otherwise.
U
will be generated according to these values.A
may however includes known interactions, in such case,U
needs to be defined and must includes all known interactions (unknown interactions will be identified usingA
). It is also possible to only declareU
, in this case the dimension of A and its coefficients will be derived fromU
.U
has a strict format, namely a data frame with 5 columns:name
: interaction name, whenU
is created fromA
name isa_i_j
wherei
is the row number andj
the column number,row
: row number,col
: column number,unknown
: a logical vector that identifies unknown and known interactions,value
: interaction value, only the sign matter for unknown interactions, The order does not matter as the columns are ordered during the validation step.
Examples
A <- rbind(c(-1, -1), c(1, 0))
R <- c(0.1, -0.05)
B <- c(0.5, 0.25)
fw_problem(A, B, R)
#> $A
#> [,1] [,2]
#> [1,] -1 -1
#> [2,] 1 0
#>
#> $B
#> [1] 0.50 0.25
#>
#> $R
#> [1] 0.10 -0.05
#>
#> $U
#> row col unknown value name
#> 1 1 1 TRUE -1 a_1_1
#> 2 2 1 TRUE 1 a_2_1
#> 3 1 2 TRUE -1 a_1_2
#>
#> $sdB
#> NULL
#>
#> $model
#> function (t, y, pars)
#> {
#> return(list((pars$A %*% y + pars$R) * y))
#> }
#> <bytecode: 0x55d8a1a71cd0>
#> <environment: namespace:fwebinfr>
#>
#> attr(,"class")
#> [1] "fw_problem"