sample_SVCdata: Sample Function for GP-based SVC Model for Given Locations

View source: R/example.R

sample_SVCdataR Documentation

Sample Function for GP-based SVC Model for Given Locations


Samples SVC data at given locations. The SVCs parameters and the covariance function have to be provided. The sampled model matrix can be provided or it is sampled. The SVCs are sampled according to their given parametrization and at respective observation locations. The error vector is sampled from a nugget effect. Finally, the response vector is computed. Please note that the function is not optimized for sampling large data sets.


  locs, = c("exp", "sph", "mat32", "mat52", "wend1", "wend2"),
  X = NULL


(data.frame(p, 3))
Contains the mean and covariance parameters of SVCs. The three columns must have the names "mean", "var", and "scale".

Standard deviation of the nugget / error term.


(numeric(n) or matrix(n, d))
The numeric vector or matrix contains the observation locations and therefore defines the number of observations to be n. For a vector, we assume locations on the real line, i.e., d=1.

Character defining the covariance function, c.f. SVC_mle_control.


(NULL or matrix(n, p))
If NULL, the covariates are sampled, where the first column contains only ones to model an intercept and further columns are sampled from a standard normal. If it is provided as a matrix, then the dimensions must match the number of locations in locs (n) and the number of SVCs defined by the number of rows in (p).


The parameters of the model can be chosen such that we obtain data from a not full model, i.e., not all covariates are associated with a fixed and a random effect. Using var = 0 for instance yields a constant beta coefficient for respective covariate. Note that in that case the scale value is neglected.


Returns a list with the response y, model matrix X, a matrix beta containing the sampled SVC at given locations, a vector eps containing the error, and a matrix locs containing the original locations. The true_pars contains the data frame of covariance parameters that were used to sample the GP-based SVCs. The nugget variance has been added to the original argument of the function with its respective variance, but NA for "mean" and "scale".


# SVC parameters
( <- data.frame(
   var = c(2, 1),
   scale = c(3, 1),
   mean = c(1, 2)))
# nugget standard deviation
tau <- 0.5

# sample locations
s <- sort(runif(500, min = 0, max = 10))
SVCdata <- sample_SVCdata( =, = tau, locs = s, = "mat32"

varycoef documentation built on Sept. 18, 2022, 1:07 a.m.