marg | R Documentation |
Marginalize a sparse table given a vector of variables to marginalize out
marg(x, y, flow = "sum") ## S3 method for class 'sparta' marg(x, y, flow = "sum") ## S3 method for class 'numeric' marg(x, y, flow = "sum")
x |
sparta object or a numeric. If numeric, the value is just returned. |
y |
character vector of the variables to marginalize out |
flow |
either "sum" or "max" |
A sparta object (or scalar if all variables are summed out)
x <- array( c(1,0,0,2,3,4,0,0), dim = c(2,2,2), dimnames = list( a = c("a1", "a2"), b = c("b1", "b2"), c = c("c1", "c2") ) ) sx <- as_sparta(x) marg(sx, c("c")) su <- sparta_unity_struct(dim_names(sx), rank = 3.14) marg(su, c("a", "b"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.