knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
In this vignette, we will show how to generate realistic datasets. For this example, the data will be simulated based on the powerconsumption
dataset provides in the package.
# Load the packages library(simulater)
First, we need to estimate the mean, covariance and noise of the real dataset. Pay attention that these functions may take some time to execute.
mu <- learn_mean(powerconsumption)
cov <- learn_covariance(powerconsumption)
noise <- learn_noise(powerconsumption)
Then, we can generate some curves using the previous estimated parameters.
X <- generate_data(10, 100, mu, cov, noise, exp(-5.5), NULL, 0.2, 1)
plot(X[[1]]$t, X[[1]]$x, type = 'l', ylim = c(230, 250)) for(i in 2:9){ lines(X[[i]]$t, X[[i]]$x, col = i) }
Now, we will (visually) compare true data with a simulated realization. The true data from the powerconsumption dataset is plotted in blue, while a generated curve is plotted in red.
X <- generate_data(1, 1440, mu, cov, noise, exp(-5.5), NULL, 0.2, 1)
plot(X[[1]]$t, X[[1]]$x, type = 'l', col = 'red', ylim = c(230, 250)) lines(seq(0, 1, length.out = 1440), matrix(powerconsumption[1,]), col = 'blue')
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.