The noiser() function takes in a dataset and
adds measurement error to it. To do this, it currently makes use of one of
two potential measurement models: One in which the measurement error is
independent over time (independent()) and one in which
measurement error does depend on time (temporal()).
Arguments
- data
Dataframe that contains information on location (x- and y-coordinates) and the time at which the measurement was taken. By default,
denoiser()will assume that this information is contained within the columns"x","y", and"time"respectively. If this isn't the case, either change the column names in the data or specify thecolsargument.- cols
Named vector or named list containing the relevant column names in
dataif they do not conform to the prespecified column names"time","x", and"y". The labels should conform to these prespecified column names and the values given to these locations should contain the corresponding column names in that dataset. Defaults toNULL, therefore assuming the structure explained indata.- .by
String denoting whether the moving window should be taken with respect to a given grouping variable. Defaults to
NULL.- model
String or function denoting the model to be used for noising up the data. When providing a string, one will use one of the native measurement models of the package, in which case the value should either be
"independent"or"temporal", calling theindependent()ortemporal()model respectively. If a function, then it should take in at least thedataand add noise to thesedatathrough using the default column names (seedata). See the vignettes for more information on how to specify this function. Defaults to"temporal".- ...
Additional arguments provided to the measurement error models. For more information, see
independent()ortemporal().
Examples
# Generate data for illustration purposes. Movement in circular motion at a
# pace of 1.27m/s with some added noise of SD = 10cm.
angles <- seq(0, 4 * pi, length.out = 100)
coordinates <- 10 * cbind(cos(angles), sin(angles))
data <- data.frame(
X = coordinates[, 1],
Y = coordinates[, 2],
seconds = rep(1:50, times = 2),
tag = rep(1:2, each = 50)
)
# Use the noiser function to add measurement error. We use the independent
# measurement error model with independence between the x- and y-dimension
# and with the measurement error variance being 0.01 in both dimensions
noiser(
data,
cols = c(
"time" = "seconds",
"x" = "X",
"y" = "Y"
),
.by = "tag",
model = "independent",
covariance = diag(2) * 0.01
) |>
head()
#> seconds X Y tag
#> 1 1 9.801649 -0.09098491 1
#> 2 2 10.104686 1.57684280 1
#> 3 3 9.770466 2.40452459 1
#> 4 4 9.478823 3.64661360 1
#> 5 5 8.818521 4.84212291 1
#> 6 6 8.239639 6.00344130 1