View source: R/prior_belief_var.R
prior_belief_var | R Documentation |
Prior Belief Graphical VAR
prior_belief_var(
Y,
prior_temporal = NULL,
post_odds_cut = 3,
est_ggm = TRUE,
prior_ggm = NULL,
progress = TRUE,
...
)
Y |
Matrix (or data frame) of dimensions n (observations) by p (variables/nodes). |
prior_temporal |
Matrix of dimensions p by p,
encoding the prior odds for including each relation
in the temporal graph (see ' |
post_odds_cut |
Numeric. Threshold for including an edge (defaults to 3).
Note |
est_ggm |
Logical. Should the contemporaneous network be estimated
(defaults to |
prior_ggm |
Matrix of dimensions p by p, encoding the prior
odds for including each relation in the graph
(see ' |
progress |
Logical. Should a progress bar be included
(defaults to |
... |
Additional arguments passed to |
Technically, the prior odds is not for including an edge in the graph,
but for (H1)/p(H0), where H1 captures the hypothesized edge size and H0 is the
null model \insertCite@see Williams2019_bfBGGM. Accordingly, setting an
entry in prior_ggm
to, say, 10, encodes a prior belief that H1 is 10 times
more likely than H0. Further, setting an entry in prior_ggm
or
prior_var
to 1 results in equal prior odds
(the default in select.explore
).
An object including (est_ggm = FALSE
):
adj: Adjacency matrix
post_prob: Posterior probability for the alternative hypothesis.
An object including (est_ggm = TRUE
):
adj_temporal: Adjacency matrix for the temporal network.
post_prob_temporal: Posterior probability for the alternative hypothesis (temporal edge)
adj_ggm: Adjacency matrix for the contemporaneous network (ggm).
post_prob_ggm: Posterior probability for the alternative hypothesis (contemporaneous edge)
The returned matrices are formatted with the rows indicating
the outcome and the columns the predictor. Hence, adj_temporal[1,4] is the temporal
relation of node 4 predicting node 1. This follows the convention of the
vars package (i.e., Acoef
).
Further, in order to compute the Bayes factor the data is standardized (mean = 0 and standard deviation = 1).
# affect data from 1 person
# (real data)
y <- na.omit(subset(ifit, id == 1)[,2:7])
p <- ncol(y)
# random prior graph
# (dont do this in practice!!)
prior_var = matrix(sample(c(1,10),
size = p^2, replace = TRUE),
nrow = p, ncol = p)
# fit model
fit <- prior_belief_var(y,
prior_temporal = prior_var,
post_odds_cut = 3)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.