rosalia: Fit a Markov network to binary data

Description Usage Arguments Value Examples

Description

The optimization is performed using the BFGS method in the optim function. Note that the likelihood function includes 2^N terms for N nodes, so parameter estimation can be very slow with more than about 20-25 nodes.

Usage

1
2
rosalia(x, prior = make_logistic_prior(location = 0, scale = 1),
  maxit = 100, trace = 1, hessian = FALSE, parlist, ...)

Arguments

x

A binary matrix. Each row corresponds to an observed sample and each column corresponds to one node in the observed network.

prior

An object of class prior. The default prior, produced by make_logistic_prior, regularizes the parameter estimates. This is important in Markov networks because the number of parameters will often be large compared to the number of independent observations. The flat prior produced by make_logistic_prior is unbiased, but can result in unbounded estimates if two nodes always share the same state in the data set.

maxit, trace, hessian, ...

Arguments passed to optim

parlist

user-specified starting values (optional).

Value

a list with the following elements:

alpha

A vector of estimated univariate potentials ("intercepts"). Larger values support higher probabilities for the corresponding node.

beta

A symmetric matrix of bivariate potentials ("interaction strengths"). Larger values support higher probabilities for the corresponding pair of nodes.

prior

The prior object that was used during model fitting.

opt

The list returned by optim.

Examples

1
2
3
4
5
6
7
# Simulate a random binary matrix with 1000 observations of five binary variables
m = matrix(rbinom(5000, size = 1, prob = .5), nrow = 1000, ncol = 5)

fit = rosalia(m)

fit$alpha
fit$beta

davharris/rosalia documentation built on May 14, 2019, 9:29 p.m.