easybgm {easybgm}R Documentation

Fit a Bayesian analysis of networks

Description

Easy estimation of a Bayesian analysis of networks to obtain conditional (in)dependence relations between variables in a network.

Usage

easybgm(
  data,
  type,
  package = NULL,
  not_cont = NULL,
  iter = 10000,
  save = FALSE,
  centrality = FALSE,
  progress = TRUE,
  posterior_method = "model-averaged",
  ...
)

Arguments

data

An n x p matrix or dataframe containing the variables for n independent observations on p variables.

type

What is the data type? Options: continuous, mixed, ordinal, binary

package

The R-package that should be used for fitting the network model; supports BGGM, BDgraph, and bgms. Optional argument; default values are specified depending on the datatype.

not_cont

If data-type is mixed, a vector of length p, specifying the not-continuous variables (1 = not continuous, 0 = continuous).

iter

number of iterations for the sampler.

save

Logical. Should the posterior samples be obtained (default = FALSE)?

centrality

Logical. Should the centrality measures be extracted (default = FALSE)? Note, that it will significantly increase the computation time.

progress

Logical. Should a progress bar be shown (default = TRUE)?

posterior_method

Determines how the posterior samples of the edge weight parameters are obtained for models fit with BDgraph. The argument can be either MAP for the maximum-a-posteriori or model-averaged. If MAP, samples are obtained for the edge weights only for the most likely structure. If model-averaged, samples are obtained for all plausible structures weighted by their posterior probability. Default is model-averaged.

...

Additional arguments that are handed to the fitting functions of the packages, e.g., informed prior specifications.

Details

Users may oftentimes wish to deviate from the default, usually uninformative, prior specifications of the packages to informed priors. This can be done by simply adding additional arguments to the easybgm function. Depending on the package that is running the underlying network estimation, researcher can specify different prior arguments. We give an overview of the prior arguments per package below.

bgms:

BDgraph:

BGGM:

We would always encourage researcher to conduct prior robustness checks.

Value

The returned object of easybgm contains several elements:

In addition, for BDgraph and bgms, the function returns:

For all packages, when setting save = TRUE and centrality = TRUE, the function will return the following objects respectively:

Examples



library(easybgm)
library(bgms)

data <- na.omit(Wenchuan)

# Fitting the Wenchuan PTSD data

fit <- easybgm(data, type = "continuous",
                iter = 1000 # for demonstration only (> 5e4 recommended)
                )

summary(fit)


# To extract the posterior parameter distribution
# and centrality measures

fit <- easybgm(data, type = "continuous",
                iter = 1000, # for demonstrative purposes, generally, 1e5 iterations are recommended
                save = TRUE,
                centrality = TRUE)


[Package easybgm version 0.1.2 Index]