Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
onlineforecast
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
packages
onlineforecast
Commits
a58ec3c7
Commit
a58ec3c7
authored
4 years ago
by
pbac
Browse files
Options
Downloads
Patches
Plain Diff
v0.9.1 submitted
parent
103aa8ec
No related branches found
No related tags found
No related merge requests found
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
DESCRIPTION
+2
-3
2 additions, 3 deletions
DESCRIPTION
R/plot_ts.R
+0
-16
0 additions, 16 deletions
R/plot_ts.R
R/plotly_ts.R
+5
-8
5 additions, 8 deletions
R/plotly_ts.R
R/score.R
+4
-4
4 additions, 4 deletions
R/score.R
vignettes/forecast-evaluation.Rmd
+3
-3
3 additions, 3 deletions
vignettes/forecast-evaluation.Rmd
with
14 additions
and
34 deletions
DESCRIPTION
+
2
−
3
View file @
a58ec3c7
...
@@ -15,15 +15,14 @@ Imports:
...
@@ -15,15 +15,14 @@ Imports:
R6 (>= 2.2.2),
R6 (>= 2.2.2),
splines (>= 3.1.1),
splines (>= 3.1.1),
pbs,
pbs,
digest
,
digest
LinkingTo: Rcpp, RcppArmadillo
LinkingTo: Rcpp, RcppArmadillo
Suggests:
Suggests:
knitr,
knitr,
rmarkdown,
rmarkdown,
R.rsp,
R.rsp,
testthat (>= 2.1.0),
testthat (>= 2.1.0),
data.table,
data.table
plotly
VignetteBuilder: knitr
VignetteBuilder: knitr
RoxygenNote: 7.1.1
RoxygenNote: 7.1.1
URL: http://onlineforecasting.org
URL: http://onlineforecasting.org
...
...
This diff is collapsed.
Click to expand it.
R/plot_ts.R
+
0
−
16
View file @
a58ec3c7
...
@@ -60,17 +60,6 @@
...
@@ -60,17 +60,6 @@
#' names(L[[2]])
#' names(L[[2]])
#'
#'
#'
#'
#' # Use plotly
#' \donttest{library(plotly)
#' L <- plot_ts(D, c("heatload","Ta"), kseq=c(1,24), usely=TRUE, xlab="Time",
#' ylabs=c("Heat (kW)","Temperature (C)"))
#'
#' # From plotly the figures are returned and can be further manipulated
#' # e.g. put the legend in the top by
#' L[[length(L)]] <- L[[length(L)]] %>% layout(legend = list(x = 100, y = 0.98))
#' print(subplot(L, shareX=TRUE, nrows=length(L), titleY = TRUE))
#' }
#'
#' @rdname plot_ts
#' @rdname plot_ts
#' @export
#' @export
plot_ts
<-
function
(
object
,
patterns
=
".*"
,
xlim
=
NA
,
ylims
=
NA
,
xlab
=
""
,
ylabs
=
NA
,
plot_ts
<-
function
(
object
,
patterns
=
".*"
,
xlim
=
NA
,
ylims
=
NA
,
xlab
=
""
,
ylabs
=
NA
,
...
@@ -474,11 +463,6 @@ plot_ts_series <- function(data, pattern, iplot = 1,
...
@@ -474,11 +463,6 @@ plot_ts_series <- function(data, pattern, iplot = 1,
#' # Plot it
#' # Plot it
#' plot_ts(fit1)
#' plot_ts(fit1)
#'
#'
#' # Plot it with plotly
#' \donttest{
#' plot_ts(fit1, usely=TRUE)
#' }
#'
#' # Return the data
#' # Return the data
#' Dplot <- plot_ts(fit1)
#' Dplot <- plot_ts(fit1)
#'
#'
...
...
This diff is collapsed.
Click to expand it.
R/plotly_ts.R
+
5
−
8
View file @
a58ec3c7
...
@@ -9,19 +9,16 @@
...
@@ -9,19 +9,16 @@
#'
#'
#' Simply the same as \code{\link{plot_ts}()} with \code{usely=TRUE}, such that plotly is used.
#' Simply the same as \code{\link{plot_ts}()} with \code{usely=TRUE}, such that plotly is used.
#'
#'
#' The \code{plotly} package must be loaded.
#' 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.
#' Note that the plot parameters set with \code{\link{par_ts}()} have no effect on the \code{plotly} plots.
#'
#'
#' See \url{http://https://onlineforecasting.org/vignettes/nice-tricks.html}.
#'
#' @rdname plot_ts
#' @rdname plot_ts
#' @examples
#' @examples
#'
#'
#' \donttest{
#' # See the website link above
#' D <- Dbuilding
#' plotly_ts(D, c("heatload","Ta"), kseq=c(1,24))
#' plotly_ts(D, c("heatload","Ta"), kseq=c(1,24))
#' plotly_ts(D, c("heatload","Ta$|Taobs$"), kseq=c(1,24))
#' }
#'
#'
#' @export
#' @export
...
...
This diff is collapsed.
Click to expand it.
R/score
_for_k
.R
→
R/score.R
+
4
−
4
View file @
a58ec3c7
...
@@ -24,7 +24,7 @@
...
@@ -24,7 +24,7 @@
#' Resid <- residuals(Yhat, y)
#' Resid <- residuals(Yhat, y)
#'
#'
#' # Calculate the score for the k1 horizon
#' # Calculate the score for the k1 horizon
#' score(Resid)$val
#' score(Resid)$
score
val
#'
#'
#' # The first values were excluded, since there are NAs
#' # The first values were excluded, since there are NAs
#' head(Resid)
#' head(Resid)
...
@@ -50,10 +50,10 @@ score <- function(Residuals, scoreperiod = NA, usecomplete = TRUE, scorefun = rm
...
@@ -50,10 +50,10 @@ score <- function(Residuals, scoreperiod = NA, usecomplete = TRUE, scorefun = rm
scoreperiod
<-
scoreperiod
&
complete.cases
(
Residuals
)
scoreperiod
<-
scoreperiod
&
complete.cases
(
Residuals
)
}
}
# Calculate the objective function for each horizon
# Calculate the objective function for each horizon
val
<-
sapply
(
1
:
ncol
(
Residuals
),
function
(
i
){
score
val
<-
sapply
(
1
:
ncol
(
Residuals
),
function
(
i
){
scorefun
(
Residuals
[
scoreperiod
,
i
])
scorefun
(
Residuals
[
scoreperiod
,
i
])
})
})
nams
(
val
)
<-
gsub
(
"h"
,
"k"
,
nams
(
Residuals
))
nams
(
score
val
)
<-
gsub
(
"h"
,
"k"
,
nams
(
Residuals
))
#
#
return
(
list
(
val
=
val
,
scoreperiod
=
scoreperiod
))
return
(
list
(
scoreval
=
score
val
,
scoreperiod
=
scoreperiod
))
}
}
This diff is collapsed.
Click to expand it.
vignettes/forecast-evaluation.Rmd
+
3
−
3
View file @
a58ec3c7
...
@@ -326,14 +326,14 @@ Now the residuals can be calculated and the score:
...
@@ -326,14 +326,14 @@ Now the residuals can be calculated and the score:
# Use the residuals function
# Use the residuals function
R <- residuals(D$Yhat1, D$y)
R <- residuals(D$Yhat1, D$y)
# And the score as a function of the horizon
# And the score as a function of the horizon
score(R, scoreperiod=ok)$val
score(R, scoreperiod=ok)$
score
val
```
```
Calculated the score (default is RMSE) for all models:
Calculated the score (default is RMSE) for all models:
```{r}
```{r}
RMSE <- sapply(nms, function(nm){
RMSE <- sapply(nms, function(nm){
score(residuals(D[[nm]],D$y), ok)$val
score(residuals(D[[nm]],D$y), ok)$
score
val
})
})
```
```
...
@@ -386,7 +386,7 @@ fittmp <- rls_fit(model$prm, model, D)
...
@@ -386,7 +386,7 @@ fittmp <- rls_fit(model$prm, model, D)
Finally, the score can be calculated on the period following the train period by:
Finally, the score can be calculated on the period following the train period by:
```{r scorefit}
```{r scorefit}
score_fit(fittmp, !D$trainperiod)$val
score_fit(fittmp, !D$trainperiod)$
score
val
```
```
In this way it's rather easy to set up different schemes, like optimizing the
In this way it's rather easy to set up different schemes, like optimizing the
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment