Description Usage Arguments Details Value Author(s) Examples

View source: R/forecasting_ga.R

This function is not called directly by the user but it is called by the forecasting_ga() for applying forecast operations using ARIMA. A new forecast function can be written by changing some lines of this function. The basic idea is to pass a chromosome's anchestors to the function, perform a forecast, return the forecasted offspring if there is not error, else return the original chromosome as the offspring.

1 2 | ```
ForecastArima(genes, Anchestors, MinimumForecastLength = 5,
forecastprob, robust.filter.width=5)
``` |

`genes` |
Vector of values of chromosome |

`Anchestors` |
Anchestor matrix of the chromosome |

`MinimumForecastLength` |
If number of anchestors of the chromosome is less than the MinimumForecastLength, then statistical forecast will not be performed. The default is 5. |

`forecastprob` |
A gene will be forecasted if a uniform random variable is less than the forecastprob. |

`robust.filter.width` |
Robust filtering parameter. Default is 5. |

Anchestor matrix is an nxp matrix of historical gene values where n is the number of anchestors and p is the number of genes. Robust filtering is required to eliminate the sudden shifts which most probably happens in very early generations. Current version uses repeated medians as the robust filtering method. Any other robust filtering functions in package robfilter can be used in new forecasting functions rather than ForecastArima.

Returns a vector of values of a single offspring which is forecasted.

Mehmet Hakan Satman <[email protected]>

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | ```
# Required package forega
require("forega")
set.seed(12345)
# This function has the global minimum at x_1 = pi and x_2 = exp(1)
f <- function (x){
return( (x[1]-pi)^2 + (x[2]-2.71828)^2 )
}
# Performing a floating-point genetic algorithm search with forecast probability of 0.10
res <- forecasting_ga(evalFunc=f, chsize=2, minv=rep(-10.0,2),
maxv=rep(10.0,2), crossprob=0.80, mutationprob=0.01,
popsize=100, maxiter=1000, MinimumForecastLength=20,
ForecastFunction=ForecastArima, elitism=2, forecastprob=0.01)
# Show the first chromosome of the returned population matrix
print(res[1,])
``` |

forega documentation built on Nov. 23, 2017, 5:05 p.m.

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.