postBeta: Draw from Posterior Distribution for Beta Parameters

View source: R/posteriors.R

postBetaR Documentation

Draw from Posterior Distribution for Beta Parameters

Description

In our model, mui follows a normal distribution with mean X_{i}^{T} \beta + b_{i} and precision tau_i. Additionally, we assume that beta follows a multivariate normal prior with mean 0 and precision rhoBeta \cdot I. This function draws from the posterior distribution of beta under these assumptions.

Usage

postBeta(rhoBeta = 0.01, X, b, m, tau, indFirst)

Arguments

rhoBeta

A scalar representing the prior precision parameter for beta.

X

A matrix of covariates, where each row represents a cycle and each column represents a covariate.

b

A vector where each element is the random effect/intercept for individual i.

m

A vector of observed means (mui) for each cycle.

tau

A vector where each element is the precision for individual i (length = number of individuals).

indFirst

An logical vector (length = number of individuals); each entry is TRUE if this is the first cycle for that individual in the vector of observations. Used to identify submatrices of X and m.

Details

For each individual, the function extracts the relevant rows of X and m using indFirst, and multiplies by the individual's precision tau[i]. It then computes the updated posterior precision and mean for beta and returns a sample from the resulting multivariate normal distribution. Requires the mvtnorm package.

Value

A numeric vector representing a draw from the posterior distribution of beta parameters.


skipTrack documentation built on Sept. 10, 2025, 10:27 a.m.