aggregation | R Documentation |
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).
aggregation(part, nodes, col_seq = NULL, col_weight = "weight", lag = 0)
part |
A data frame containing the particles propagated to time slice
t, as obtained from function |
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 l1, l2, … such that the samples of time slices t - l1, t - l2, … are aggregated. |
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.
Koller, D. and Friedman, N. (2009). Probabilistic Graphical Models: Principles and Techniques. The MIT Press.
aggregation
, particles
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))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.