Description Usage Arguments Details Slots Methods Examples
This class stores data that may contain interventions on some or all of the observations. It also allows for the degenerate case with no interventions, i.e. purely observational data.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | sparsebnData(x, ...)
is.sparsebnData(x)
## S3 method for class 'data.frame'
sparsebnData(x, type, levels = NULL, ivn = NULL,
...)
## S3 method for class 'matrix'
sparsebnData(x, type, levels = NULL, ivn = NULL, ...)
## S3 method for class 'sparsebnData'
print(x, n = 5L, ...)
## S3 method for class 'sparsebnData'
summary(object, n = 5L, ...)
## S3 method for class 'sparsebnData'
plot(x, ...)
|
x |
a |
... |
(optional) additional arguments. |
type |
either ' |
levels |
(optional) |
ivn |
(optional) |
n |
(optional) number of rows from data matrix to print. |
object |
an object of type |
The structure of a sparsebnData
object is very simple: It contains a
data.frame
object, a type identifier (i.e. discrete or continuous),
a list of factor levels, and a list of interventions.
The levels
list should be the same size as the number of nodes
and consist of names of the different levels for each node. Each level should
be coded to be from 0...k-1 where k is the number of levels for a
particular variable (see below for more).
The ivn
list should be the same size as the number of rows in
the dataset, and each component indicates which column(s) in the dataset is
(are) under intervention. If an observation has no interventions, then the
corresponding component is NULL
. Thus, if the data is purely
observational, this list should contain only NULL
values.
Presently, only levels coded as 0,1,...,k-1 are supported (k = the number of levels for a variable). Future releases are planned to support more general factor levels. The level 0 corresponds to the baseline level or measurement.
Also inherits from list
.
data
(data.frame
) Dataset.
type
(character
) Type of data: Either "continuous", "discrete", or "mixed".
levels
(list
) List of levels for each column in data
.
ivn
(list
) List of columns under intervention for each row in data
.
print
num.samples
is.obs
count.levels
count.interventions
as.data.frame
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | ### Generate a random continuous dataset
mat <- matrix(rnorm(1000), nrow = 20)
dat <- sparsebnData(mat, type = "continuous") # purely observational data with continuous variables
### Discrete data
mat <- rbind(c(0,2,0),
c(1,1,0),
c(1,0,3),
c(0,1,0))
dat.levels <- list(c(0,1), c(0,1,2), c(0,1,2,3))
dat <- sparsebnData(mat,
type = "discrete",
levels = dat.levels) # purely observational data with discrete variables
dat.ivn <- list(c(1), # first observation was intervened at node 1
c(1), # second observation was intervened at node 1
c(2,3), # third observation was intervened at nodes 2 and 3
c(1,3)) # fourth observation was intervened at nodes 1 and 3
dat <- sparsebnData(mat,
type = "discrete",
levels = dat.levels,
ivn = dat.ivn) # specify intervention rows
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.