mrfSampler {bgms} | R Documentation |

## Sample states of the ordinal MRF

### Description

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 variable from a logistic model using the other variable states as predictor variables.

### Usage

```
mrfSampler(
no_states,
no_variables,
no_categories,
interactions,
thresholds,
variable_type = "ordinal",
reference_category,
iter = 1000
)
```

### Arguments

`no_states` |
The number of states of the ordinal MRF to be generated. |

`no_variables` |
The number of variables in the ordinal MRF. |

`no_categories` |
Either a positive integer or a vector of positive
integers of length |

`interactions` |
A symmetric |

`thresholds` |
A |

`variable_type` |
What kind of variables are simulated? Can be a single
character string specifying the variable type of all |

`reference_category` |
An integer vector of length |

`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 |

### Details

There are two modeling options for the category thresholds. The default option assumes that the category thresholds are free, except that the first threshold is set to zero for identification. The user then only needs to specify the thresholds for the remaining response categories. This option is useful for any type of ordinal variable and gives the user the most freedom in specifying their model.

The Blume-Capel option is specifically designed for ordinal variables that have a special type of reference_category category, such as the neutral category in a Likert scale. The Blume-Capel model specifies the following quadratic model for the threshold parameters:

`\mu_{\text{c}} = \alpha \times \text{c} + \beta \times (\text{c} - \text{r})^2,`

where `\mu_{\text{c}}`

is the threshold for category c
(which now includes zero), `\alpha`

offers a linear trend
across categories (increasing threshold values if
`\alpha > 0`

and decreasing threshold values if
`\alpha <0`

), if `\beta < 0`

, it offers an
increasing penalty for responding in a category further away from the
reference_category category r, while `\beta > 0`

suggests a
preference for responding in the reference_category category.

### Value

A `no_states`

by `no_variables`

matrix of simulated states of
the ordinal MRF.

### Examples

```
# Generate responses from a network of five binary and ordinal variables.
no_variables = 5
no_categories = sample(1:5, size = no_variables, replace = TRUE)
Interactions = matrix(0, nrow = no_variables, ncol = no_variables)
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_variables, ncol = max(no_categories))
x = mrfSampler(no_states = 1e3,
no_variables = no_variables,
no_categories = no_categories,
interactions = Interactions,
thresholds = Thresholds)
# Generate responses from a network of 2 ordinal and 3 Blume-Capel variables.
no_variables = 5
no_categories = 4
Interactions = matrix(0, nrow = no_variables, ncol = no_variables)
Interactions[2, 1] = Interactions[4, 1] = Interactions[3, 2] =
Interactions[5, 2] = Interactions[5, 4] = .25
Interactions = Interactions + t(Interactions)
Thresholds = matrix(NA, no_variables, no_categories)
Thresholds[, 1] = -1
Thresholds[, 2] = -1
Thresholds[3, ] = sort(-abs(rnorm(4)), decreasing = TRUE)
Thresholds[5, ] = sort(-abs(rnorm(4)), decreasing = TRUE)
x = mrfSampler(no_states = 1e3,
no_variables = no_variables,
no_categories = no_categories,
interactions = Interactions,
thresholds = Thresholds,
variable_type = c("b","b","o","b","o"),
reference_category = 2)
```

*bgms*version 0.1.3.1 Index]