I am trying to construct a multiple linear regression model
that i am going to use for future prediction
.
In My code, i constructed the model using DF
data where Y
is my response variable while X1
and X2
independent variables. After fitting the model, i want to use the model (ie coefficients) to predict
the year 2017 response variable (ie., Y
). I would then want to plot the predicted value for the 2017 against the actual value of Y
(ie DF$Actual
) to see my model performance.
library(lubridate)
set.seed(1500)
DF <- data.frame(Date = seq(as.Date("2000-01-01"), to = as.Date("2010-12-31"), by = "days"),
Y = runif(4018, 0,50), X1 = runif(4018, 2,45), X2 = runif(4018, 12, 55))
DF1 <- data.frame(Date = seq(as.Date("2017-01-01"), to = as.Date("2017-09-30"), by = "days"),
Actual = runif(273, 0,50), X1 = runif(273, 2,45), X2 = runif(273, 12, 55))
ML_Model <- lm(data = DF, Y~X1+X2)
#summary(ML_Model)
Pred_Model <- predict(ML_Model, data.frame(X1 = DF1$X1, X2 = DF1$X2))
# plot the prected Y vs Acutal Y from DF1.......