aggregation {gmgm} | R Documentation |
Aggregate particles to obtain inferred values
Description
This function aggregates particles to obtain inferred values. Assuming that
the particles have been propagated to a given time slice t
, the
weighted average of the samples is computed to estimate the state of the
system at t
or at previous time slices (Koller and Friedman, 2009).
Usage
aggregation(part, nodes, col_seq = NULL, col_weight = "weight", lag = 0)
Arguments
part |
A data frame containing the particles propagated to time slice
|
nodes |
A character vector containing the inferred nodes. |
col_seq |
A character vector containing the column names of |
col_weight |
A character string corresponding to the column name of
|
lag |
A non-negative integer vector containing the time lags |
Value
If lag
has one element, a data frame (tibble) containing the
aggregated values of the inferred nodes and their observation sequences (if
col_seq
is not NULL
). If lag
has two or more elements, a
list of data frames (tibbles) containing these values for each time lag.
References
Koller, D. and Friedman, N. (2009). Probabilistic Graphical Models: Principles and Techniques. The MIT Press.
See Also
Examples
library(dplyr)
set.seed(0)
data(gmdbn_air, data_air)
evid <- data_air %>%
group_by(DATE) %>%
slice(1:3) %>%
ungroup()
evid$NO2[sample.int(150, 30)] <- NA
evid$O3[sample.int(150, 30)] <- NA
evid$TEMP[sample.int(150, 30)] <- NA
evid$WIND[sample.int(150, 30)] <- NA
aggreg <- particles(data.frame(DATE = unique(evid$DATE))) %>%
propagation(gmdbn_air, evid, col_seq = "DATE", n_times = 3) %>%
aggregation(c("NO2", "O3", "TEMP", "WIND"), col_seq = "DATE", lag = c(0, 1))