predict.densEstBayes {densEstBayes} | R Documentation |
Obtain the Bayesian density estimate from a densEstBayes()
fit at new abscissae
Description
Values of the estimated density function, obtained via densEstBayes
, are computed for new abscissae.
Usage
## S3 method for class 'densEstBayes'
predict(object,newdata,cred.fit = FALSE,credLev = 0.95,...)
Arguments
object |
A |
newdata |
A numerical vector of abscissae values. |
cred.fit |
Boolean flag: |
credLev |
number between 0 and 1 such that the credible interval band has (100*credLev)% approximate coverage. The default value is 0.95. |
... |
A place-holder for other prediction parameters. |
Value
A list is returned with the following components:
fit |
numerical vector of ordinate values corresponding to the density estimate. |
credLow.fit |
numerical vector of ordinate values corresponding to the lower limits of the pointwise approximate (100*credLev)% credible set variability band. |
credUpp.fit |
numerical vector of ordinate values corresponding to the upper limits of the pointwise approximate (100*credLev)% credible set variability band. |
Author(s)
Matt P. Wand matt.wand@uts.edu.au
Examples
library(densEstBayes) ; data(OldFaithful2011)
# Obtain a density estimate for the `OldFaithful2011' data:
dest <- densEstBayes(OldFaithful2011,method = "SMFVB")
# Plot the density estimate:
plot(dest,xlab = "time interval between geyser eruptions (minutes)")
rug(jitter(OldFaithful2011,amount = 0.2),col = "dodgerblue")
# Obtain predictions at 60,70,80,90,100 and 110 seconds and
# add to them plot:
newdataVec <- seq(60,110,by = 10)
predictObj <- predict(dest,newdata = newdataVec,cred.fit = TRUE)
print(predictObj$fit)
points(newdataVec,predictObj$fit,col = "blue")
# Print and add to the plot the lower and upper limits of
# the pointwise 95% credible intervals:
print(predictObj$credLow.fit)
print(predictObj$credUpp.fit)
points(newdataVec,predictObj$credLow.fit,col = "red")
points(newdataVec,predictObj$credUpp.fit,col = "red")