Package 'StatRec'

Title: A Statistical Method for Multi-Item Rating and Recommendation Problems
Description: Implements the methodological developments found in Hermes (2025) <doi:10.48550/arXiv.2503.02786>, and allows for the statistical modeling of data consisting of multiple users that provide an ordinal rating for one or multiple items.
Authors: Sjoerd Hermes [aut, cre]
Maintainer: Sjoerd Hermes <[email protected]>
License: GPL-3
Version: 1.0.0
Built: 2026-05-12 09:50:57 UTC
Source: https://github.com/cran/StatRec

Help Index


model

Description

This function applies the proposed method of Hermes (2025) on a given set of ratings, user covariates and item covariates. This implementation allows for the same flexibility as in the Hermes (2025) paper, namely linear and bilinear predictors, sparsity and latent factors. Returns posterior samples for the parameter estimates and posterior predictive samples for the missing ratings.

Usage

model(X, Y, R, k, l, method, sparse, mcmc_samples, burnin, verbose)

Arguments

X

A n×pn \times p user covariate matrix, where nn is the number of users and pp is the number of user covariates.

Y

A m×qm \times q item covariate matrix, where mm is the number of items and qq is the number of item covariates.

R

A n×mn \times m rating matrix, where missing ratings are encoded as 0 and observed ratings are encoded to be in {1,,k}\{1,\ldots,k\}.

k

Integer value indicating the maximum rating that a user can provide.

l

Number of latent factors.

method

Method choice, either linear or bilinear.

sparse

Boolean value indicating whether sparsity should be imposed on B\mathbf{B} (TRUE) or not (FALSE).

mcmc_samples

Total number of Gibbs samples.

burnin

Number of Gibbs samples that are used as burnin.

verbose

Boolean value indicating whether parameter estimation progress is returned (TRUE) or not (FALSE).

Value

B_hat

A p×q×p \times q \times (mcmc_samples - burnin) array consisting of the post-burnin samples for the coefficients of the user and item covariates.

U_hat

A n×l×n \times l \times (mcmc_samples - burnin) array consisting of the post-burnin samples for the user latent factors (only applicable if l>0l > 0).

V_hat

A m×l×m \times l \times (mcmc_samples - burnin) array consisting of the post-burnin samples for the item latent factors (only applicable if l>0l > 0).

R_hat

A n×m×n \times m \times (mcmc_samples - burnin) array consisting of the post-burnin posterior predictive samples for the missing ratings.

Author(s)

Sjoerd Hermes
Maintainer: Sjoerd Hermes [email protected]

References

1. Hermes, S. (2025). A Statistical Interpretation of Multi-Item Rating and Recommendation Problems. arXiv preprint, arXiv:2503.02786.

Examples

# Set parameters
n = m = 15
p = q = 3
method = "linear"
k = 5
l = 1
sparse = TRUE

# Generate some data
# this is completely random, and there is no relation between the ratings
# and the covariates or latent factors
set.seed(2025)  
r = matrix(rbinom(n*m, k, 0.3), n, m)
X = matrix(rnorm(n * p), n, p)
Y = matrix(rnorm(m * q), m, q)

# Fit the model on the data
est = model(X, Y, r, k, l, method, sparse, mcmc_samples = 2000, burnin = 1000, TRUE)