Set initial conditions in a network model

set_init(nm, data, comp, size, prop, group_by = NULL)

Arguments

nm

A networkModel object (e.g. output from new_networkModel)

data

A tibble containing the initial conditions

comp

String, name of the data column with the compartment names

size

String, name of the data column with the compartment sizes

prop

String, name of the data column with the compartment proportions of marked tracer

group_by

Optional vector of string giving the names of the columns to use for grouping the data into replicates

Value

A networkModel object.

Examples

# Using the topology from the Trinidad case study
m <- new_networkModel() %>%
  set_topo("NH4, NO3 -> epi, FBOM", "epi -> petro, pseph",
           "FBOM -> tricor", "petro, tricor -> arg")
#> Using default distribution family for proportions ("gamma_cv").
#>   (eta is the coefficient of variation of gamma distributions.)
#> Using default distribution family for sizes ("normal_cv").
#>   (zeta is the coefficient of variation of normal distributions.)

# Taking initial condtions from the 'lalaja' dataset at t=0
inits <- lalaja[lalaja[["time.days"]] == 0, ]
inits
#> # A tibble: 24 × 6
#> # Groups:   stream, transect [3]
#>    stream transect   compartment mgN.per.m2 prop15N time.days
#>    <chr>  <chr>      <chr>            <dbl>   <dbl>     <dbl>
#>  1 UL     transect.1 NH4              0.300 0.0240          0
#>  2 UL     transect.1 NO3             31.5   0.00397         0
#>  3 UL     transect.2 NH4              0.300 0.0140          0
#>  4 UL     transect.2 NO3             31.5   0.00407         0
#>  5 UL     transect.3 NH4              0.300 0.00694         0
#>  6 UL     transect.3 NO3             31.5   0.00413         0
#>  7 UL     transect.1 arg              2.31  0.00366         0
#>  8 UL     transect.2 arg              2.31  0.00366         0
#>  9 UL     transect.3 arg              2.31  0.00366         0
#> 10 UL     transect.1 epi            329.    0.00366         0
#> # ℹ 14 more rows
m <- set_init(m, inits, comp = "compartment", size = "mgN.per.m2",
              prop = "prop15N", group_by = "transect")
m
#> # A tibble: 3 × 5
#>   topology           initial          observations parameters        group    
#>   <list>             <list>           <list>       <list>            <list>   
#> 1 <topology [8 × 8]> <tibble [8 × 3]> <NULL>       <tibble [19 × 2]> <chr [1]>
#> 2 <topology [8 × 8]> <tibble [8 × 3]> <NULL>       <tibble [19 × 2]> <chr [1]>
#> 3 <topology [8 × 8]> <tibble [8 × 3]> <NULL>       <tibble [19 × 2]> <chr [1]>