1
$\begingroup$

I am trying to make a prediction of imbalance prices in the elctricity market. My dataset consists of data for every 15 minutes (this is the time period in which a price is determined) during 11 months. I have several exogenous factors (like the spot market price) included mentioned here as x1 etc.

In forecasting the price I am using the following code:

lag <- function(x, k){c(rep(NA, k), x)[1 : length(x)]}
mydata$y_lag1 <- lag(mydata$y, 1)
mydata$y_lag2 <- lag(mydata$y, 2)
mydata$x1_lag1 <- lag(mydata$x1, 1)
mydata$x2_lag1 <- lag(mydata$x2, 1)
mydata$x3_lag1 <- lag(mydata$x3, 1

f<- y ~ y_lag1 + y_lag2 + x1_lag1 + x2_lag1 + x3_lag1
fit <- lm(formula = f, data = mydata)
mydata$P_imb_pred <- predict(fit, newdata = mydata)

pred <- data.frame(time=mydata$time, price=mydata$P_imb_pred)

My code works, but I am unsure if it does wat I want it to. I am trying to predict the price only 1 time unit (so 15 minutes) ahead. That's why I have lagged variables in the function. Can someone help me out? Should I additionally specify how much time ahead I want to forecast? If so, can you tell me how?

Thanks for your help!

$\endgroup$

migrated from stackoverflow.com Dec 11 '15 at 3:56

This question came from our site for professional and enthusiast programmers.

1
$\begingroup$

If you want to predict the price 1 step ahead it does what you want. But is the price of the electricity market stationary? my guess is not so you will have to work with returns and because you are working with time series you should use a model of time series like an ARMA(p,q) or a GARCH or a mix of both to control for the volatility. There is ton of information about time series models in R.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy