sample_SVCdata {varycoef}R Documentation

Sample Function for GP-based SVC Model for Given Locations

Description

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.

Usage

sample_SVCdata(
  df.pars,
  nugget.sd,
  locs,
  cov.name = c("exp", "sph", "mat32", "mat52", "wend1", "wend2"),
  X = NULL
)

Arguments

df.pars

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

nugget.sd

(numeric(1))
Standard deviation of the nugget / error term.

locs

(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.

cov.name

(character(1))
Character defining the covariance function, c.f. SVC_mle_control.

X

(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 df.pars (p).

Details

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.

Value

list
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".

Examples

set.seed(123)
# SVC parameters
(df.pars <- 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(
  df.pars = df.pars, nugget.sd = tau, locs = s, cov.name = "mat32"
)

[Package varycoef version 0.3.4 Index]