Description Usage Arguments Details Value Author(s) References See Also Examples
bcgam
is used to fit generalised partial linear regression models using a Bayesian
approach, where shape and smoothness constraints are imposed on nonparametrically modelled predictors
through shape-restricted splines, and no constraints are imposed on optional parametrically modelled covariates.
1 2 |
formula |
an object of class
|
family |
a description of the error distribution and link function to be used in the model. This accepts
only the following families: |
data |
an optional data frame, list or environment containing the variables in the model. The default is |
nloop |
length of the MCMC. The default is |
burnin |
a positive value, smaller than |
We assume the additive model for each systematic component element η_i given by
η_i = f_1(x_{1i}) + ... + f_L(x_{Li}) + z_i'γ,
where z_i is a vector of variables to be modelled parametrically and γ is a parameter vector. The functions f_l of the continuous predictors x_l are assumed to be smooth, and shape restrictions such as monotonicity and/or convexity might be assumed. Generally, the vector η=(η_1, ..., η_n)' is approximated by
∑_{j=1}^{m_1}β_{1j}δ_{1j} + ... + ∑_{j=1}^{m_L}β_{Lj}δ_{Lj} + ∑_{j=1}^{p}α_jν_j,
where β_{lj} ≥ 0 for all l,j. The δ's represent the basis vectors used to approximate the f functions. The ν_j consists of the one vector and the vectors of the observed values of covariates to be modelled parametrically. In addition, when f_l is assumed to be convex, the x_l vector is included as one of the ν_j.
A Bayesian approach is considered for estimation and inference of the model above. As the β coefficients are constrained to be non-negative, then a gamma prior with hyperparameters c_{l1} (shape) and c_{l2} (scale) is assumed for each β_{lj}. The values c_{l1} and c_{l2} are chosen in a way that a large variance can be combined with a small mean, so that it is close to a non-informative gamma prior. Further, a normal prior distribution with mean zero and large variance M is considered for the α coefficients.
bcgam
makes use of the system "nimble" to set the Bayesian (hierarchical) model and compute the MCMC. Hence,
"nimble" has to be loaded in R
to be able to use bcgam
. Information about how to download
and install "nimble" can be found at https://r-nimble.org.
bcgam
returns an object of class "bcgam".
The generic routines summary
and print
are used to obtain and print a summary
of the results. Further, 2D and 3D plots can be created using plot
and persp
, respectively.
An object of class "bcgam" is a list containing at least the following components:
coefs |
a vector of posterior means of the α and β coefficients. |
sd.coefs |
a vector of posterior standard errors of the α and β coefficients. |
etahat |
a vector of posterior means of the systematic component η. |
muhat |
a vector of posterior means of μ. μ is obtained by transforming η using the inverse of the link function. |
alpha.sims |
a matrix of posterior samples (after burn-in) of the α coefficients. |
beta.sims |
a matrix of posterior samples (after burn-in) of the β coefficients. |
sigma.sims |
a matrix of posterior samples (after burn-in) of σ. This is only
shown when |
eta.sims |
a matrix of posterior samples (after burn-in) of the systematic component η. |
mu.sims |
a matrix of posterior samples (after burn-in) of μ. μ is obtained by transforming η using the inverse of the link function. |
delta |
a matrix that contains the basis functions δ in its columns. |
zmat |
a matrix that contains the vectors ν in its columns. |
knots |
a list of the knots. |
shapes |
a list of numbers that indicate the shape categories. |
sps |
a character vector of the space parameter used to create the knots. |
nloop |
the length of the MCMC. |
burnin |
the burn-in value. |
family |
the family parameter. |
y |
the response variable. |
Cristian Oliva-Aviles and Mary C. Meyer
Meyer, M. C. (2008) Inference using shape-restricted regression splines. Annals of Applied Statistics 2(3), 1013-1033.
Meyer, M. C., Hackstadt, A. J., and Hoeting J. A. (2011) Bayesian estimation and inference for generalised partial linear models using shape-restricted splines. Journal of Nonparametric Statistics 23(4), 867-884.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | ## Not run:
## Example 1 (gaussian)
data(duncan)
bcgam.fit <- bcgam(income~sm.incr(prestige, space="E")+sm.conv(education)+type, data=duncan)
print(bcgam.fit)
summary(bcgam.fit)
plot(bcgam.fit, prestige, col=4)
persp(bcgam.fit, prestige, education, level=0.90)
## Example 2 (poisson)
set.seed(2018)
n<-50
x1<-sqrt(1:n)
z<-as.factor(rbinom(n, 1, 0.5))
log.eta<-x1/7+0.2*as.numeric(z)+rnorm(50, sd=0.6)
eta<-exp(log.eta)
y<-rpois(n,eta)
bcgam.fit <- bcgam(y~sm.conv(x1)+z, family="poisson")
summary(bcgam.fit)
predict(bcgam.fit, newdata=data.frame(x1=0.2, z="0"), interval="credible")
plot(bcgam.fit, x1, col=3, col.inter=4)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.