simGPR: Simulate Data for Gaussian Process Regression

View source: R/simGPR.R

simGPRR Documentation

Simulate Data for Gaussian Process Regression

Description

simGPR generates simulated data for Gaussian Process Regression (GPR) models, including the true hyperparameters used for simulation.

Usage

simGPR(
  N = 200,
  d = 3,
  d_mean = 0,
  sigma2 = 0.1,
  tau = 2,
  kernel_func = kernel_se,
  perc_spars = 0.5,
  theta,
  beta,
  device
)

Arguments

N

Positive integer specifying the number of observations to simulate. Default is 200.

d

Positive integer specifying the number of covariates for the covariance structure. Default is 3.

d_mean

Positive integer specifying the number of covariates for the mean structure. Default is 0.

sigma2

Positive numeric value specifying the noise variance. Default is 0.1.

tau

Positive numeric value specifying the global shrinkage parameter. Default is 2.

kernel_func

Function specifying the covariance kernel. Default is kernel_se.

perc_spars

Numeric value in [0, 1] indicating the proportion of elements in theta and beta to sparsify. Default is 0.5.

theta

Optional numeric vector specifying the true inverse length-scale parameters. If not provided, they are randomly generated.

beta

Optional numeric vector specifying the true regression coefficients for the mean structure. If not provided, they are randomly generated.

device

Optional torch_device object specifying whether to run the simulation on CPU or GPU. Defaults to GPU if available.

Details

This function simulates data from a Gaussian Process Regression model. The response variable y is sampled from a multivariate normal distribution with a covariance matrix determined by the specified kernel function, theta, tau, and sigma2. If d_mean > 0, a mean structure is included in the simulation, with covariates x_mean and regression coefficients beta.

Value

A list containing:

  • data: A data frame with y (response variable), x (covariates for the covariance structure), and optionally x_mean (covariates for the mean structure).

  • true_vals: A list containing the true values used for the simulation:

    • theta: The true inverse length-scale parameters.

    • sigma2: The true noise variance.

    • tau: The true global shrinkage parameter.

    • beta (optional): The true regression coefficients for the mean structure.

Examples

if (torch::torch_is_installed()) {
  torch::torch_manual_seed(123)

  # Simulate data with default settings
  sim_data <- simGPR()

  # Simulate data with custom settings
  sim_data <- simGPR(N = 100, d = 5, d_mean = 2, perc_spars = 0.3, sigma2 = 0.5)

  # Access the simulated data
  head(sim_data$data)

  # Access the true values used for simulation
  sim_data$true_vals
  }

shrinkGPR documentation built on April 4, 2025, 3:07 a.m.

Related to simGPR in shrinkGPR...