stuckval: Add fixed values to a time series

Description Usage Arguments Value Examples

Description

This function allows you to inject windows of fixed values into a time series. This is meant to mimic a broken sensor that is frozen on a fixed value for a specified period of time.

Usage

1
2
stuckval(y, n = 1, min.dur = 1, max.dur = 1, val.mu = mean(y),
  val.sd = 1, plot = F)

Arguments

y

The time series into which you would like to inject an error. No default.

n

The number of error events you would like to inject. Defaults to 1.

min.dur

The minimum duration, in time steps, for an error event. A random duration length is chosen to fall between the minimum and maximum (see below) duration event. Defaults to 1.

max.dur

The maximum duration, in time steps, for an error event. A random duration length is chosen to fall between the minimum (see above) and maximum duration event. Defaults to 1.

val.mu

A random fixed value is chosen for each error event from a normal distribution. val.mu is the average of that distribution. The default value is the mean of the entire time series.

val.sd

A random fixed value is chosen for each error event from a normal distribution. val.sd is the standard deviation of that distribution. Defaults to 1.

plot

A logical value (T or F) indicating if a plot should be returned. Defaults to F.

Value

Returns a list with three components and an optional plot. The three components are the original time series, the new error-injected time series, and a vector of 1 and 0 that indicate the locations (time steps) where errors were injected. The plot is a graphical illustration of these three components.

Examples

1
2
3
4
5
6
7
8
library(setset)
data(simseries)
d1 <- simseries
str(d1)
stuckval(d1$v1, n=3, min.dur=1000, max.dur=10000, val.sd=1, plot=T)
d2 <- stuckval(d1$v1, n=3, min.dur=1000, max.dur=10000, val.sd=1, plot=T)
str(d2)
noiseval(d2$new.data, n=5, min.dur=100, max.dur=1000, noise.sd=1, plot=T)

tmeeha/setset documentation built on May 31, 2019, 4:38 p.m.