Skip to contents

Predict Method for rhierMnlRwMixture Objects

Usage

# S3 method for class 'rhierMnlRwMixture'
predict(
  object,
  newdata = NULL,
  type = "DeltaZ+mu",
  burn = 0,
  nsim = 10,
  r_verbose = TRUE,
  ...
)

Arguments

object

A fitted rhierMnlRwMixture object.

newdata

Optional list containing data for prediction. Structure depends on type:

  • For type %in% c("DeltaZ", "DeltaZ+mu"): Requires newdata$Z, a matrix with npred rows for prediction units (if model was fit with Z).

  • For type = "posterior_probs": Requires newdata$nlgtdata, a list of length nlgt (original number of units). Each element \\[[i]] must contain $X, the design matrix (T_i*p) x nvar for unit i. Also requires newdata$p, the number of alternatives.

  • For type = "prior_probs": Requires newdata$Z (if model fit with Z, determining npred), newdata$p, and newdata$X (a list of length npred, each element \\[[i]] having the design matrix (T_i*p) x nvar).

type

Type of prediction:

  • "DeltaZ": Expected part-worths of the representative consumer, \(\Delta(Z)\).

  • "DeltaZ+mu": Expected part-worths plus the mean of the unobserved heterogeneity component, \(\Delta(Z) + \mu_j\). Note: for mixtures (ncomp > 1), this uses the mean \(\mu_1\) from the first component.

  • "posterior_probs": Posterior predictive choice probabilities for the original estimation units using stored betadraw.

  • "prior_probs": Prior predictive choice probabilities for new prediction units (based on newdata$Z or the overall mixture if no Z was used). Probabilities are averaged over nsim draws from the heterogeneity mixture distribution per posterior draw.

burn

Integer, number of initial MCMC draws to discard.

nsim

Integer, number of draws from the heterogeneity mixture distribution per posterior draw for type = "prior_probs".

r_verbose

Logical, print progress updates?

...

Additional arguments passed to underlying prediction functions (e.g., mc.cores, verbose for BART DeltaZ predictions via pwbart).

Value

Depends on type:

  • For type %in% c("DeltaZ", "DeltaZ+mu"): 3D array [npred, nvar, ndraws_out] of predicted expected part-worths.

  • For type = "posterior_probs": List of length nlgt. Each element \\[[i]] is a 3D array [T_i, p, ndraws_out] of posterior predictive choice probabilities for unit i.

  • For type = "prior_probs": List of length npred. Each element \\[[i]] is a 3D array [T_i, p, ndraws_out] of prior predictive choice probabilities for prediction unit i.