Note that new global parameters are not given any default prior.

add_covariates(nm, ..., use_regexpr = TRUE)

Arguments

nm

A networkModel object.

...

One or several formulas defining the covariates.

use_regexpr

Boolean, use regular expression to match the parameters affected by the formulas?

Value

A networkModel object.

Examples

# Using a subset of the topology from the Trinidad case study
m <- new_networkModel() %>%
  set_topo("NH4, NO3 -> epi, FBOM", "epi -> petro, pseph")
#> 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
# Grouping by transect id
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")
#> Some compartments are not present in the network topology and are
#> removed from the initial data:
#>   - arg
#>   - tricor
m
#> # A tibble: 3 × 5
#>   topology           initial          observations parameters        group    
#>   <list>             <list>           <list>       <list>            <list>   
#> 1 <topology [6 × 6]> <tibble [6 × 3]> <NULL>       <tibble [14 × 2]> <chr [1]>
#> 2 <topology [6 × 6]> <tibble [6 × 3]> <NULL>       <tibble [14 × 2]> <chr [1]>
#> 3 <topology [6 × 6]> <tibble [6 × 3]> <NULL>       <tibble [14 × 2]> <chr [1]>

# Default model
params(m, simplify = TRUE)
#>  [1] "eta"                  "lambda_FBOM"          "lambda_NH4"          
#>  [4] "lambda_NO3"           "lambda_epi"           "lambda_petro"        
#>  [7] "lambda_pseph"         "upsilon_NH4_to_FBOM"  "upsilon_NH4_to_epi"  
#> [10] "upsilon_NO3_to_FBOM"  "upsilon_NO3_to_epi"   "upsilon_epi_to_petro"
#> [13] "upsilon_epi_to_pseph" "zeta"                

# Adding an effect of the "transect" covariate on some parameters
m <- add_covariates(m, upsilon_epi_to_pseph ~ transect)
params(m, simplify = TRUE)
#>  [1] "eta"                             "lambda_FBOM"                    
#>  [3] "lambda_NH4"                      "lambda_NO3"                     
#>  [5] "lambda_epi"                      "lambda_petro"                   
#>  [7] "lambda_pseph"                    "upsilon_NH4_to_FBOM"            
#>  [9] "upsilon_NH4_to_epi"              "upsilon_NO3_to_FBOM"            
#> [11] "upsilon_NO3_to_epi"              "upsilon_epi_to_petro"           
#> [13] "upsilon_epi_to_pseph|transect.1" "upsilon_epi_to_pseph|transect.2"
#> [15] "upsilon_epi_to_pseph|transect.3" "zeta"