Commit 33ed4ec0 authored by pbac's avatar pbac
Browse files

Changed ones() to one()

parent 68071df1
......@@ -2,7 +2,7 @@
^\.Rproj\.user$
^make.R
^data/all
^vignettes/tmp-output
^tmp
^vignettes/make.R
^vignettes/shared-init.Rmd
^vignettes/cache
......
......@@ -21,15 +21,5 @@ misc-R/*cache*
vignettes/*cache*
vignettes/*genfig*
vignettes/*_files*
vignettes/tmp-output/
vignettes/setup-data_cache/
vignettes/solar-forecasting_cache-rls/
vignettes/building-heat-load-forecasting_cache/
vignettes/onlineforecasting_pdf_source/onlineforecasting\.tex
vignettes/onlineforecasting_pdf_source/*cache*
vignettes/onlineforecasting_pdf_source/*genfig*
vignettes/onlineforecasting_pdf_source/onlineforecasting-tikzDictionary
vignettes/onlineforecasting_pdf_source/onlineforecasting.log
vignettes/onlineforecasting_pdf_source/onlineforecasting.pdf
tmp/
......@@ -17,7 +17,7 @@
#'
#' @param X data.frame (as part of data.list) with horizons as columns named \code{kxx} (i.e. one for each horizon)
#' @param Boundary.knots The value is NA: then the boundaries are set to the range of each horizons (columns in X). See \code{?splines::bs}
#' @param intercept Default value is TRUE: in an onlineforecast model there is no intercept per defauls (set by \code{ones()}. See \code{?splines::bs}
#' @param intercept Default value is TRUE: in an onlineforecast model there is no intercept per defauls (set by \code{one()}. See \code{?splines::bs}
#' @param df See \code{?splines::bs}
#' @param knots See \code{?splines::bs}
#' @param degree See \code{?splines::bs}
......
......@@ -133,7 +133,7 @@ forecastmodel <- R6::R6Class("forecastmodel", public = list(
# Keep the prm
self$prm <- prm
# Find if any opt parameters, first the ones with "__" hence for the inputs
# Find if any opt parameters, first the one with "__" hence for the inputs
pinputs <- prm[grep("__",nams(prm))]
# If none found for inputs, then the rest must be for regression
if (length(pinputs) == 0 & length(prm) > 0) {
......
......@@ -8,7 +8,7 @@ input_class <- R6::R6Class(
state_L = list(),
state_i = integer(1),
## The model in which it is included (reference to the R6 forecastmodel object), its needed here,
## since transformation functions (like AR, ones) need to access information about the model (like kseq)
## since transformation functions (like AR, one) need to access information about the model (like kseq)
model = NA,
## methods
......
......@@ -38,7 +38,7 @@
#' model <- forecastmodel$new()
#' model$output <- "y"
#' model$add_inputs(Ta = "Ta",
#' mu = "ones()")
#' mu = "one()")
#' model$add_regprm("rls_prm(lambda=0.99)")
#'
#' # Before fitting the model, define which points to include in the evaluation of the score function
......@@ -79,7 +79,7 @@ lm_fit <- function(prm=NA, model, data, scorefun = NA, returnanalysis = TRUE, pr
# - If scorefun is given, e.g. rmse() then the value of this is returned
if(printout){
# Should here actually only print the ones that were found and changed?
# Should here actually only print the one that were found and changed?
cat("----------------\n")
if(is.na(prm[1])){
cat("prm=NA, so current parameters are used.\n")
......
......@@ -28,7 +28,7 @@
#' # Define a simple model
#' model <- forecastmodel$new()
#' model$add_inputs(Ta = "lp(Ta, a1=0.9)",
#' mu = "ones()")
#' mu = "one()")
#' # Before fitting the model, define which points to include in the evaluation of the score function
#' D$scoreperiod <- in_range("2010-12-20", D$t)
#' # And the sequence of horizons to fit for
......
......@@ -14,7 +14,7 @@
#' D$y <- D$heatload
#' # Define a model
#' model <- forecastmodel$new()
#' model$add_inputs(Ta = "lp(Ta, a1=0.7)", mu = "ones()")
#' model$add_inputs(Ta = "lp(Ta, a1=0.7)", mu = "one()")
#'
#' # Before fitting the model, define which points to include in the evaluation of the score function
#' D$scoreperiod <- in_range("2010-12-20", D$t)
......
......@@ -21,7 +21,7 @@
#' # Define a model
#' model <- forecastmodel$new()
#' model$add_inputs(Ta = "Ta",
#' mu = "ones()")
#' mu = "one()")
#' model$add_regprm("rls_prm(lambda=0.99)")
#' model$kseq <- 1:6
#' # Fit it
......
......@@ -2,7 +2,7 @@
#library(devtools)
#document()
#load_all(as.package("../../onlineforecast"))
#?ones
#?one
#' Returns a data.frame of ones which can be used in forecast model inputs
#'
......@@ -12,26 +12,26 @@
#'
#' @title Create ones for model input intercept
#' @return A data.frame of ones
#' @name ones
#' @name one
#' @examples
#'
#' # A model
#' model <- forecastmodel$new()
#' # Use the function in the input definition
#' model$add_inputs(mu = "ones()")
#' model$add_inputs(mu = "one()")
#' # Set the forecast horizons
#' model$kseq <- 1:4
#' # During the transformation stage the ones will be generated for the horizons
#' # During the transformation stage the one will be generated for the horizons
#' model$transform_data(subset(Dbuilding, 1:7))
#'
#' @export
ones <- function(){
one <- function(){
# To find kseq, get the model (remember it is call per reference, so don't change it without cloning)
model <- get("self", parent.env(parent.frame(4)))
# Get the data to find the all the names with k in data
data <- get("data", parent.env(parent.frame()))
n <- length(data$t)
# Generate the matrix of ones and return it as a data.frame
# Generate the matrix of one and return it as a data.frame
as.data.frame(matrix(1, nrow=n, ncol=length(model$kseq), dimnames=list(NULL, pst("k",model$kseq))))
}
......@@ -466,7 +466,7 @@ plot_ts_series <- function(data, pattern, iplot = 1,
#' model <- forecastmodel$new()
#' model$output = "heatload"
#' model$add_inputs(Ta = "Ta",
#' mu = "ones()")
#' mu = "one()")
#' model$add_regprm("rls_prm(lambda=0.9)")
#' model$kseq <- c(3,18)
#' fit1 <- rls_fit(NA, model, D, returnanalysis = TRUE)
......
......@@ -54,7 +54,7 @@
#' model <- forecastmodel$new()
#' model$output <- "y"
#' model$add_inputs(Ta = "Ta",
#' mu = "ones()")
#' mu = "one()")
#' model$add_regprm("rls_prm(lambda=0.99)")
#'
#' # Before fitting the model, define which points to include in the evaluation of the score function
......
......@@ -27,7 +27,7 @@
#' D$y <- D$heatload
#' # Define a simple model
#' model <- forecastmodel$new()
#' model$add_inputs(Ta = "Ta", mu = "ones()")
#' model$add_inputs(Ta = "Ta", mu = "one()")
#' model$add_regprm("rls_prm(lambda=0.99)")
#'
#' # Before fitting the model, define which points to include in the evaluation of the score function
......
......@@ -13,7 +13,7 @@
#' D$y <- D$heatload
#' # Define a simple model
#' model <- forecastmodel$new()
#' model$add_inputs(Ta = "Ta", mu = "ones()")
#' model$add_inputs(Ta = "Ta", mu = "one()")
#' model$add_regprm("rls_prm(lambda=0.99)")
#'
#' # Before fitting the model, define which points to include in the evaluation of the score function
......
......@@ -18,7 +18,7 @@
#' D$scoreperiod <- in_range("2010-12-20", D$t)
#' # Define a simple model
#' model <- forecastmodel$new()
#' model$add_inputs(Ta = "Ta", mu = "ones()")
#' model$add_inputs(Ta = "Ta", mu = "one()")
#' model$kseq <- 1:6
#'
#' # Here the expression which sets the parameters is defined
......
......@@ -47,7 +47,7 @@
#' # Define a model
#' model <- forecastmodel$new()
#' model$add_inputs(Ta = "Ta",
#' mu = "ones()")
#' mu = "one()")
#' model$add_regprm("rls_prm(lambda=0.99)")
#' model$kseq <- 1:6
#' # Fit it
......
......@@ -8,7 +8,7 @@ D <- subset(Dbuilding, c("2010-12-15", "2011-01-01"))
D$y <- D$heatload
# Define a model
model <- forecastmodel$new()
model$add_inputs(Ta = "lp(Ta, a1=0.7)", mu = "ones()")
model$add_inputs(Ta = "lp(Ta, a1=0.7)", mu = "one()")
# Before fitting the model, define which points to include in the evaluation of the score function
D$scoreperiod <- in_range("2010-12-20", D$t)
......
......@@ -23,7 +23,7 @@ test_that("run", {
model$add_inputs(Ta = "lp(Ta, a1=0.9)",
I = "lp(I, a1=0.7)",
mu_tday = "fs(tday/24, nharmonics=10)",
mu = "ones()")
mu = "one()")
model$add_regprm("rls_prm(lambda=0.9)")
## ------------------------------------------------------------------------
......
......@@ -45,9 +45,9 @@ knitr::opts_chunk$set(
comment = "## ",
prompt = FALSE,
cache = TRUE,
cache.path = paste0("tmp-output/tmp-",vignettename,"/"),
cache.path = paste0("../tmp/vignettes/tmp-",vignettename,"/"),
fig.align="center",
fig.path = paste0("tmp-output/tmp-",vignettename,"/"),
fig.path = paste0("../tmp/vignettes/tmp-",vignettename,"/"),
fig.height = figheight,
fig.width = figwidth,
out.width = "100%"
......@@ -166,7 +166,7 @@ model <- forecastmodel$new()
model$output = "y"
model$add_inputs(Ta = "lp(Ta, a1=0.9)",
I = "lp(I, a1=0.9)",
mu = "ones()")
mu = "one()")
model$add_prmbounds(Ta__a1 = c(0.8, 0.9, 0.99),
I__a1 = c(0.6, 0.9, 0.99),
lambda = c(0.9, 0.99, 0.9999))
......
......@@ -4,8 +4,11 @@ library(knitr)
library(rmarkdown)
# Put the files in this dir (ignored in the git)
dirnam <- "tmp-output/"
dirnam <- "../tmp/vignettes/"
dir.create("../tmp")
dir.create(dirnam)
file.remove(dir("cache", full.names=TRUE))
file.remove("cache")
makeit <- function(nam, openit=FALSE, clean=TRUE){
namrmd <- paste0(nam,".Rmd")
......@@ -15,19 +18,18 @@ makeit <- function(nam, openit=FALSE, clean=TRUE){
if(openit){ system(paste0("chromium-browser ",dirnam,nam,".html &")) }
}
file.remove(dir("tmp-output/tmp-setup-data/", full.names=TRUE))
#
file.remove(dir(paste0(dirnam,"tmp-setup-data/"), full.names=TRUE))
makeit("setup-data", openit=FALSE)
#
file.remove(dir("cache", full.names=TRUE))
file.remove("cache")
file.remove(dir("tmp-output/tmp-setup-and-use-model/", full.names=TRUE))
file.remove(dir(paste0(dirnam,"tmp-setup-and-use-model/"), full.names=TRUE))
makeit("setup-and-use-model", openit=FALSE, clean=TRUE)
#
file.remove(dir("tmp-output/tmp-forecast-evaluation/", full.names=TRUE))
file.remove(dir(paste0(dirnam,"tmp-output/tmp-forecast-evaluation/"), full.names=TRUE))
makeit("forecast-evaluation", openit=FALSE)
# Finish and include it!!
## file.remove(dir("tmp-output/tmp-online-updating/", full.names=TRUE))
## file.remove(dir(paste0(dirnam,"tmp-output/tmp-online-updating/"), full.names=TRUE))
## makeit("online-updating", openit=FALSE)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment