predict.tgp | R Documentation |
This generic prediction method was designed to obtain samples
from the posterior predictive distribution after the b*
functions have finished. Samples, or kriging mean and variance
estimates, can be obtained from the MAP model encoded in the
"tgp"
-class object, or this parameterization can be used
as a jumping-off point in obtaining further samples from the
joint posterior and posterior predictive distributions
## S3 method for class 'tgp' predict(object, XX = NULL, BTE = c(0, 1, 1), R = 1, MAP = TRUE, pred.n = TRUE, krige = TRUE, zcov = FALSE, Ds2x = FALSE, improv = FALSE, sens.p = NULL, trace = FALSE, verb = 0, ...)
object |
|
XX |
Optional |
BTE |
3-vector of Monte-carlo parameters (B)urn in, (T)otal, and
(E)very. Predictive samples are saved every E MCMC rounds starting
at round B, stopping at T. The default |
R |
Number of repeats or restarts of |
MAP |
When |
pred.n |
|
krige |
|
zcov |
If |
Ds2x |
|
improv |
|
sens.p |
Either |
trace |
|
verb |
Level of verbosity of R-console print statements: from 0 (default: none); 1 which shows the “progress meter”; 2 includes an echo of initialization parameters; up to 3 and 4 (max) with more info about successful tree operations |
... |
Ellipses are not used in the current version
of |
While this function was designed with prediction in mind, it is
actually far more general. It allows a continuation of
MCMC sampling where the b*
function left off (when
MAP=FALSE
) with a possibly new set of predictive locations
XX
. The intended use of this function is to obtain quick
kriging-style predictions for a previously-fit MAP estimate
(contained in a "tgp"
-class object)
on a new set of predictive locations XX
. However,
it can also be used simply to extend the search for an MAP model
when MAP=FALSE
, pred.n=FALSE
, and XX=NULL
The output is the same, or a subset of, the output produced
by the b*
functions, for example see btgp
It is important to note that this function is not a replacement
for supplying XX
to the b*
functions, which is the only
way to get fully Bayesian samples from the posterior prediction
at new inputs. It is only intended as a post-analysis (diagnostic)
tool.
Inputs XX
containing NaN, NA
, or Inf
are
discarded with non-fatal warnings. Upon execution, MCMC reports are
made every 1,000 rounds to indicate progress.
If XX
s are provided which fall outside the range of X
inputs provided to the original b*
function, then those will
not be extrapolated properly, due to the way that bounding rectangles
are defined in the original run. For a workaround, supply
out$Xsplit <- rbind(X, XX)
before running predict
on
out
.
See note for btgp
or another b*
function
regarding the handling and appropriate specification of traces
.
The "tgp"
class output produced by predict.tgp
can
also be used as input to predict.tgp
, as well as others (e.g.,
plot.tgp
.
Robert B. Gramacy, rbg@vt.edu, and Matt Taddy, mataddy@amazon.com
https://bobby.gramacy.com/r_packages/tgp/
predict
, blm
, btlm
,
bgp
, btgp
, bgpllm
,
btgpllm
, plot.tgp
## revisit the Motorcycle data require(MASS) ## fit a btgpllm without predictive sampling (for speed) out <- btgpllm(X=mcycle[,1], Z=mcycle[,2], bprior="b0", pred.n=FALSE) ## nothing to plot here because there is no predictive data ## save the "tgp" class output object for use later and save(out, file="out.Rsave") ## then remove it (for illustrative purposes) out <- NULL ## (now imagine emailing the out.Rsave file to a friend who ## then performs the following in order to use your fitted ## tgp model on his/her own predictive locations) ## load in the "tgp" class object we just saved load("out.Rsave") ## new predictive locations XX <- seq(2.4, 56.7, length=200) ## now obtain kriging estimates from the MAP model out.kp <- predict(out, XX=XX, pred.n=FALSE) plot(out.kp, center="km", as="ks2") ## actually obtain predictive samples from the MAP out.p <- predict(out, XX=XX, pred.n=FALSE, BTE=c(0,1000,1)) plot(out.p) ## use the MAP as a jumping-off point for more sampling out2 <- predict(out, XX, pred.n=FALSE, BTE=c(0,2000,2), MAP=FALSE, verb=1) plot(out2) ## (generally you would not want to remove the file) unlink("out.Rsave")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.