Set observations in a network model
set_obs(nm, data, comp, size, prop, time, group_by)
A networkModel
object (e.g. output from
new_networkModel
)
A tibble containing the observations. If NULL, remove observations from the model.
String, name of the data
column with the compartment
names
String, name of the data
column with the compartment
sizes
String, name of the data
column with the compartment
proportions of heavy tracer
String, name of the data
column with the sampling times
Optional vector of string giving the names of the columns to use for grouping the data into replicates
A networkModel
object.
# 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]>
# Taking observations from 'lalaja'
m <- set_obs(m, lalaja[lalaja[["time.days"]] > 0, ], time = "time.days")
#> Using the same columns by default as the ones used with `set_init()`:
#> 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]> <tibble [77 × 4]> <tibble [19 × 2]> <chr>
#> 2 <topology [8 × 8]> <tibble [8 × 3]> <tibble [72 × 4]> <tibble [19 × 2]> <chr>
#> 3 <topology [8 × 8]> <tibble [8 × 3]> <tibble [74 × 4]> <tibble [19 × 2]> <chr>
plot(m)