Sample from the posterior (conditional on all other parameters) in the conjugate setting.

conj_norm_mu(y, tau, mu0 = 0, tau0 = 0.001, ..., mult = 1, params.only = FALSE)

conj_mvnorm_mu(
  y,
  Q,
  mu0 = NULL,
  Q0 = diag(0.001, p),
  ...,
  newQ = mult * Q0 + n * Q,
  newQ.chol = gu_chol(newQ),
  mult = 1,
  params.only = FALSE
)

conj_matnorm_mu(
  y,
  V,
  U = NULL,
  mu0 = NULL,
  Q0,
  ...,
  newQ = V %x% U + Q0,
  newQ.chol = gu_chol(newQ),
  diag = FALSE,
  zero = NULL,
  params.only = FALSE
)

conj_lm_beta(
  y,
  X,
  XtX = t(X) %*% X,
  tau,
  mu0 = NULL,
  Q0,
  ...,
  newQ = tau * XtX + Q0,
  newQ.chol = gu_chol(newQ),
  params.only = FALSE
)

conj_matlm_beta(
  y,
  X,
  V,
  U = NULL,
  mu0 = NULL,
  Q0,
  ...,
  XtU = if (is.null(U)) t(X) else t(X) %*% U,
  XtUX = XtU %*% X,
  newQ = V %x% XtUX + Q0,
  newQ.chol = gu_chol(newQ),
  diag = FALSE,
  zero = NULL,
  params.only = FALSE
)

conj_norm_tau(y, mu, a0 = 0.001, b0 = 0.001, params.only = FALSE)

conj_mvnorm_Q(y, mu = NULL, V0, v0, V0_inv = chol_inv(V0), params.only = FALSE)

conj_matnorm_V(
  y,
  mu = NULL,
  U = NULL,
  V0,
  v0,
  ...,
  ytUy = t(ymu) %*% U %*% ymu,
  V0_inv = chol_inv(V0),
  params.only = FALSE
)

conj_lm_tau(
  y,
  X,
  beta,
  Xbeta = X %*% beta,
  a0 = 0.001,
  b0 = 0.001,
  params.only = FALSE
)

conj_binom_p(k, n, a0 = 1, b0 = 1, params.only = FALSE)

conj_gamma_b(x, a, a0, b0, params.only = FALSE)

Arguments

y, x

realizations from the distribution whose parameter is being drawn. For multivariate conjugacy, this is an n-by-p matrix

mu0

the prior mean of mu or beta. The default (NULL) is the same as an appropriately-dimensioned vector/matrix of all zeros, but a little faster.

...

Other arguments. Examples include verbose=, take.chol=, and Rstruct=.

mult

An optional multiplier for the prior precision; useful in some cases

params.only

Should just a list of the updated parameters be returned?

Q, tau

the precision of the (multivariate) normal distribution from which y comes

Q0, tau0

the prior precision of mu.

V, U

the precision matrices for the matrix-normal distribution

diag

If TRUE, both V and Q0 are assumed (but not confirmed!) to be diagonal, which can speed up the Cholesky decomposition up to 100x. Default FALSE.

zero

A matrix of ones and zeros, the same size as the beta to sample. Zero indicates a structural zero in the beta. In the event that this is specified, everything returned is of size sum(zero).

X

the data matrix on beta

XtX, XtU, XtUX, ytUy, V0_inv, Xbeta, newQ, newQ.chol

pre-computed "shortcut" arguments for efficiency reasons

mu

the mean of the normal distribution from which y comes

a0, b0

the parameters (shape and rate) of the gamma distribution prior on tau, or the parameters (shape1 and shape2) of the beta distribution prior on p.

V0, v0

the parameters (matrix and degrees of freedom) of the Wishart prior on Q or V

beta

the coefficients on X

k

The number of successes

n

The number of trials

a

The shape parameter for the gamma distribution