Optimize Mean Squared Prediction Error of a time series forecast using metaheuristicOpt package in R

27 views Asked by At

I wish to combine three forecasts of a time series (f1,f2,f3) with weights assigned to each of the series. The objective is to find weights w1, w2, w3 which will minimise the Mean Squared Prediction Error of the combine forecasts Fc. I am using the 'metaheuristicOpt' package in R.

The error lies in these parts of my code :

ff <- function(weights) {
  Fc <- weights[1]*f1 + weights[2]*f2 + weights[3]*f3
  mse <- mean((Fc - F)^2)
}

resultPSO<-metaOpt(ff, optimType="MIN",algorithm="PSO",numVar,rangeVar,Vmax,ci) 

I am expecting a vector of the weights w1,w2,w3 that minimises mse.

I am receiving "Error in control[[i]] : subscript out of bounds" I need your help to resolve this.

0

There are 0 answers