Skip to contents

Create an object of class fw_problem that can be used for interaction inference.

Usage

fw_problem(A, B, R, U = NULL, sdB = NULL)

fw_as_problem(x, ...)

Arguments

A

interaction matrix. A square matrix describing interactions of the system (see details). If NULL, A is derived from U.

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 from A.

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 using A). It is also possible to only declare U, in this case the dimension of A and its coefficients will be derived from U. U has a strict format, namely a data frame with 5 columns:

  • name: interaction name, when U is created from A name is a_i_j where i is the row number and j 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.

Functions

  • fw_as_problem(): Coerce an object to an object of class fw_problem.

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"