From a5df283b46cde8ffa2d4bf026dc78f7574f1e9ea Mon Sep 17 00:00:00 2001 From: Peder <pbac@dtu.dk> Date: Wed, 11 Oct 2023 20:24:59 +0200 Subject: [PATCH] updated to new documentation format --- DESCRIPTION | 6 +- NAMESPACE | 3 +- R/extra.R | 4 + R/lagdf.R | 7 +- R/lp.R | 12 ++- R/onlineforecast-package.R | 16 ++-- R/plot_ts.R | 12 +++ R/plotly_ts.R | 4 + R/resample.R | 1 + R/rls_summary.R | 1 + cran-comments.md | 19 +++++ inst/CITATION | 26 +++---- make.R | 23 +++--- man/lagdf.character.Rd | 78 +++++++++++++++++++ man/lagdf.factor.Rd | 78 +++++++++++++++++++ man/lagdf.logical.Rd | 78 +++++++++++++++++++ man/lagdf.matrix.Rd | 78 +++++++++++++++++++ man/lagdf.numeric.Rd | 78 +++++++++++++++++++ man/lp.Rd | 2 +- man/lp_vector.Rd | 24 ++++++ man/onlineforecast-package.Rd | 28 +++++++ man/onlineforecast.Rd | 14 ---- man/plot_ts.Rd | 42 ++++++++++ man/plotly_ts.data.frame.Rd | 140 ++++++++++++++++++++++++++++++++++ man/plotly_ts.data.list.Rd | 140 ++++++++++++++++++++++++++++++++++ man/resample.data.frame.Rd | 76 ++++++++++++++++++ man/summary.rls_fit.Rd | 78 +++++++++++++++++++ src/Makevars | 4 +- 28 files changed, 1013 insertions(+), 59 deletions(-) create mode 100644 R/extra.R create mode 100644 man/lagdf.character.Rd create mode 100644 man/lagdf.factor.Rd create mode 100644 man/lagdf.logical.Rd create mode 100644 man/lagdf.matrix.Rd create mode 100644 man/lagdf.numeric.Rd create mode 100644 man/lp_vector.Rd create mode 100644 man/onlineforecast-package.Rd delete mode 100644 man/onlineforecast.Rd create mode 100644 man/plotly_ts.data.frame.Rd create mode 100644 man/plotly_ts.data.list.Rd create mode 100644 man/resample.data.frame.Rd create mode 100644 man/summary.rls_fit.Rd diff --git a/DESCRIPTION b/DESCRIPTION index 4e0d43e..43032fa 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Package: onlineforecast Type: Package Title: Forecast Modelling for Online Applications -Version: 1.0.1 -Description: A framework for fitting adaptive forecasting models. Provides a way to use forecasts as input to models, e.g. weather forecasts for energy related forecasting. The models can be fitted recursively and can easily be setup for updating parameters when new data arrives. See the included vignettes, the website <https://onlineforecasting.org> and the pre-print paper "onlineforecast: An R package for adaptive and recursive forecasting" <arXiv:2109.12915>. +Version: 1.0.2 +Description: A framework for fitting adaptive forecasting models. Provides a way to use forecasts as input to models, e.g. weather forecasts for energy related forecasting. The models can be fitted recursively and can easily be setup for updating parameters when new data arrives. See the included vignettes, the website <https://onlineforecasting.org> and the paper "onlineforecast: An R package for adaptive and recursive forecasting" <https://journal.r-project.org/articles/RJ-2023-031/>. License: GPL-3 Encoding: UTF-8 LazyData: true @@ -25,7 +25,7 @@ Suggests: data.table, plotly VignetteBuilder: knitr -RoxygenNote: 7.1.2 +RoxygenNote: 7.2.3 URL: https://onlineforecasting.org BugReports: https://lab.compute.dtu.dk/packages/onlineforecast/-/issues Config/testthat/edition: 3 diff --git a/NAMESPACE b/NAMESPACE index 4ec65ce..92f6113 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -88,7 +88,8 @@ export(score) export(setpar) export(stairs) export(step_optim) -importFrom(Rcpp,sourceCpp) +exportPattern("^[[:alpha:]]+") +importFrom(Rcpp,evalCpp) importFrom(grDevices,colorRampPalette) importFrom(grDevices,graphics.off) importFrom(graphics,axis) diff --git a/R/extra.R b/R/extra.R new file mode 100644 index 0000000..e447e17 --- /dev/null +++ b/R/extra.R @@ -0,0 +1,4 @@ +#' @useDynLib onlineforecast +#' @importFrom Rcpp evalCpp +#' @exportPattern "^[[:alpha:]]+" +NULL diff --git a/R/lagdf.R b/R/lagdf.R index a72012c..9d0ff33 100644 --- a/R/lagdf.R +++ b/R/lagdf.R @@ -40,6 +40,7 @@ lagdf <- function(x, lagseq){ } +#' @inherit lagdf #' @export lagdf.numeric <- function(x, lagseq) { ## Return a data.frame @@ -51,17 +52,20 @@ lagdf.numeric <- function(x, lagseq) { } +#' @inherit lagdf #' @export lagdf.factor <- function(x, lagseq) { lagdf.numeric(x, lagseq) } +#' @inherit lagdf #' @export lagdf.character <- function(x, lagseq) { lagdf.numeric(x, lagseq) } +#' @inherit lagdf #' @export lagdf.logical <- function(x, lagseq) { lagdf.numeric(x, lagseq) @@ -154,6 +158,8 @@ lagdf.data.frame <- function(x, lagseq) { return(X) } + +#' @inherit lagdf.data.frame #' @export lagdf.matrix <- function(x, lagseq){ lagdf.data.frame(x, lagseq) @@ -196,4 +202,3 @@ lagdf.matrix <- function(x, lagseq){ ## invisible(NULL) ## } ## } - diff --git a/R/lp.R b/R/lp.R index f9408eb..b9d6b7c 100644 --- a/R/lp.R +++ b/R/lp.R @@ -4,7 +4,7 @@ #load_all(as.package("../../onlineforecast")) #?lp -#' First-order low-pass filtering of a time series vector. +#' First-order low-pass filtering of time series. #' #' This function applies a first order unity gain low-pass filter to the columns of \code{X}. #' The low-pass filter is applied to each column seperately. The stationary gain of the filter i one. @@ -66,6 +66,16 @@ lp <- function(X, a1, usestate = TRUE) { } +#' First-order low-pass filtering of a time series vector. +#' +#' This function applies a first order unity gain low-pass filter vector. +#' +#' The \code{lp_vector_cpp} function does the same much faster. +#' +#' @title First-order low-pass filtering +#' @param x vector. +#' @param a1 The low-pass filter coefficient. +#' @return The low-pass filtered vector lp_vector <- function(x, a1) { ## Make a 1'st order low pass filter as (5.3) p.46 in the HAN report. y <- numeric(length(x)) diff --git a/R/onlineforecast-package.R b/R/onlineforecast-package.R index 4ac94e9..a65cf64 100644 --- a/R/onlineforecast-package.R +++ b/R/onlineforecast-package.R @@ -1,12 +1,6 @@ -#' Functions for online forecasting -#' -#' This package provides functions to for setting up forecast models which run in an online setting, e.g. like demand, solar and wind power forecasts updated regularly - often hourly, and forecasts up to 48 hours ahead. -#' -#' See the website \url{https://onlineforecasting.org} for more information. -#' -#' @title Functions for online forecasting -#' @docType package -#' @name onlineforecast -#' @useDynLib onlineforecast -#' @importFrom Rcpp sourceCpp +#' @keywords internal +"_PACKAGE" + +## usethis namespace: start +## usethis namespace: end NULL diff --git a/R/plot_ts.R b/R/plot_ts.R index 5290400..f46f360 100644 --- a/R/plot_ts.R +++ b/R/plot_ts.R @@ -277,6 +277,10 @@ plot_ts.data.frame <- function(object, patterns=".*", xlim = NA, ylims = NA, xla plot_ts.matrix <- plot_ts.data.frame +#' @rdname plot_ts +#' @param data The data.frame from where to find columns to plot +#' @param xnm The name of the column +#' @param pattern The regex pattern plot_ts_iseq <- function(data, pattern, xnm, namesdata){ iseq <- integer(0) # Use these names when finding columns to plot @@ -302,6 +306,14 @@ plot_ts_iseq <- function(data, pattern, xnm, namesdata){ # Plot all columns found with regex pattern #' @importFrom graphics plot lines axis title axis.POSIXct mtext par legend +#' @rdname plot_ts +#' @param iplot The plot index +#' @param ylim ylim in the plot +#' @param main main title +#' @param mainline line for the main title +#' @param colormap the colormap for the lines +#' @param legendtext Text for the legend +#' @param xaxis Boolean determining to include the xaxis plot_ts_series <- function(data, pattern, iplot = 1, ylim = NA, xlab = "", main = "", mainline = -1.2, colormap = NA, legendtext = NA, xat = NA, plotit = TRUE, p = NA, namesdata = NA, xaxis = TRUE, ...) { diff --git a/R/plotly_ts.R b/R/plotly_ts.R index 58dc346..f0f4db3 100644 --- a/R/plotly_ts.R +++ b/R/plotly_ts.R @@ -27,6 +27,8 @@ plotly_ts <- function(object, patterns=".*", xlim = NA, ylims = NA, xlab = "", y UseMethod("plotly_ts") } + +#' @inherit plotly_ts #' @export plotly_ts.data.list <- function(object, patterns=".*", xlim = NA, ylims = NA, xlab = "", ylabs = NA, mains = "", mainouter="", legendtexts = NA, colormaps = NA, xat = NA, usely=TRUE, p=NA, kseq = NA, ...) { @@ -34,6 +36,8 @@ plotly_ts.data.list <- function(object, patterns=".*", xlim = NA, ylims = NA, xl mains = mains, mainouter=mainouter, legendtexts = legendtexts, colormaps = colormaps, xat = xat, usely = usely, p = p, kseq=kseq, ...) } + +#' @inherit plotly_ts #' @export plotly_ts.data.frame <- function(object, patterns=".*", xlim = NA, ylims = NA, xlab = "", ylabs = NA, mains = "", mainouter="", legendtexts = NA, colormaps = NA, xat = NA, usely=TRUE, p=NA, namesdata=NA, ...) { diff --git a/R/resample.R b/R/resample.R index 0a60873..cc00303 100644 --- a/R/resample.R +++ b/R/resample.R @@ -57,6 +57,7 @@ resample <- function(object, ts, tstart=NA, tend=NA, timename="t", fun=mean, qua } #' @importFrom stats aggregate +#' @inherit resample #' @export resample.data.frame <- function(object, ts, tstart=NA, tend=NA, timename="t", fun=mean, quantizetime=TRUE, ...) { diff --git a/R/rls_summary.R b/R/rls_summary.R index 1c28e36..2b8f464 100644 --- a/R/rls_summary.R +++ b/R/rls_summary.R @@ -137,5 +137,6 @@ rls_summary <- function(object, scoreperiod = NA, scorefun = rmse, printit = TRU } #' @importFrom stats sd +#' @inherit rls_summary #' @export summary.rls_fit <- rls_summary diff --git a/cran-comments.md b/cran-comments.md index e1f26bf..1f1294c 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -1,3 +1,22 @@ +#---------------------------------------------------------------- +# v1.0.2 +Updated package documentation to fix: +You have file + 'onlineforecast/man/onlineforecast.Rd' with + \docType{package}, likely intended as a package + overview help file, but without the appropriate + PKGNAME-package \alias as per "Documenting packages" + in R-exts. + +From email: +From: Kurt Hornik + <Kurt.Hornik@wu.ac.at>Sent: 19 August 2023 10:53 + AMTo: Peder Bacher <pbac@dtu.dk>Cc: + Kurt.Hornik@R-project.org + <Kurt.Hornik@R-project.org>Subject: CRAN package + onlineforecast + + #---------------------------------------------------------------- # v1.0.1 diff --git a/inst/CITATION b/inst/CITATION index 7299dad..5a435fd 100644 --- a/inst/CITATION +++ b/inst/CITATION @@ -1,22 +1,18 @@ -citHeader("To cite onlineforecast in publications use:") -citEntry( - entry = "Article", - title = "onlineforecast: An R package for adaptive and recursive forecasting", +bibentry( + bibtype = "Article", + title = "Onlineforecast: An R Package for Adaptive and Recursive Forecasting", author = "Peder Bacher and Hjörleifur G. Bergsteinsson and Linde Frölke and Mikkel L. Sørensen and Julian Lemos-Vinasco and Jon Liisberg and Jan Kloppenborg Møller and Henrik Aalborg Nielsen and Henrik Madsen", - Journal = "test", - year = "2021", - eprint = "2109.12915", - archivePrefix="arXiv", - primaryClass="stat.CO", - url = "https://arxiv.org/abs/2109.12915", - textVersion = "The article \"onlineforecast: An R package for adaptive and recursive forecasting\", see https://arxiv.org/abs/2109.12915. This is the pre-print version submitted to Journal of Statistical Software." + journal = "R Journal", + year = "2023", + volume = "15/1", + pages = "173-194", + doi = "10.32614/RJ-2023-031", + url = "https://journal.r-project.org/articles/RJ-2023-031/" ) -citEntry( - entry = "Manual", +bibentry( + bibtype = "Manual", title = "{{onlineforecast}: Forecast Modelling for Online Applications}", author = "Peder Bacher and Hjörleifur G. Bergsteinsson", - year = "2022", - note = "R package version 1.0.1", url = "https://onlineforecasting.org", textVersion = "" ) diff --git a/make.R b/make.R index 36e1696..a167bcd 100644 --- a/make.R +++ b/make.R @@ -1,4 +1,4 @@ -#---------------------------------------------------------------- +## #---------------------------------------------------------------- ## # These packages must be installed ## install.packages("Rcpp") ## install.packages("R6") @@ -7,7 +7,7 @@ ## # cpp matrix library ## install.packages("RcppArmadillo") ## # For develop install -## install.packages("devtools") +## install.packages("devtools", type="source") ## install.packages("roxygen2") ## # For testing and building vignettes ## install.packages("rmarkdown") @@ -22,9 +22,9 @@ library(devtools) library(roxygen2) # Load the package directly -## document() -## pack <- as.package("../onlineforecast") -## load_all(pack) + document() + pack <- as.package("../onlineforecast") + load_all(pack) # ---------------------------------------------------------------- @@ -45,6 +45,8 @@ library(roxygen2) # Init new test #use_test("newtest") + + # # Run all tests document() test() @@ -60,10 +62,7 @@ run_examples() # The version (move the value from DESCRIPTION to other places, so only update it in DESCRIPTION) txt <- scan("DESCRIPTION", character()) (ver <- txt[which(txt == "Version:") + 1]) -# Update CITATION (change the year manually) -txt2 <- scan("inst/CITATION", character(), sep="#", quote="") -txt2[grep("R package version",txt2)] <- paste0(' note = "R package version ',ver,'",') -write.table(txt2, "inst/CITATION", row.names=FALSE, col.names=FALSE, quote=FALSE) +# Not needed to write elsewhere now # ---------------------------------------------------------------- # Build the package @@ -71,10 +70,11 @@ document() # Run the "vignettes/make.R" to build a cache build(".", vignettes=TRUE) -# Install it +# The file gzfile <- paste0("../onlineforecast_",ver,".tar.gz") -install.packages(gzfile) +# Install it +install.packages(gzfile) library(onlineforecast) # ---------------------------------------------------------------- @@ -163,3 +163,4 @@ unlink("onlineforecast.Rcheck/", recursive=TRUE) ## write(x, nm) ## } ## docit() + diff --git a/man/lagdf.character.Rd b/man/lagdf.character.Rd new file mode 100644 index 0000000..f1db238 --- /dev/null +++ b/man/lagdf.character.Rd @@ -0,0 +1,78 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/lagdf.R +\name{lagdf.character} +\alias{lagdf.character} +\title{Lagging which returns a data.frame} +\usage{ +\method{lagdf}{character}(x, lagseq) +} +\arguments{ +\item{x}{The data.frame to have columns lagged} + +\item{lagseq}{The sequence of lags as an integer. Alternatively, as a character "+k", "-k", "+h" or "-h", e.g. "k12" will with "+k" be lagged 12.} +} +\value{ +A data.frame. + +A data.frame with columns that are lagged +} +\description{ +Lagging by shifting the values back or fourth always returning a data.frame. + +Lagging of a data.frame +} +\details{ +This function lags (shifts) the values of the vector. A data.frame is always returned with the columns +as the vectors lagged with the values in lagseq. The column names are set to "kxx", where xx are the lag of the column. + +This function lags the columns with the integer values specified with the argument \code{lagseq}. +} +\examples{ +# The values are simply shifted +# Ahead in time +lagdf(1:10, 3) +# Back in time +lagdf(1:10, -3) +# Works but returns a numeric column +lagdf(as.factor(1:10), 3) +# Works and returns a character column +lagdf(as.character(1:10), 3) +# Giving several lag values +lagdf(1:10, c(1:3)) +lagdf(1:10, c(5,3,-1)) + +# See also how to lag a forecast data.frame with: ?lagdf.data.frame + + + +# dataframe of forecasts +X <- data.frame(k1=1:10, k2=1:10, k3=1:10) +X + +# Lag all columns +lagdf(X, 1) +\dontshow{if(!all(is.na(lagdf(X, 1)[1, ]))){stop("Lag all columns didn't work")}} + +# Lag each column different steps +lagdf(X, 1:3) +# Lag each columns with its k value from the column name +lagdf(X, "+k") +\dontshow{ + if(any(lagdf(X, 1:3) != lagdf(X, "+k"),na.rm=TRUE)){stop("Couldn't lag +k")} +} +# Also works for columns named hxx +names(X) <- gsub("k", "h", names(X)) +lagdf(X, "-h") + +# If lagseq must have length as columns in X, it doesn't know how to lag and an error is thrown +try(lagdf(X, 1:2)) + +\dontshow{ +if(!class(lagdf(data.frame(k1=1:10), 2)) == "data.frame"){stop("Trying to lag data.frame with 1 column, but return is not class data.frame")} +if(!all(dim(lagdf(data.frame(k1=1:10), "+k")) == c(10,1))){stop("Trying to lag data.frame with 1 column, but return is not class data.frame")} +} + +} +\seealso{ +\code{\link{lagdf.data.frame}} which is run when \code{x} is a data.frame. +} diff --git a/man/lagdf.factor.Rd b/man/lagdf.factor.Rd new file mode 100644 index 0000000..9709259 --- /dev/null +++ b/man/lagdf.factor.Rd @@ -0,0 +1,78 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/lagdf.R +\name{lagdf.factor} +\alias{lagdf.factor} +\title{Lagging which returns a data.frame} +\usage{ +\method{lagdf}{factor}(x, lagseq) +} +\arguments{ +\item{x}{The data.frame to have columns lagged} + +\item{lagseq}{The sequence of lags as an integer. Alternatively, as a character "+k", "-k", "+h" or "-h", e.g. "k12" will with "+k" be lagged 12.} +} +\value{ +A data.frame. + +A data.frame with columns that are lagged +} +\description{ +Lagging by shifting the values back or fourth always returning a data.frame. + +Lagging of a data.frame +} +\details{ +This function lags (shifts) the values of the vector. A data.frame is always returned with the columns +as the vectors lagged with the values in lagseq. The column names are set to "kxx", where xx are the lag of the column. + +This function lags the columns with the integer values specified with the argument \code{lagseq}. +} +\examples{ +# The values are simply shifted +# Ahead in time +lagdf(1:10, 3) +# Back in time +lagdf(1:10, -3) +# Works but returns a numeric column +lagdf(as.factor(1:10), 3) +# Works and returns a character column +lagdf(as.character(1:10), 3) +# Giving several lag values +lagdf(1:10, c(1:3)) +lagdf(1:10, c(5,3,-1)) + +# See also how to lag a forecast data.frame with: ?lagdf.data.frame + + + +# dataframe of forecasts +X <- data.frame(k1=1:10, k2=1:10, k3=1:10) +X + +# Lag all columns +lagdf(X, 1) +\dontshow{if(!all(is.na(lagdf(X, 1)[1, ]))){stop("Lag all columns didn't work")}} + +# Lag each column different steps +lagdf(X, 1:3) +# Lag each columns with its k value from the column name +lagdf(X, "+k") +\dontshow{ + if(any(lagdf(X, 1:3) != lagdf(X, "+k"),na.rm=TRUE)){stop("Couldn't lag +k")} +} +# Also works for columns named hxx +names(X) <- gsub("k", "h", names(X)) +lagdf(X, "-h") + +# If lagseq must have length as columns in X, it doesn't know how to lag and an error is thrown +try(lagdf(X, 1:2)) + +\dontshow{ +if(!class(lagdf(data.frame(k1=1:10), 2)) == "data.frame"){stop("Trying to lag data.frame with 1 column, but return is not class data.frame")} +if(!all(dim(lagdf(data.frame(k1=1:10), "+k")) == c(10,1))){stop("Trying to lag data.frame with 1 column, but return is not class data.frame")} +} + +} +\seealso{ +\code{\link{lagdf.data.frame}} which is run when \code{x} is a data.frame. +} diff --git a/man/lagdf.logical.Rd b/man/lagdf.logical.Rd new file mode 100644 index 0000000..d17a7f1 --- /dev/null +++ b/man/lagdf.logical.Rd @@ -0,0 +1,78 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/lagdf.R +\name{lagdf.logical} +\alias{lagdf.logical} +\title{Lagging which returns a data.frame} +\usage{ +\method{lagdf}{logical}(x, lagseq) +} +\arguments{ +\item{x}{The data.frame to have columns lagged} + +\item{lagseq}{The sequence of lags as an integer. Alternatively, as a character "+k", "-k", "+h" or "-h", e.g. "k12" will with "+k" be lagged 12.} +} +\value{ +A data.frame. + +A data.frame with columns that are lagged +} +\description{ +Lagging by shifting the values back or fourth always returning a data.frame. + +Lagging of a data.frame +} +\details{ +This function lags (shifts) the values of the vector. A data.frame is always returned with the columns +as the vectors lagged with the values in lagseq. The column names are set to "kxx", where xx are the lag of the column. + +This function lags the columns with the integer values specified with the argument \code{lagseq}. +} +\examples{ +# The values are simply shifted +# Ahead in time +lagdf(1:10, 3) +# Back in time +lagdf(1:10, -3) +# Works but returns a numeric column +lagdf(as.factor(1:10), 3) +# Works and returns a character column +lagdf(as.character(1:10), 3) +# Giving several lag values +lagdf(1:10, c(1:3)) +lagdf(1:10, c(5,3,-1)) + +# See also how to lag a forecast data.frame with: ?lagdf.data.frame + + + +# dataframe of forecasts +X <- data.frame(k1=1:10, k2=1:10, k3=1:10) +X + +# Lag all columns +lagdf(X, 1) +\dontshow{if(!all(is.na(lagdf(X, 1)[1, ]))){stop("Lag all columns didn't work")}} + +# Lag each column different steps +lagdf(X, 1:3) +# Lag each columns with its k value from the column name +lagdf(X, "+k") +\dontshow{ + if(any(lagdf(X, 1:3) != lagdf(X, "+k"),na.rm=TRUE)){stop("Couldn't lag +k")} +} +# Also works for columns named hxx +names(X) <- gsub("k", "h", names(X)) +lagdf(X, "-h") + +# If lagseq must have length as columns in X, it doesn't know how to lag and an error is thrown +try(lagdf(X, 1:2)) + +\dontshow{ +if(!class(lagdf(data.frame(k1=1:10), 2)) == "data.frame"){stop("Trying to lag data.frame with 1 column, but return is not class data.frame")} +if(!all(dim(lagdf(data.frame(k1=1:10), "+k")) == c(10,1))){stop("Trying to lag data.frame with 1 column, but return is not class data.frame")} +} + +} +\seealso{ +\code{\link{lagdf.data.frame}} which is run when \code{x} is a data.frame. +} diff --git a/man/lagdf.matrix.Rd b/man/lagdf.matrix.Rd new file mode 100644 index 0000000..5ad18b2 --- /dev/null +++ b/man/lagdf.matrix.Rd @@ -0,0 +1,78 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/lagdf.R +\name{lagdf.matrix} +\alias{lagdf.matrix} +\title{Lagging which returns a data.frame} +\usage{ +\method{lagdf}{matrix}(x, lagseq) +} +\arguments{ +\item{x}{The data.frame to have columns lagged} + +\item{lagseq}{The sequence of lags as an integer. Alternatively, as a character "+k", "-k", "+h" or "-h", e.g. "k12" will with "+k" be lagged 12.} +} +\value{ +A data.frame. + +A data.frame with columns that are lagged +} +\description{ +Lagging by shifting the values back or fourth always returning a data.frame. + +Lagging of a data.frame +} +\details{ +This function lags (shifts) the values of the vector. A data.frame is always returned with the columns +as the vectors lagged with the values in lagseq. The column names are set to "kxx", where xx are the lag of the column. + +This function lags the columns with the integer values specified with the argument \code{lagseq}. +} +\examples{ +# The values are simply shifted +# Ahead in time +lagdf(1:10, 3) +# Back in time +lagdf(1:10, -3) +# Works but returns a numeric column +lagdf(as.factor(1:10), 3) +# Works and returns a character column +lagdf(as.character(1:10), 3) +# Giving several lag values +lagdf(1:10, c(1:3)) +lagdf(1:10, c(5,3,-1)) + +# See also how to lag a forecast data.frame with: ?lagdf.data.frame + + + +# dataframe of forecasts +X <- data.frame(k1=1:10, k2=1:10, k3=1:10) +X + +# Lag all columns +lagdf(X, 1) +\dontshow{if(!all(is.na(lagdf(X, 1)[1, ]))){stop("Lag all columns didn't work")}} + +# Lag each column different steps +lagdf(X, 1:3) +# Lag each columns with its k value from the column name +lagdf(X, "+k") +\dontshow{ + if(any(lagdf(X, 1:3) != lagdf(X, "+k"),na.rm=TRUE)){stop("Couldn't lag +k")} +} +# Also works for columns named hxx +names(X) <- gsub("k", "h", names(X)) +lagdf(X, "-h") + +# If lagseq must have length as columns in X, it doesn't know how to lag and an error is thrown +try(lagdf(X, 1:2)) + +\dontshow{ +if(!class(lagdf(data.frame(k1=1:10), 2)) == "data.frame"){stop("Trying to lag data.frame with 1 column, but return is not class data.frame")} +if(!all(dim(lagdf(data.frame(k1=1:10), "+k")) == c(10,1))){stop("Trying to lag data.frame with 1 column, but return is not class data.frame")} +} + +} +\seealso{ +\code{\link{lagdf.data.frame}} which is run when \code{x} is a data.frame. +} diff --git a/man/lagdf.numeric.Rd b/man/lagdf.numeric.Rd new file mode 100644 index 0000000..198901e --- /dev/null +++ b/man/lagdf.numeric.Rd @@ -0,0 +1,78 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/lagdf.R +\name{lagdf.numeric} +\alias{lagdf.numeric} +\title{Lagging which returns a data.frame} +\usage{ +\method{lagdf}{numeric}(x, lagseq) +} +\arguments{ +\item{x}{The data.frame to have columns lagged} + +\item{lagseq}{The sequence of lags as an integer. Alternatively, as a character "+k", "-k", "+h" or "-h", e.g. "k12" will with "+k" be lagged 12.} +} +\value{ +A data.frame. + +A data.frame with columns that are lagged +} +\description{ +Lagging by shifting the values back or fourth always returning a data.frame. + +Lagging of a data.frame +} +\details{ +This function lags (shifts) the values of the vector. A data.frame is always returned with the columns +as the vectors lagged with the values in lagseq. The column names are set to "kxx", where xx are the lag of the column. + +This function lags the columns with the integer values specified with the argument \code{lagseq}. +} +\examples{ +# The values are simply shifted +# Ahead in time +lagdf(1:10, 3) +# Back in time +lagdf(1:10, -3) +# Works but returns a numeric column +lagdf(as.factor(1:10), 3) +# Works and returns a character column +lagdf(as.character(1:10), 3) +# Giving several lag values +lagdf(1:10, c(1:3)) +lagdf(1:10, c(5,3,-1)) + +# See also how to lag a forecast data.frame with: ?lagdf.data.frame + + + +# dataframe of forecasts +X <- data.frame(k1=1:10, k2=1:10, k3=1:10) +X + +# Lag all columns +lagdf(X, 1) +\dontshow{if(!all(is.na(lagdf(X, 1)[1, ]))){stop("Lag all columns didn't work")}} + +# Lag each column different steps +lagdf(X, 1:3) +# Lag each columns with its k value from the column name +lagdf(X, "+k") +\dontshow{ + if(any(lagdf(X, 1:3) != lagdf(X, "+k"),na.rm=TRUE)){stop("Couldn't lag +k")} +} +# Also works for columns named hxx +names(X) <- gsub("k", "h", names(X)) +lagdf(X, "-h") + +# If lagseq must have length as columns in X, it doesn't know how to lag and an error is thrown +try(lagdf(X, 1:2)) + +\dontshow{ +if(!class(lagdf(data.frame(k1=1:10), 2)) == "data.frame"){stop("Trying to lag data.frame with 1 column, but return is not class data.frame")} +if(!all(dim(lagdf(data.frame(k1=1:10), "+k")) == c(10,1))){stop("Trying to lag data.frame with 1 column, but return is not class data.frame")} +} + +} +\seealso{ +\code{\link{lagdf.data.frame}} which is run when \code{x} is a data.frame. +} diff --git a/man/lp.Rd b/man/lp.Rd index 7964f26..8cab84d 100644 --- a/man/lp.Rd +++ b/man/lp.Rd @@ -17,7 +17,7 @@ lp(X, a1, usestate = TRUE) The low-pass filtered dataframe (as a matrix) } \description{ -First-order low-pass filtering of a time series vector. +First-order low-pass filtering of time series. } \details{ This function applies a first order unity gain low-pass filter to the columns of \code{X}. diff --git a/man/lp_vector.Rd b/man/lp_vector.Rd new file mode 100644 index 0000000..4e3ed79 --- /dev/null +++ b/man/lp_vector.Rd @@ -0,0 +1,24 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/lp.R +\name{lp_vector} +\alias{lp_vector} +\title{First-order low-pass filtering} +\usage{ +lp_vector(x, a1) +} +\arguments{ +\item{x}{vector.} + +\item{a1}{The low-pass filter coefficient.} +} +\value{ +The low-pass filtered vector +} +\description{ +First-order low-pass filtering of a time series vector. +} +\details{ +This function applies a first order unity gain low-pass filter vector. + +The \code{lp_vector_cpp} function does the same much faster. +} diff --git a/man/onlineforecast-package.Rd b/man/onlineforecast-package.Rd new file mode 100644 index 0000000..bcbeee4 --- /dev/null +++ b/man/onlineforecast-package.Rd @@ -0,0 +1,28 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/onlineforecast-package.R +\docType{package} +\name{onlineforecast-package} +\alias{onlineforecast} +\alias{onlineforecast-package} +\title{onlineforecast: Forecast Modelling for Online Applications} +\description{ +A framework for fitting adaptive forecasting models. Provides a way to use forecasts as input to models, e.g. weather forecasts for energy related forecasting. The models can be fitted recursively and can easily be setup for updating parameters when new data arrives. See the included vignettes, the website \url{https://onlineforecasting.org} and the paper "onlineforecast: An R package for adaptive and recursive forecasting" \url{https://journal.r-project.org/articles/RJ-2023-031/}. +} +\seealso{ +Useful links: +\itemize{ + \item \url{https://onlineforecasting.org} + \item Report bugs at \url{https://lab.compute.dtu.dk/packages/onlineforecast/-/issues} +} + +} +\author{ +\strong{Maintainer}: Peder Bacher \email{pbac@dtu.dk} + +Authors: +\itemize{ + \item Hjorleifur G Bergsteinsson \email{hgbe@dtu.dk} +} + +} +\keyword{internal} diff --git a/man/onlineforecast.Rd b/man/onlineforecast.Rd deleted file mode 100644 index cf53df4..0000000 --- a/man/onlineforecast.Rd +++ /dev/null @@ -1,14 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/onlineforecast-package.R -\docType{package} -\name{onlineforecast} -\alias{onlineforecast} -\title{Functions for online forecasting} -\description{ -Functions for online forecasting -} -\details{ -This package provides functions to for setting up forecast models which run in an online setting, e.g. like demand, solar and wind power forecasts updated regularly - often hourly, and forecasts up to 48 hours ahead. - -See the website \url{https://onlineforecasting.org} for more information. -} diff --git a/man/plot_ts.Rd b/man/plot_ts.Rd index 0aa2369..3059a12 100644 --- a/man/plot_ts.Rd +++ b/man/plot_ts.Rd @@ -5,6 +5,8 @@ \alias{plot_ts.data.list} \alias{plot_ts.data.frame} \alias{plot_ts.matrix} +\alias{plot_ts_iseq} +\alias{plot_ts_series} \alias{plot_ts.rls_fit} \alias{plotly_ts} \title{Time series plotting} @@ -84,6 +86,26 @@ plot_ts( ... ) +plot_ts_iseq(data, pattern, xnm, namesdata) + +plot_ts_series( + data, + pattern, + iplot = 1, + ylim = NA, + xlab = "", + main = "", + mainline = -1.2, + colormap = NA, + legendtext = NA, + xat = NA, + plotit = TRUE, + p = NA, + namesdata = NA, + xaxis = TRUE, + ... +) + \method{plot_ts}{rls_fit}( object, patterns = c("^y$|^Yhat$", "^Residuals$", "CumAbsResiduals$", pst("^", @@ -156,6 +178,26 @@ plotly_ts( \item{namesdata}{For \code{class(object)=="data.frame"} a character vector. Names of columns in object to be searched in, instead of \code{names(object)}.} +\item{data}{The data.frame from where to find columns to plot} + +\item{pattern}{The regex pattern} + +\item{xnm}{The name of the column} + +\item{iplot}{The plot index} + +\item{ylim}{ylim in the plot} + +\item{main}{main title} + +\item{mainline}{line for the main title} + +\item{colormap}{the colormap for the lines} + +\item{legendtext}{Text for the legend} + +\item{xaxis}{Boolean determining to include the xaxis} + \item{fit}{An \code{rls_fit}.} } \value{ diff --git a/man/plotly_ts.data.frame.Rd b/man/plotly_ts.data.frame.Rd new file mode 100644 index 0000000..91f21dd --- /dev/null +++ b/man/plotly_ts.data.frame.Rd @@ -0,0 +1,140 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/plotly_ts.R +\name{plotly_ts.data.frame} +\alias{plotly_ts.data.frame} +\title{Time series plotting} +\usage{ +\method{plotly_ts}{data.frame}( + object, + patterns = ".*", + xlim = NA, + ylims = NA, + xlab = "", + ylabs = NA, + mains = "", + mainouter = "", + legendtexts = NA, + colormaps = NA, + xat = NA, + usely = TRUE, + p = NA, + namesdata = NA, + ... +) +} +\arguments{ +\item{object}{A \code{data.list} or \code{data.frame} with observations and forecasts, note diffe} + +\item{patterns}{See \code{\link{plot_ts}}. The default pattern finds the generated series in the function, '!!RLSinputs!!' will be replaced with the names of the RLS inputs (regression stage inputs).} + +\item{xlim}{The time range as a character of length 2 and form "YYYY-MM-DD" or POSIX. Date to start and end the plot.} + +\item{ylims}{The \code{ylim} for each plot given in a list.} + +\item{xlab}{A character with the label for the x-axis.} + +\item{ylabs}{A character vector with labels for the y-axes.} + +\item{mains}{A character vector with the main for each plot.} + +\item{mainouter}{A character with the main at the top of the plot (can also be added afterwards with \code{title(main, outer=TRUE)}).} + +\item{legendtexts}{A list with the legend texts for each plot (replaces the names of the variables).} + +\item{colormaps}{A list of colormaps, which will be used in each plot.} + +\item{xat}{POSIXt specifying where the ticks on x-axis should be put.} + +\item{usely}{If TRUE then plotly will be used.} + +\item{p}{The plot_ts parameters in a list, as generated with the function \code{\link{par_ts}()}.} + +\item{namesdata}{For \code{class(object)=="data.frame"} a character vector. Names of columns in object to be searched in, instead of \code{names(object)}.} + +\item{...}{Parameters passed to \code{\link{par_ts}}, see the list of parameters in \code{?\link{par_ts}}.} +} +\value{ +A list with a data.frame with the data for each plot, if usely=TRUE, then a list of the figures (drawn with print(subplot(L, shareX=TRUE, nrows=length(L), titleY = TRUE))). + +The plotted data in a \code{data.list}. +} +\description{ +Plot time series of observations and forecasts (lagged to be aligned in time). + +Plot forecasts, residuals, cumulated residuals and RLS coefficients + +Simply the same as \code{\link{plot_ts}()} with \code{usely=TRUE}, such that plotly is used. +} +\details{ +Generates time series plots depending on the variables matched by each regular expression given in the \code{patterns} argument. + +The forecasts matrices in the \code{data.list} given in \code{object} will be lagged to be aligned in time (i.e. k-step forecasts will be lagged by k). + +Use the plotly package if argument \code{usely} is TRUE, see \code{\link{plotly_ts}()}. + +A useful plot for residual analysis and model validation of an RLS fitted forecast model. + +All parameters, except those described below, are simply passed to \code{\link{plot_ts}()}. + +The \code{plotly} package must be installed and loaded. + +Note that the plot parameters set with \code{\link{par_ts}()} have no effect on the \code{plotly} plots. + +See \url{https://onlineforecasting.org/vignettes/nice-tricks.html}. +} +\examples{ + +# Time series plots for \code{data.list}, same as for \code{data.frame} except use of \code{kseq} +D <- Dbuilding +plot_ts(D, c("heatload","Ta"), kseq=c(1,24)) +# Make two plots (and set the space for the legend) +plot_ts(D, c("heatload","Ta"), kseq=c(1,24), legendspace=11) +# Only the Ta observations +plot_ts(D, c("heatload","Taobs$"), kseq=c(1,24), legendspace=11) + +# Give labels +plot_ts(D, c("heatload","Ta"), kseq=c(1,24), xlab="Time", ylabs=c("Heat (kW)","Temperature (C)")) +# Mains (see mainsline in par_ts()) +plot_ts(D, c("heatload","Ta"), kseq=c(1,24), mains=c("Heatload","Temperature"), mainsline=c(-1,-2)) + +# Format of the xaxis (see par_ts()) +plot_ts(D, c("heatload","Ta"), kseq=c(1,24), xaxisformat="\%Y-\%m-\%d \%H:\%m") + +# Return the data, for other plots etc. +L <- plot_ts(D, c("heatload","Ta"), kseq=c(1,24)) +names(L[[1]]) +names(L[[2]]) + + + +# Fit a model (see vignette 'setup-and-use-model' +D <- Dbuilding +D$scoreperiod <- in_range("2010-12-22", D$t) +model <- forecastmodel$new() +model$output = "heatload" +model$add_inputs(Ta = "Ta", + mu = "one()") +model$add_regprm("rls_prm(lambda=0.9)") +model$kseq <- c(3,18) +fit1 <- rls_fit(NA, model, D, returnanalysis = TRUE) + +# Plot it +plot_ts(fit1) + +# Return the data +Dplot <- plot_ts(fit1) + +# The RLS coefficients are now in a nice format +head(Dplot$mu) + + +# See the website link above + +} +\seealso{ +\code{\link{par_ts}} for setting plot control parameters. + +\code{\link{regex}} for regular expressions to select which variables to plot. + +\code{\link{plot_ts}}. +} diff --git a/man/plotly_ts.data.list.Rd b/man/plotly_ts.data.list.Rd new file mode 100644 index 0000000..4055ff0 --- /dev/null +++ b/man/plotly_ts.data.list.Rd @@ -0,0 +1,140 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/plotly_ts.R +\name{plotly_ts.data.list} +\alias{plotly_ts.data.list} +\title{Time series plotting} +\usage{ +\method{plotly_ts}{data.list}( + object, + patterns = ".*", + xlim = NA, + ylims = NA, + xlab = "", + ylabs = NA, + mains = "", + mainouter = "", + legendtexts = NA, + colormaps = NA, + xat = NA, + usely = TRUE, + p = NA, + kseq = NA, + ... +) +} +\arguments{ +\item{object}{A \code{data.list} or \code{data.frame} with observations and forecasts, note diffe} + +\item{patterns}{See \code{\link{plot_ts}}. The default pattern finds the generated series in the function, '!!RLSinputs!!' will be replaced with the names of the RLS inputs (regression stage inputs).} + +\item{xlim}{The time range as a character of length 2 and form "YYYY-MM-DD" or POSIX. Date to start and end the plot.} + +\item{ylims}{The \code{ylim} for each plot given in a list.} + +\item{xlab}{A character with the label for the x-axis.} + +\item{ylabs}{A character vector with labels for the y-axes.} + +\item{mains}{A character vector with the main for each plot.} + +\item{mainouter}{A character with the main at the top of the plot (can also be added afterwards with \code{title(main, outer=TRUE)}).} + +\item{legendtexts}{A list with the legend texts for each plot (replaces the names of the variables).} + +\item{colormaps}{A list of colormaps, which will be used in each plot.} + +\item{xat}{POSIXt specifying where the ticks on x-axis should be put.} + +\item{usely}{If TRUE then plotly will be used.} + +\item{p}{The plot_ts parameters in a list, as generated with the function \code{\link{par_ts}()}.} + +\item{kseq}{For \code{class(object)=="data.list"} an integer vector, default = NA. Control which forecast horizons to include in the plots. If NA all the horizons will be included.} + +\item{...}{Parameters passed to \code{\link{par_ts}}, see the list of parameters in \code{?\link{par_ts}}.} +} +\value{ +A list with a data.frame with the data for each plot, if usely=TRUE, then a list of the figures (drawn with print(subplot(L, shareX=TRUE, nrows=length(L), titleY = TRUE))). + +The plotted data in a \code{data.list}. +} +\description{ +Plot time series of observations and forecasts (lagged to be aligned in time). + +Plot forecasts, residuals, cumulated residuals and RLS coefficients + +Simply the same as \code{\link{plot_ts}()} with \code{usely=TRUE}, such that plotly is used. +} +\details{ +Generates time series plots depending on the variables matched by each regular expression given in the \code{patterns} argument. + +The forecasts matrices in the \code{data.list} given in \code{object} will be lagged to be aligned in time (i.e. k-step forecasts will be lagged by k). + +Use the plotly package if argument \code{usely} is TRUE, see \code{\link{plotly_ts}()}. + +A useful plot for residual analysis and model validation of an RLS fitted forecast model. + +All parameters, except those described below, are simply passed to \code{\link{plot_ts}()}. + +The \code{plotly} package must be installed and loaded. + +Note that the plot parameters set with \code{\link{par_ts}()} have no effect on the \code{plotly} plots. + +See \url{https://onlineforecasting.org/vignettes/nice-tricks.html}. +} +\examples{ + +# Time series plots for \code{data.list}, same as for \code{data.frame} except use of \code{kseq} +D <- Dbuilding +plot_ts(D, c("heatload","Ta"), kseq=c(1,24)) +# Make two plots (and set the space for the legend) +plot_ts(D, c("heatload","Ta"), kseq=c(1,24), legendspace=11) +# Only the Ta observations +plot_ts(D, c("heatload","Taobs$"), kseq=c(1,24), legendspace=11) + +# Give labels +plot_ts(D, c("heatload","Ta"), kseq=c(1,24), xlab="Time", ylabs=c("Heat (kW)","Temperature (C)")) +# Mains (see mainsline in par_ts()) +plot_ts(D, c("heatload","Ta"), kseq=c(1,24), mains=c("Heatload","Temperature"), mainsline=c(-1,-2)) + +# Format of the xaxis (see par_ts()) +plot_ts(D, c("heatload","Ta"), kseq=c(1,24), xaxisformat="\%Y-\%m-\%d \%H:\%m") + +# Return the data, for other plots etc. +L <- plot_ts(D, c("heatload","Ta"), kseq=c(1,24)) +names(L[[1]]) +names(L[[2]]) + + + +# Fit a model (see vignette 'setup-and-use-model' +D <- Dbuilding +D$scoreperiod <- in_range("2010-12-22", D$t) +model <- forecastmodel$new() +model$output = "heatload" +model$add_inputs(Ta = "Ta", + mu = "one()") +model$add_regprm("rls_prm(lambda=0.9)") +model$kseq <- c(3,18) +fit1 <- rls_fit(NA, model, D, returnanalysis = TRUE) + +# Plot it +plot_ts(fit1) + +# Return the data +Dplot <- plot_ts(fit1) + +# The RLS coefficients are now in a nice format +head(Dplot$mu) + + +# See the website link above + +} +\seealso{ +\code{\link{par_ts}} for setting plot control parameters. + +\code{\link{regex}} for regular expressions to select which variables to plot. + +\code{\link{plot_ts}}. +} diff --git a/man/resample.data.frame.Rd b/man/resample.data.frame.Rd new file mode 100644 index 0000000..20579b1 --- /dev/null +++ b/man/resample.data.frame.Rd @@ -0,0 +1,76 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/resample.R +\name{resample.data.frame} +\alias{resample.data.frame} +\title{Resampling to equidistant time series} +\usage{ +\method{resample}{data.frame}( + object, + ts, + tstart = NA, + tend = NA, + timename = "t", + fun = mean, + quantizetime = TRUE, + ... +) +} +\arguments{ +\item{object}{Can be data.frame} + +\item{ts}{(numeric) New sample period in seconds} + +\item{tstart}{A POSIXxx (or charater or numeric), which indicates the first time point in the series returned} + +\item{tend}{A POSIXxx (or charater or numeric), which indicates the last time point in the series returned} + +\item{timename}{(character) The name of the time column in object} + +\item{fun}{(function) The function of apply. Default is mean, such that average values are obtained} + +\item{quantizetime}{(logical) Should the new time points be set to the end of the time intervals, or should they also be the result of the fun function} + +\item{...}{Passed on to the fun function} +} +\value{ +A downsampled data.frame +} +\description{ +Make a downsampling to a lower sampling frequency +} +\details{ +Given an object with a column indicating the time points of the observations the +function returns a similar object, where the function is applied for each new (and longer) +interval. + +Typically it is used if for example 15 minute values should be made into 1 hour values. + +NOTE that it is always assumed that the time point is at the end of the time interval, +e.g. if hourly values are returned, then "2019-01-01 01:00" indicates the first hour in 2019. + +All time points at the time point (border) of between two intervals is assigned to the +first interval of the two. +} +\examples{ + +# Generate some test data with 10 minutes sampling frequency for one day +X <- data.frame(t=seq(ct("2019-01-01 00:10"),ct("2019-01-02"), by=10*60)) + +# A single sine over the day +X$val <- sin(as.numeric(X$t)/3600*2*pi/(24)) + +# Resample to hourly average values +Xre <- resample(X, 3600) +plot(X$t, X$val) +lines(Xre$t, Xre$val, type="b", col=2) + +# Resample to hourly max values +Xre <- resample(X, 3600, fun=max) +lines(Xre$t, Xre$val, type="b", col=3) + +# Another starting time point +Xre <- resample(X, 3600, tstart="2019-01-01 00:30") +lines(Xre$t, Xre$val, type="b", col=4) + + +} diff --git a/man/summary.rls_fit.Rd b/man/summary.rls_fit.Rd new file mode 100644 index 0000000..af700a5 --- /dev/null +++ b/man/summary.rls_fit.Rd @@ -0,0 +1,78 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/rls_summary.R +\name{summary.rls_fit} +\alias{summary.rls_fit} +\title{Print summary of an onlineforecast model fitted with RLS} +\usage{ +\method{summary}{rls_fit}(object, scoreperiod = NA, scorefun = rmse, printit = TRUE, ...) +} +\arguments{ +\item{object}{of class \code{rls_fit}, so a fit calculated by \code{\link{rls_fit}}.} + +\item{scoreperiod}{logical (or index). If this scoreperiod is given, then it will be used over the one in the fit.} + +\item{scorefun}{The score function to be applied on each horizon.} + +\item{printit}{Print the result.} + +\item{...}{Not used.} +} +\value{ +A list of: + + - scorefun. + + - scoreval (value of the scorefun for each horizon). + + - scoreperiod is the scoreperiod used. +} +\description{ +The summary of an onlineforecast model fitted with RLS with simple stats providing a simple overview. +} +\details{ +The following is printed: + +* The model. + +* Number of observations included in the scoreperiod. + +* RLS coefficients summary statistics for the estimated coefficient time series (since observations are correlated, then usual statistics cannot be applied directly): + + - mean: the sample mean of the series. + + - sd: sample standard deviation of the series. + + - min: minimum of the series. + + - max: maximum of the series. + +* Scorefunction applied for each horizon, per default the RMSE. +} +\examples{ + +# Take data +D <- subset(Dbuilding, c("2010-12-15", "2011-01-01")) +D$y <- D$heatload +D$scoreperiod <- in_range("2010-12-20", D$t) +# Define a model +model <- forecastmodel$new() +model$add_inputs(Ta = "Ta", + mu = "one()") +model$add_regprm("rls_prm(lambda=0.99)") +model$kseq <- 1:6 +# Fit it +fit <- rls_fit(prm=c(lambda=0.99), model, D) + +# Print the summary +summary(fit) +# We see: +# - The model (output, inputs, lambda) +# - The Ta coefficient is around -0.12 in average (for all horizons) with a standard dev. of 0.03, +# so not varying extremely (between -0.18 and -0.027). +# - The intercept mu is around 5.5 and varying very little. +# - The RMSE is around 0.9 for all horizons. + +# The residuals and coefficient series can be seen by +plot_ts(fit) + +} diff --git a/src/Makevars b/src/Makevars index d3e3f41..613c3b0 100644 --- a/src/Makevars +++ b/src/Makevars @@ -8,7 +8,9 @@ ## ## And with R 3.4.0, and RcppArmadillo 0.7.960.*, we turn C++11 on as OpenMP ## support within Armadillo prefers / requires it -CXX_STD = CXX11 +## +## In R 4.0, C++11 became the minimum supported compiler, so SystemRequirements: C++11 was no longer necessary. +#CXX_STD = CXX11 PKG_CXXFLAGS = $(SHLIB_OPENMP_CXXFLAGS) PKG_LIBS = $(SHLIB_OPENMP_CXXFLAGS) $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS) -- GitLab