sample_lm_gprior {countSTAR} | R Documentation |
Sample the linear regression parameters assuming a g-prior
Description
Sample the parameters for a linear regression model assuming a g-prior for the coefficients.
Usage
sample_lm_gprior(y, X, params, psi = NULL, XtX = NULL, X_test = NULL)
Arguments
y |
|
X |
|
params |
the named list of parameters containing
|
psi |
the prior variance for the g-prior |
XtX |
the |
X_test |
matrix of predictors at test points (default is NULL) |
Value
The updated named list params
with draws from the full conditional distributions
of sigma
and coefficients
(along with updated mu
and mu_test
if applicable).
Note
The parameters in coefficients
are:
-
beta
: thep x 1
vector of regression coefficients components ofbeta
Examples
# Simulate data for illustration:
sim_dat = simulate_nb_lm(n = 100, p = 5)
y = sim_dat$y; X = sim_dat$X
# Initialize:
params = init_lm_gprior(y = y, X = X)
# Sample:
params = sample_lm_gprior(y = y, X = X, params = params)
names(params)
names(params$coefficients)