Learn R Programming

AMIAS (version 1.1.0)

SimuBlocks: Generate simulated data

Description

Generate data for simulations.

Usage

SimuBlocks(n, sigma = 0.1, seed = NA)
SimuWave(n, sigma = 0.1, seed = NA)
SimuDoppler(n, sigma = 0.1, seed = NA)

Arguments

n

The number of observations.

sigma

A positive value to specify the standard deviation of the Gaussian noise.

seed

a single value to specify the seed used for generating data. See set.seed for details.

Value

A list with the following components:

y

The simulated data of length \(n\).

x

The locations of y, of length \(n\).

y0

The true signal of length \(n\).

tau

Locations of the true knots.

SetA

Indexs of the true knots.

Details

Let \(x = i/n, i=1,\dots,n\). Assume that \(y_x\) follows an underlying trend \(y0_x\) with additive noise \(\epsilon_x\), i.e., $$y_x = y0_x + \epsilon_x,$$ where \(y0_x\) is a smooth curve representing relatively long-term movements and \(\epsilon_x\) is often assumed to follow i.i.d. \(N(0, \sigma^2)\).

References

Wen, C., Zhu, J., Wang, X., and Zhang, A. (2019) L0 trend filtering, technique report.

Examples

Run this code
# NOT RUN {
  ##------ Piecewise constant trend filtering example in Wen et al.(2018).-----
  set.seed(1)
  data <- SimuBlocks(2048)
  fit <- samias(data$y, kmax = 15)           # With default input argument
  plot(fit, type="coef", main = "Blocks")    # Plot the optimal estimate
  lines(data$x, data$y0, type="s")           # Add the true signal for reference
  plot(fit, type= "vpath", main = "Blocks")  # Plot the solution path

# }

Run the code above in your browser using DataLab