Skip to contents

Fit a Cumulative Link Model using CmdStanR

Usage

clm_stan(
  formula,
  data,
  link = "logit",
  base = "logit",
  threshold = "flexible",
  link_param = NULL,
  prior = NULL,
  chains = 4,
  iter = 2000,
  warmup = NULL,
  ...
)

Arguments

formula

A formula specifying the model (response ~ predictors)

data

A data frame containing the variables in the formula

Link function. One of "logit" (default), "probit", "cloglog", "loglog", "cauchit", "tlink", "gev", "aep", "sp", "aranda_ordaz", "log_gamma"

base

Base distribution for SP link. One of "logit" (default), "probit", "cloglog", "loglog", "cauchit", "tlink". Ignored for other link functions.

threshold

Threshold structure. One of "flexible" (default), "equidistant", "symmetric"

A list of link parameters. For flexible links, values can be:

  • Numeric: Use as fixed value (e.g., list(df = 8))

  • "estimate": Estimate the parameter with Bayesian inference

prior

Prior specification. Can be either:

chains

Number of MCMC chains (default: 4)

iter

Total iterations per chain (default: 2000)

warmup

Warmup iterations per chain. If NULL (default), uses floor(iter/2)

...

Additional arguments passed to cmdstanr::sample()

Value

An object of class "clmstan"

Examples

if (FALSE) { # \dontrun{
# Fit a proportional odds model
library(ordinal)
data(wine)
fit <- clm_stan(rating ~ temp + contact, data = wine, link = "logit")
print(fit)

# Fit with t-link (fixed df)
fit_t <- clm_stan(rating ~ temp, data = wine, link = "tlink",
                  link_param = list(df = 8))

# Fit with GEV link (estimate xi)
fit_gev <- clm_stan(rating ~ temp, data = wine, link = "gev",
                    link_param = list(xi = "estimate"))
} # }