rptmvn {nntmvn} | R Documentation |
Draw one sample of the underlying GP responses for a partially censored Gaussian process using sequential nearest neighbor (SNN) method
Description
Draw one sample of the underlying GP responses for a partially censored Gaussian process using sequential nearest neighbor (SNN) method
Usage
rptmvn(
y,
cens_lb,
cens_ub,
mask_cens,
m = 30,
covmat = NULL,
locs = NULL,
cov_name = NULL,
cov_parm = NULL,
NN = NULL,
ordering = 0,
seed = NULL
)
Arguments
y |
uncensored responses of length n, where n is the number of all responses |
cens_lb |
lower bound vector for TMVN of length n |
cens_ub |
upper bound vector for TMVN of length n |
mask_cens |
mask for censored responses (also locations) of length n |
m |
positive integer for the number of nearest neighbors used |
covmat |
n-by-n dense covariance matrix, either |
locs |
location matrix n X d |
cov_name |
covariance function name from the |
cov_parm |
parameters for the covariance function from the |
NN |
n X m matrix for nearest neighbors. i-th row is the nearest neighbor indices of y_i. |
ordering |
|
seed |
set seed for reproducibility |
Value
a vector of length n representing the underlying GP responses
Examples
library(GpGp)
library(RANN)
library(nntmvn)
set.seed(123)
x <- matrix(seq(from = 0, to = 1, length.out = 51), ncol = 1)
cov_name <- "matern15_isotropic"
cov_parm <- c(1.0, 0.1, 0.001) #' variance, range, nugget
cov_func <- getFromNamespace(cov_name, "GpGp")
covmat <- cov_func(cov_parm, x)
y <- t(chol(covmat)) %*% rnorm(length(x))
mask <- y < 0.3
y_cens <- y
y_cens[mask] <- NA
lb <- rep(-Inf, 100)
ub <- rep(0.3, 100)
m <- 10
y_samp_mtd1 <- rptmvn(y_cens, lb, ub, mask,
m = m, locs = x,
cov_name = cov_name, cov_parm = cov_parm, seed = 123
)
y_samp_mtd2 <- rptmvn(y_cens, lb, ub, mask,
m = m, covmat = covmat,
seed = 123
)
plot(x, y_cens, ylim = range(y))
points(x[mask, ], y[mask], col = "blue")
plot(x, y_cens, ylim = range(y))
points(x[mask, ], y_samp_mtd1[mask], col = "red")
plot(x, y_cens, ylim = range(y))
points(x[mask, ], y_samp_mtd2[mask], col = "brown")