bsad | R Documentation |
This function fits a semiparametric model, which consists of parametric and nonparametric components, for estimating density using a logistic Gaussian process.
bsad(x, xmin, xmax, nint, MaxNCos, mcmc = list(), prior = list(), smoother = c('geometric', 'algebraic'), parametric = c('none', 'normal', 'gamma', 'laplace'), marginal.likelihood = TRUE, verbose = FALSE)
x |
a vector giving the data from which the density estimate is to be computed. |
xmin |
minimum value of x. |
xmax |
maximum value of x. |
nint |
number of grid points for plots (need to be odd). The default is 201. |
MaxNCos |
maximum number of Fourier coefficients. |
mcmc |
a list giving the MCMC parameters.
The list includes the following integers (with default values in parentheses):
|
prior |
a list giving the prior information. The list includes the following parameters
(default values specify the non-informative prior):
|
smoother |
types of smoothing priors for Fourier coefficients. See Details. |
parametric |
specifying a distribution of the parametric part to be test. |
marginal.likelihood |
a logical variable indicating whether the log marginal likelihood is calculated. |
verbose |
a logical variable. If |
This generic function fits a semiparametric model, which consists of parametric and nonparametric, for density estimation (Lenk, 2003):
f(x | β, Z) = \frac{\exp[h(x)^\topβ + Z(x)]}{\int_\mathcal{X} \exp[h(y)^\topβ + Z(y)]dG(y)}
where Z is a zero mean, second-order Gaussian process with bounded, continuous covariance function. i.e.,
E[Z(x), Z(y)] = σ(x,y), \quad \int_\mathcal{X}ZdG = 0 ~~(a.s.)
Using the Karhunen-Loeve Expansion, Z is represented as infinite series with random coefficients
Z(x) = ∑_{j=1}^∞ θ_j\varphi_j(x),
where \{\varphi_j\} is the cosine basis, \varphi_j(x)=√{2}\cos[jπ G(x)].
For the random Fourier coefficients of the expansion, two smoother priors are assumed (optional),
θ_j | τ, γ \sim N(0, τ^2\exp[-jγ]), ~ j ≥ 1 ~ (geometric ~smoother)
θ_j | τ, γ \sim N(0, τ^2\exp[-ln(j+1)γ]), ~ j ≥ 1 ~ (algebraic ~smoother)
The coefficient β have the popular normal prior,
β | m_{0,β}, V_{0,β} \sim N(m_{0,β}, V_{0,β})
To complete the model specification, independent hyper priors are assumed,
τ^2 | r_0, s_0 \sim IGa(r_0/2, s_0/2)
γ | w_0 \sim Exp(w_0)
Note that the posterior algorithm is based on computing a discrete version of the likelihood over a fine mesh on \mathcal{X}.
An object of class bsad
representing the Bayesian spectral analysis density estimation model fit.
Generic functions such as print
, fitted
and plot
have methods to show the results of the fit.
The MCMC samples of the parameters in the model are stored in the list mcmc.draws
,
the posterior samples of the fitted values are stored in the list fit.draws
, and
the MCMC samples for the log marginal likelihood are saved in the list loglik.draws
.
The output list also includes the following objects:
post.est |
posterior estimates for all parameters in the model. |
lmarg |
log marginal likelihood. |
ProbProbs |
posterior probability of models. |
call |
the matched call. |
mcmctime |
running time of Markov chain from |
Jo, S., Choi, T., Park, B. and Lenk, P. (2019). bsamGP: An R Package for Bayesian Spectral Analysis Models Using Gaussian Process Priors. Journal of Statistical Software, 90, 310-320.
Lenk, P. (2003) Bayesian semiparametric density estimation and model verification using a logistic Gaussian process. Journal of Computational and Graphical Statistics, 12, 548-565.
## Not run: ############################ # Old Faithful geyser data # ############################ data(faithful) attach(faithful) # mcmc parameters mcmc <- list(nblow = 10000, smcmc = 1000, nskip = 10, ndisp = 1000, kappaloop = 5) # fits BSAD model fout <- bsad(x = eruptions, xmin = 0, xmax = 8, nint = 501, mcmc = mcmc, smoother = 'geometric', parametric = 'gamma') # Summary print(fout); summary(fout) # fitted values fit <- fitted(fout) # predictive density plot plot(fit, ask = TRUE) detach(faithful) ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.