Learn R Programming

mrct (version 0.0.1.0)

mrct.rgauss: Random sample from Gaussian process

Description

Generate random samples of Gaussian process on a uniform grid for different settings of the simulation study in oguamalam2023minimum;nobracketsmrct.

Usage

mrct.rgauss(
  x.grid,
  N,
  seed = 123,
  model,
  outliers,
  sigma = 1,
  l = 1,
  method = "linear"
)

Value

Numeric matrix with \(N\) rows and length(x.grid) columns containing the randomly generated curves following a Gaussian process. Each observations is a row of the result.

Arguments

x.grid

Numeric vector containing a uniform grid on which the process is defined.

N

Integer number of observations to generate.

seed

Integer (default is \(123\)).. Random seed for reprocudibility.

model

Integer. Either \(1, 2\) or \(3\). Corresponds to one of the three simulation settings.

outliers

Integer vector containing the indices of outliers. If empty, then only regular curves will be generated.

sigma, l

Numeric values with default equal to \(1\). Parameters for the covariance kernel.

method

Different types of covariance kernels. Possible options are "quadratic" $$\gamma(s,t) = \sigma \text{exp}\left(\frac{-(s-t)^2}{l}\right),$$ "linear" $$\gamma(s,t) = \sigma \text{exp}\left(\frac{-|s-t|}{l}\right)$$ or "gaussian" (default) $$\gamma(s,t) = \sigma^2 \text{exp}\left(\frac{-(s-t)^2}{2 l^2}\right)$$.

References

oguamalam2023minimummrct.

Examples

Run this code
# Fix seed for reproducibility
set.seed(123)

# Sample outlying indices
cont.ind <- sample(1:50,size=10)

# Generate 50 curves on the interval [0,1] at 50 timepoints with 20% outliers
y <- mrct.rgauss(x.grid=seq(0,1,length.out=50), N=50 ,model=1,
                 outliers=cont.ind)

# Visualize curves (regular curves grey, outliers black)
colormap <- rep("grey",50); colormap[cont.ind] <- "black"
matplot(x=seq(0,1,length.out=50), y=t(y), type="l", lty="solid",
        col=colormap, xlab="t",ylab="")

Run the code above in your browser using DataLab