View source: R/plot_functions.R
plot.shrinkGPR_marg_samples_1D | R Documentation |
Generates a plot of 1D conditional predictive samples produced by gen_marginal_samples
with a single covariate.
## S3 method for class 'shrinkGPR_marg_samples_1D'
plot(x, ...)
x |
An object of class |
... |
Additional arguments passed to plot.mcmc.tvp for customizing the plot, such as axis labels or plotting options. |
By default, the function visualizes the posterior predictive median and 95% and 50% credible intervals for the selected covariate across a grid of evaluation points. Axis labels are automatically inferred if not explicitly provided.
Note: The shrinkTVP package must be installed to use this function.
Called for its side effects. Returns invisible(NULL)
.
Peter Knaus peter.knaus@wu.ac.at
gen_marginal_samples
Other plotting functions:
plot.shrinkGPR()
,
plot.shrinkGPR_marg_samples_2D()
,
plot.shrinkTPR()
# Simulate data
set.seed(123)
torch::torch_manual_seed(123)
n <- 100
x <- matrix(runif(n * 2), n, 2)
y <- sin(2 * pi * x[, 1]) + rnorm(n, sd = 0.1)
data <- data.frame(y = y, x1 = x[, 1], x2 = x[, 2])
# Fit GPR model
res <- shrinkGPR(y ~ x1 + x2, data = data)
# Generate marginal samples
marginal_samps_x1 <- gen_marginal_samples(res, to_eval = "x1", nsamp = 100)
marginal_samps_x2 <- gen_marginal_samples(res, to_eval = "x2", nsamp = 100)
# Plot marginal predictions
plot(marginal_samps_x1)
plot(marginal_samps_x2)
# Customize plot appearance (see plot.mcmc.tvp from shrinkTVP package for more options)
plot(marginal_samps_x2, shaded = FALSE, quantlines = TRUE, quantcol = "red")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.