subsampling: subsampling

View source: R/simulate.R

subsamplingR Documentation

subsampling

Description

subsampling

Usage

subsampling(x, sampling, ...) 

Arguments

x

an yuima-class or yuima.model-class object.

sampling

a yuima.sampling-class object.

...

used to create a sampling structure

Details

When subsampling on some grid of times, it may happen that no data is available at the given grid point. In this case it is possible to use several techniques. Different options are avaiable specifying the argument, or the slot, interpolation:

"none" or "exact"

no interpolation. If no data point exists at a given grid point, NA is returned in the subsampled data

"pt" or "previous"

the first data on the left of the grid point instant is used.

"nt" or "next"

the first data on the right of the grid point instant is used.

"lin" or "linear"

the average of the values of the first data on the left and the first data to the right of the grid point instant is used.

Value

yuima

a yuima.data-class object.

Author(s)

The YUIMA Project Team

Examples

## Set a model
diff.coef.1 <- function(t, x1=0, x2) x2*(1+t)
diff.coef.2 <- function(t, x1, x2=0) x1*sqrt(1+t^2)
cor.rho <- function(t, x1=0, x2=0) sqrt((1+cos(x1*x2))/2)
diff.coef.matrix <- matrix(c("diff.coef.1(t,x1,x2)",
"diff.coef.2(t,x1,x2)*cor.rho(t,x1,x2)", "",
"diff.coef.2(t,x1,x2)*sqrt(1-cor.rho(t,x1,x2)^2)"),2,2)
cor.mod <- setModel(drift=c("",""), diffusion=diff.coef.matrix, 
solve.variable=c("x1", "x2"), xinit=c(3,2))
set.seed(111)

## We first simulate the two dimensional diffusion model
yuima.samp <- setSampling(Terminal=1, n=1200)
yuima <- setYuima(model=cor.mod, sampling=yuima.samp)
yuima.sim <- simulate(yuima)

plot(yuima.sim, plot.type="single")

## random sampling with exponential times
## one random sequence per time series
newsamp <- setSampling(
 random=list(rdist=c( function(x) rexp(x, rate=10), 
  function(x) rexp(x, rate=20))) )
newdata <- subsampling(yuima.sim, sampling=newsamp)
points(get.zoo.data(newdata)[[1]],col="red")
points(get.zoo.data(newdata)[[2]],col="green")


plot(yuima.sim, plot.type="single")

## deterministic subsampling with different
## frequence for each time series
newsamp <- setSampling(delta=c(0.1,0.2))
newdata <- subsampling(yuima.sim, sampling=newsamp)
points(get.zoo.data(newdata)[[1]],col="red")
points(get.zoo.data(newdata)[[2]],col="green")

yuima documentation built on Nov. 14, 2022, 3:02 p.m.

Related to subsampling in yuima...