Learn R Programming

bsamGP (version 1.1.2)

predict.blm: Predict method for a blm object

Description

Computes predicted values of Bayesian linear models.

Usage

# S3 method for blm
predict(object, newdata, alpha = 0.05, HPD = TRUE, …)

Arguments

object

a bsam object

newdata

an optional data matrix or vector 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

Value

A list containing posterior means and 95% credible intervals.

The output list includes the following objects:

wbeta

posterior estimates for regression function.

yhat

posterior estimates for generalised regression function.

Details

None.

References

Chen, M., Shao, Q. and Ibrahim, J. (2000) Monte Carlo Methods in Bayesian computation. Springer-Verlag New York, Inc.

See Also

blq, blr, gblr

Examples

Run this code
# NOT RUN {
	#####################
	# Simulated example #
	#####################

	# Simulate data
	  set.seed(1)

	  n <- 100
	  w <- runif(n)
	  y <- 3 + 2*w + rnorm(n, sd = 0.8)

	  # Fit the model with default priors and mcmc parameters
	  fout <- blr(y ~ w)

	  # Predict
	  new <- rnorm(n)
	  predict(fout, newdata = new)
# }

Run the code above in your browser using DataLab