The “stan_polr” Function in R

  • Package: rstanarm

  • Purpose: Fits a Bayesian ordered logistic or probit regression model using Stan.

  • General class: Modeling

  • Required argument(s):

    • formula: The model formula specifies the response variable and predictors.

    • data: The data frame containing the variables in the formula.

    • prior: The prior distribution for the coefficients (can be set to null for a uniform prior).

  • Notable optional arguments:

    • method: The link function to be used (e.g., “logistic”, “probit”, “cloglog”).

    • chains: The number of Markov chains to run (default is 4).

    • iter: The number of iterations for each chain (default is 2,000).

    • seed: An optional seed for reproducibility.

  • Example:

  • # Load the rstanarm library
    library(rstanarm)

    # Fit a Bayesian ordered logistic regression model
    model <- stan_polr(Species ~ Petal.Width + Sepal.Width, data = iris[1:100,], prior = NULL, method = "logistic")

    # Print model summary
    summary(model)

  • This example demonstrates how to fit a Bayesian ordered logistic regression model using the stan_polr function from the rstanarm package. The formula specifies the model structure, the data argument provides the dataset, and optional arguments like method, prior (if not used it needs to be null), chains, iter, and seed can be adjusted for customization.

Previous
Previous

The “stan_betareg” Function in R

Next
Next

The “stan_glmer” Function in R