constrainProcess: Matrix Constraining Process

View source: R/constrainProcess.R

constrainProcessR Documentation

Matrix Constraining Process

Description

Generates matrix X which maps constrained masses β to observed masses y for an individual sample component, when given a linear system of constraining equations.

Usage

constrainProcess(C = NULL, file = FALSE)

Arguments

C

Matrix of constraints for a process at steady state. See Details below.

file

Character string indicating file path for a *.csv file containing linear constraints. Only values of -1, 0, and 1 are valid. The first row in the file is required to be a header naming the sampling locations. See Details for an example.

Details

The output of this function is meant to be used as the input parameter X in the BMB function. The matrix C, or imported matrix from file, indexes sampling locations via columns, and number of constraints via rows. Only values of -1, 0, and 1 are valid, and indicate mass leaving a node, a location that is not relevant to a node, and mass entering a node respectively. Constraints should only be indicated around each node. No additional, and no less constraints should be specified. Additional constraints are redundant. Each sample component is subject to the same constraints, and therefore the constraints given to constrainProcess do not need to be repeated for each component.

See vignette("Two_Node_Process") for an application example.

The file path of a *.csv file, which could be used to indicate the constraints for the process in vignette("Two_Node_Process"), can be found by typing system.file("extdata", "twonode_constraints.csv",package = "BayesMassBal"), and can be used as a template for other processes.

Value

Returns the matrix X which maps β to observed masses y. No changes need to be made to X when using with BMB.

Examples


## For a single node process where
## y_1 = y_2 + y_3

C <- matrix(c(1,-1,-1), nrow=  1,ncol = 3)
constrainProcess(C = C)

## For a 2 node process with 1 input and 3 outputs
## as shown in \dontrun{vignette("Two_Node_Process", package = "BayesMassBal")}

C <- matrix(c(1,-1,0,-1,0,0,1,-1,0,-1), byrow = TRUE, ncol = 5, nrow = 2)
constrainProcess(C = C)

## Obtaining the constraints from a .csv file

C <- constrainProcess(file =
 system.file("extdata", "twonode_constraints.csv",package = "BayesMassBal"))


BayesMassBal documentation built on June 18, 2022, 1:08 a.m.