Learn R Programming

bsamGP (version 1.2.6)

predict.bsamdpm: Predict method for a bsamdpm object

Description

Computes the predicted values of Bayesian spectral analysis models with Dirichlet process mixture errors.

Usage

# S3 method for bsamdpm
predict(object, newp, newnp, alpha = 0.05, HPD = TRUE, ...)

Value

A list object of class predict.bsamdpm containing posterior means and \(100(1-\alpha)\)% credible intervals.

The output list includes the following objects:

fxobs

posterior estimates for unknown functions over observation.

wbeta

posterior estimates for parametric part.

yhat

posterior estimates for fitted values of response.

Arguments

object

a bsamdpm object

newp

an optional data of parametric components with which to predict. If omitted, the fitted values are returned.

newnp

an optional data of nonparametric components with which to predict. If omitted, the fitted values are returned.

alpha

a numeric scalar in the interval (0,1) giving the \(100(1-\alpha)\)% credible intervals.

HPD

a logical variable indicating whether the \(100(1-\alpha)\)% Highest Posterior Density (HPD) intervals are calculated. If HPD=FALSE, the \(100(1-\alpha)\)% equal-tail credible intervals are calculated. The default is TRUE.

...

not used

Details

None.

See Also

bsaqdpm, bsardpm

Examples

Run this code
if (FALSE) {

#####################
# Increasing-convex #
#####################

# Simulate data
set.seed(1)

n <- 200
x <- runif(n)
e <- c(rnorm(n/2, sd = 0.5), rnorm(n/2, sd = 3))
y <- exp(6*x - 3) + e

# Number of cosine basis functions
nbasis <- 50

# Fit the model with default priors and mcmc parameters
fout <- bsardpm(y ~ fs(x), nbasis = nbasis, shape = 'IncreasingConvex')

# Prediction
xnew <- runif(n)
predict(fout, newnp = xnew)

}

Run the code above in your browser using DataLab