postBeta | R Documentation |
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.
postBeta(rhoBeta = 0.01, X, b, m, tau, indFirst)
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 |
m |
A vector of observed means ( |
tau |
A vector where each element is the precision for individual |
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. |
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.
A numeric vector representing a draw from the posterior distribution of beta parameters.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.