# \donttest{
# 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]) * cos(2 * pi * x[, 2]) + 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 predictions for x1 and x2 jointly
marginal_samps_both <- gen_marginal_samples(res, to_eval = c("x1", "x2"), nsamp = 100)
# Plot interactive surface
plot(marginal_samps_both)
# Customize surface appearance
plot(marginal_samps_both, opacity = 0.8, colorscale = "Magma")
# Customize further via plotly
p <- plot(marginal_samps_both, opacity = 0.8, colorscale = "Magma")
p |> plotly::layout(
scene = list(
xaxis = list(title = "Covariate 1"),
yaxis = list(title = "Covariate 2"),
zaxis = list(title = "Expected value")
)
)
# }
Run the code above in your browser using DataLab