rater: Fit statistical models to repeated categorical rating data...

View source: R/inference.R

raterR Documentation

Fit statistical models to repeated categorical rating data using Stan

Description

This functions allows the user to fit statistical models of noisy categorical rating, based on the Dawid-Skene model, using Bayesian inference. A variety of data formats and models are supported. Inference is done using Stan, allowing models to be fit efficiently, using both optimisation and Markov Chain Monte Carlo (MCMC).

Usage

rater(
  data,
  model,
  method = "mcmc",
  data_format = "long",
  long_data_colnames = c(item = "item", rater = "rater", rating = "rating"),
  inits = NULL,
  verbose = TRUE,
  ...
)

Arguments

data

A 2D data object: data.frame, matrix, tibble etc. with data in either long or grouped format.

model

Model to fit to data - must be rater_model or a character string - the name of the model. If the character string is used, the prior parameters will be set to their default values.

method

A length 1 character vector, either "mcmc" or "optim". This will be fitting method used by Stan. By default "mcmc"

data_format

A length 1 character vector, "long", "wide" and "grouped". The format that the passed data is in. Defaults to "long". See ⁠vignette("data-formats)⁠ for details.

long_data_colnames

A 3-element named character vector that specifies the names of the three required columns in the long data format. The vector must have the required names: * item: the name of the column containing the item indexes, * rater: the name of the column containing the rater indexes, * rating: the name of the column containing the ratings. By default, the names of the columns are the same as the names of the vector: "item", "rater", and "rating" respectively. This argument is ignored when the data_format argument is either "wide" or "grouped".

inits

The initialization points of the fitting algorithm

verbose

Should rater() produce information about the progress of the chains while using the MCMC algorithm. Defaults to TRUE

...

Extra parameters which are passed to the Stan fitting interface.

Details

The default MCMC algorithm used by Stan is No U Turn Sampling (NUTS) and the default optimisation method is LGFGS. For MCMC 4 chains are run be default with 2000 iterations in total each.

Value

An object of class rater_fit containing the fitted parameters.

See Also

rstan::sampling(), rstan::optimizing()

Examples



# Fit a model using MCMC (the default).
mcmc_fit <- rater(anesthesia, "dawid_skene")

# Fit a model using optimisation.
optim_fit <- rater(anesthesia, dawid_skene(), method = "optim")

# Fit a model using passing data grouped data.
grouped_fit <- rater(caries, dawid_skene(), data_format = "grouped")




rater documentation built on Sept. 12, 2023, 1:13 a.m.