sample_params_additive0 | R Documentation |
Sample the parameters for an additive model, which may contain both linear and nonlinear predictors. The nonlinear terms are modeled using low-rank thin plate splines. The sampler draws the linear terms jointly and then samples each vector of nonlinear coefficients using Bayesian backfitting (i.e., conditional on all other nonlinear and linear terms).
sample_params_additive0(
y,
X_lin,
X_nonlin,
params,
A = 10^4,
B_all = NULL,
BtB_all = NULL,
XtX = NULL
)
y |
|
X_lin |
|
X_nonlin |
|
params |
the named list of parameters containing
|
A |
the prior scale for |
B_all |
optional |
BtB_all |
optional |
XtX |
optional |
The updated named list params
with draws from the full conditional distributions
of sigma
and coefficients
(and updated mu
).
The parameters in coefficients
are:
beta
: the p x 1
linear coefficients, including the linear terms from X_nonlin
f_j
: the n x pNL
matrix of fitted values for each nonlinear function
theta_j
: the pNL
-dimensional of nonlinear basis coefficients
sigma_beta
: p x 1
vector of linear regression coefficient standard deviations
sigma_theta_j
: pNL x 1
vector of nonlinear coefficient standard deviations
# Simulate data for illustration:
sim_dat = simulate_nb_friedman(n = 100, p = 5)
y = sim_dat$y; X = sim_dat$X
# Linear and nonlinear components:
X_lin = as.matrix(X[,-(1:3)])
X_nonlin = as.matrix(X[,(1:3)])
# Initialize:
params = init_params_additive0(y = y, X_lin = X_lin, X_nonlin = X_nonlin)
# Sample:
params = sample_params_additive0(y = y,
X_lin = X_lin,
X_nonlin = X_nonlin,
params = params)
names(params)
names(params$coefficients)
# And plot an example:
plot(X_nonlin[,1], params$coefficients$f_j[,1])
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.