Initialize linear regression parameters assuming a g-prior
Source:R/STAR_Bayesian.R
init_lm_gprior.RdInitialize the parameters for a linear regression model assuming a g-prior for the coefficients.
Arguments
- y
n x 1vector of data- X
n x pmatrix of predictors- X_test
n0 x pmatrix of predictors at test points (default is NULL)
Value
a named list params containing at least
mu: vector of conditional means (fitted values)sigma: the conditional standard deviationcoefficients: a named list of parameters that determinemu
Additionally, if X_test is not NULL, then the list includes an element
mu_test, the vector of conditional means at the test points
Note
The parameters in coefficients are:
beta: thep x 1vector 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)
names(params)
#> [1] "mu" "sigma" "coefficients"
names(params$coefficients)
#> [1] "beta"