mrf_penalty.factor: Fully connected graph and random effect MRF penalties from a...

mrf_penalty.factorR Documentation

Fully connected graph and random effect MRF penalties from a factor

Description

Fully connected graph and random effect MRF penalties from a factor

Usage

## S3 method for class 'factor'
mrf_penalty(
  object,
  type = c("full", "individual"),
  node_labels = NULL,
  add_delta = FALSE,
  ...
)

Arguments

object

an R object to create the MRF penalty from.

type

character; one of "full" or "individual" indicating if a fully connected graph ("full") or a random effect (random intercepts; "individual") penalty is created.

node_labels

character; a vector of alternative labels for the levels of the factor.

add_delta

numeric or logical; either the numeric value to add to the diagonal of the MRF penalty matrix, or a logical value indicating if such an adjustment should be made. The default is to not alter the diagonal of the penalty matrix.

...

arguments passed to other methods.

Examples

# a factor
fv <- factor(letters[1:10])

# create the MRF penalty for a fully connected graph
p <- mrf_penalty(fv, type = "full")
p
as.matrix(p)

# create the MRF penalty equivalent of random effects
p <- mrf_penalty(fv, type = "individual")
p
as.matrix(p)

eric-pedersen/MRFtools documentation built on Jan. 28, 2024, 2:13 a.m.