Estimates trend indices for time series data using Gaussian Process regression
library(devtools)
install_github('aejensen/gptrendR')
library(gptrendR)
set.seed(123456)
tObs <- seq(0,1, length.out = 100)
sim <- simulateGP(tObs, seCov, c(2, 0.1), 0.05, deriv=TRUE)
fit <- GP(sim$t, sim$y, seCov)
tEval <- seq(0, 1, length.out=200)
p <- gpPrediction2(tEval, sim$t, sim$y, seCov, fit$m, fit$theta, fit$sigma2, nSim = 2.5*10^4)
par(mfrow=c(1,2), bty="n")
plot(fit, type="n")
plotBand(p$f$t, apply(p$postPred$sim, 1, quantile, p = 0.025),
apply(p$postPred$sim, 1, quantile, p = 0.975),
col = "darkgray")
plotBand(p$f$t, apply(p$f$sim, 1, quantile, p = 0.025),
apply(p$f$sim, 1, quantile, p = 0.975),
col = "lightgray")
points(sim$t, sim$y, pch=19, cex=0.5)
lines(p$f$t, p$f$mu, lwd=2)
curve(sim$f(x), 0, 1, add = TRUE, lwd = 2, col = 2)
plot(p$df$t, p$df$mu, type="n")
plotBand(p$df$t, apply(p$df$sim, 1, quantile, p = 0.025),
apply(p$df$sim, 1, quantile, p = 0.975),
col = "lightgray")
lines(p$df$t, p$df$mu, lwd = 2, col = 2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.