mrfSampler {bgms} | R Documentation |
This function samples states from the ordinal MRF using a Gibbs sampler. The Gibbs sampler is initiated with random values from the response options, after which it proceeds by simulating states for each node from a logistic model using the other node states as predictor variables.
mrfSampler(
no_states,
no_nodes,
no_categories,
interactions,
thresholds,
iter = 1000
)
no_states |
The number of states of the ordinal MRF to be generated. |
no_nodes |
The number of nodes in the ordinal MRF. |
no_categories |
Either a positive integer or a vector of positive
integers of length |
interactions |
A symmetric |
thresholds |
A |
iter |
The number of iterations used by the Gibbs sampler.
The function provides the last state of the Gibbs sampler as output. By
default set to |
A no_states
by no_nodes
matrix of simulated states of
the ordinal MRF.
# Generate responses from a network of five binary and ordinal variables.
no_nodes = 5
no_categories = sample(1:5, size = no_nodes, replace = TRUE)
Interactions = matrix(0, nrow = no_nodes, ncol = no_nodes)
Interactions[2, 1] = Interactions[4, 1] = Interactions[3, 2] =
Interactions[5, 2] = Interactions[5, 4] = .25
Interactions = Interactions + t(Interactions)
Thresholds = matrix(0, nrow = no_nodes, ncol = max(no_categories))
x = mrfSampler(no_states = 1e3,
no_nodes = no_nodes,
no_categories = no_categories,
interactions = Interactions,
thresholds = Thresholds)