SimuBlocksInv {L0TFinv} | R Documentation |
Simulate Blocks Data
Description
This function generates data points of piecewise constant trends.
Usage
SimuBlocksInv(n, sigma, seed = NA, tau, h)
Arguments
n |
Number of data points |
sigma |
Standard deviation of the noise added to the signal |
seed |
An optional seed for random number generation to make results reproducible |
tau |
The locations of change points in the underlying trend |
h |
The constant values of the |
Details
To simplify the analysis, normalize the change point positions to a range between 0 and 1. Require that all elements of the input
tau
are within this range. Consequently, the change point positions in simulated data forms a subset of the set {\frac{1}{n}
,\frac{2}{n}
,\frac{3}{n}
,..., 1}.In fact,
length(tau)
change points can divide the interval intolength(tau)+1
segments of constant function values. Therefore, ensure that the length of vectorh
islength(tau)+1
.
Value
A list containing the piecewise constant simulated data and the underlying trend:
x |
The set { |
y |
The piecewise constant simulated data of length |
y0 |
The underlying trend of length |
setA |
The set of position indicators of change points in the simulated data |
tau |
The locations of change points in the underlying trend |
Examples
tau = c(0.1, 0.3, 0.4, 0.7, 0.85)
h = c(-1, 5, 3, 0, -1, 2)
BlocksData <- SimuBlocksInv(n = 350, sigma = 0.1, seed = 50, tau = tau ,h = h)
plot(BlocksData$x, BlocksData$y, xlab="", ylab="")
lines(BlocksData$x, BlocksData$y0, col = "red")
print(BlocksData$setA)
print(BlocksData$tau)