Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/lm_predict.R
\name{lm_predict}
\alias{lm_predict}
\title{Prediction with an lm forecast model.}
\usage{
lm_predict(model, datatr)
}
\arguments{
\item{model}{Onlineforecast model object which has been fitted.}
\item{datatr}{Transformed data.}
}
\value{
The Yhat forecast matrix with a forecast for each model$kseq and for each time point in \code{datatr$t}.
}
\description{
Use a fitted forecast model to predict its output variable with transformed data.
}
\details{
See the ??ref(recursive updating vignette, not yet available).
}
\examples{
# Take data
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 = "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
model$kseq <- 1:6
# Transform using the mdoel
datatr <- model$transform_data(D)
# See the transformed data
str(datatr)
# The model has not been fitted
model$Lfits
# To fit
lm_fit(model=model, data=D)
# Now the fits for each horizon are there (the latest update)
# For example
summary(model$Lfits$k1)
# Use the fit for prediction
D$Yhat <- lm_predict(model, datatr)
# Plot it
plot_ts(D, c("y|Yhat"), kseq=1)
}