model: model

View source: R/RcppExports.R

modelR Documentation

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 \times p user covariate matrix, where n is the number of users and p is the number of user covariates.

Y

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

R

A n \times m rating matrix, where missing ratings are encoded as 0 and observed ratings are encoded to be in \{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 \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 \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 \times l \times (mcmc_samples - burnin) array consisting of the post-burnin samples for the user latent factors (only applicable if l > 0).

V_hat

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

R_hat

A 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 sjoerd.hermes@wur.nl

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)

StatRec documentation built on April 3, 2025, 5:27 p.m.

Related to model in StatRec...