Learn R Programming

sdbuildR (version 2.0.0)

summary.stockflow: Run model diagnostics

Description

Check for common formulation problems in a stock-and-flow model.

Usage

# S3 method for stockflow
summary(object, ...)

Value

Object of class summary_stockflow. A flat named list with one entry per check. Each entry contains a problem field ("none", "warning", or "error") and type-specific data fields.

Arguments

object

Stock-and-flow model, object of class stockflow.

...

Additional arguments (currently unused).

Details

The following problems are detected:

  • An absence of stocks

  • Flows without a source (from) or target (to)

  • Flows connected to a stock that does not exist

  • Undefined variable references in equations

  • Circularity in equations

The following potential problems are detected:

  • Absence of flows

  • Stocks without inflows or outflows

  • Equations with a value of 0

Examples

Run this code
# No issues
sfm <- stockflow("SIR")
summary(sfm)

# Detect absence of stocks or flows
sfm <- stockflow()
summary(sfm)

# Detect stocks without inflows or outflows
sfm <- stockflow() |> update("Prey", "stock")
summary(sfm)

# Detect circularity in equation definitions
sfm <- stockflow() |>
  update("Prey", "stock", eqn = "Predator") |>
  update("Predator", "stock", eqn = "Prey")
summary(sfm)

Run the code above in your browser using DataLab