plot.SMCMallows: Plot SMC Posterior Distributions

View source: R/plot.SMCMallows.R

plot.SMCMallowsR Documentation

Plot SMC Posterior Distributions

Description

Plot posterior distributions of SMC-Mallow parameters.

Usage

## S3 method for class 'SMCMallows'
plot(
  x,
  nmc = nrow(x$rho_samples[, 1, ]),
  burnin = 0,
  parameter = "alpha",
  time = ncol(x$rho_samples[, 1, ]),
  C = 1,
  colnames = NULL,
  items = NULL,
  ...
)

Arguments

x

An object of type SMC-Mallows, returned for example from smc_mallows_new_users.

nmc

Number of Monte Carlo samples

burnin

A numeric value specifying the number of iterations to discard as burn-in. Defaults to model_fit$burnin, and must be provided if model_fit$burnin does not exist. See assess_convergence.

parameter

Character string defining the parameter to plot. Available options are "alpha" and "rho".

time

Integer determining the update slice to plot

C

Number of cluster

colnames

A vector of item names. If NULL, generic names are generated for the items in the ranking.

items

Either a vector of item names, or a vector of indices. If NULL, five items are selected randomly.

...

Other arguments passed to plot (not used).

Value

A plot of the posterior distributions

Author(s)

Waldir Leoncio

See Also

Other posterior quantities: assign_cluster(), compute_consensus.BayesMallows(), compute_consensus.SMCMallows(), compute_consensus(), compute_posterior_intervals.BayesMallows(), compute_posterior_intervals.SMCMallows(), compute_posterior_intervals(), heat_plot(), plot.BayesMallows(), plot_elbow(), plot_top_k(), predict_top_k(), print.BayesMallowsMixtures(), print.BayesMallows()

Examples

set.seed(994)

n_items <- dim(sushi_rankings)[2]
metric <- "footrule"

# Estimate the logarithm of the partition function of the Mallows rank model
logz_estimate <- estimate_partition_function(
  method = "importance_sampling",
  alpha_vector = seq(from = 0, to = 15, by = 0.5), n_items = n_items,
  metric = metric, nmc = 1e2, degree = 10
)

# Perform the resample-move SMC algorithm
smc_test <- smc_mallows_new_users(
  R_obs = sushi_rankings[1:100, ], type = "complete", n_items = n_items,
  metric = metric, leap_size = floor(n_items / 5), N = 100, Time = 10,
  logz_estimate = logz_estimate, mcmc_kernel_app = 5, num_new_obs = 5,
  alpha_prop_sd = 0.5, lambda = 0.15, alpha_max = 1e3
)

# Plot rho
plot(smc_test, colnames = colnames(sushi_rankings), parameter = "rho")

# Plot alpha
plot(smc_test, parameter = "alpha")

BayesMallows documentation built on Nov. 25, 2023, 5:09 p.m.