Ovariable Checks

Share:

Description

The Check functions are used to introduce common model specific alterations to variables without changing their definition directly.

Usage

1
2
3
4
5
CheckCollapse(variable, indent = 0, verbose = TRUE, ...)
CheckDecisions(variable, indent = 0, verbose = TRUE, ...)
CheckInput(variable, substitute = FALSE, indent = 0, verbose = TRUE, ...)
CheckMarginals(variable, deps = list(), priormarg = TRUE, indent = 0, 
    verbose = TRUE, ...)

Arguments

variable

an ovariable to run Check on.

deps

the dependency list of a latent ovariable, used by CheckMarginals to keep track of index columns.

priormarg

flag determining whether columns are assumed to be indices by default when checking marginals.

substitute

flag determining whether model inputs should replace or append to current variable values.

indent

used by verbose to structure status messages by using indentation.

verbose

flag status message printing.

...

excess arguments are ignored.

Details

The Check functions are mainly used internally. They check for external instructions (model specific changes); specifically objects in .GlobalEnv with prefixes ("Col", "Dec", "Inp"). they are automated in the normal ovariable evaluation routine (EvalOutput).

CheckCollapse uses CollapseMarginal which collapses marginals by applying sums, means or samples. Also loses all non-marginal columns except the relevant "Result". It is mainly used to streamline models by reducing rows in data.

CheckDecisions checks for and applies decisions on variables. The function makes use of the odecision-class, which specifies the target cells as well as the effect. Odecisions are most often produced by DecisionTableParser.

CheckInput checks and uses outside input (run specific user inputs in models). Input should be in ovariable format.

CheckMarginals fills the marginal slot of an ovariable using information from variable data and upstream variable marginals. Assumes that all depended upon variables are loaded, as should be the case.

See also: http://en.opasnet.org/

Value

Original ovariable with possible adjustments.

Author(s)

T. Rintala teemu.rintala.a@gmail.com

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
#library(OpasnetUtils)
#
Deca <- new(
		"odecision",
		dectable = data.frame(
				Decision = "Dec1",
				Option = c("do it", "BAU"),
				Cell = c("",""),
				Change = c("Multiply", "Identity"),
				Result = c("2", "1")
		)
)
openv.setN(10)
a <- Ovariable("a", data = data.frame(A = c("A", "B"), Result = c("1-2","2-4")))

b <- Ovariable("b", formula = function(...){2*a}, dependencies = data.frame(Name = "a"))

b <- EvalOutput(b)

b
oapply(a, a@output[c("A", "Dec1")], mean)