Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request to make forecasting new values feature work #14

Open
muazhari opened this issue Mar 7, 2021 · 0 comments
Open

Request to make forecasting new values feature work #14

muazhari opened this issue Mar 7, 2021 · 0 comments

Comments

@muazhari
Copy link
Contributor

muazhari commented Mar 7, 2021

can someone make the regression_forecast() method works to get n new forecasted values based on the overall sample data?

you can find this block of code below in the source code, but it broke and not fixed until now.
and why this block code "buffer[i][1] -= buffer[i-1-j][1]*coeffs[j];" only calculate last coeff.length data points? why not the entire sample data points? this led to linear values.

please someone help me to make it work as soon as possible because I truly need it.


timeseries.prototype.regression_forecast = function(options) {
	options = _.extend({
		method:		'ARMaxEntropy',	// ARMaxEntropy | ARLeastSquare
		sample:		50,		// points int he sample
		start:		100,	// Where to start
		n:			5,		// How many points to forecast
		degree:		5
	},options);
	
	var i;
	var j;
	var l = this.data.length;
	
	var mean	= this.mean();
	this.offset(-mean);
	var backup 	= this.clone();
	var buffer 	= this.clone();
	
	var sample 		= buffer.slice(options.start-1-options.sample, options.start);
	
	// The current data to process is only a sample of the real data.
	this.data		= sample;
	// Get the AR coeffs
	var coeffs 		= this[options.method]({degree: options.degree});
	console.log("coeffs",coeffs);
	
	for (i=options.start;i<options.start+options.n;i++) {
		buffer[i][1]	= 0;
		for (j=0;j<coeffs.length;j++) {
			if (options.method == 'ARMaxEntropy') {
				buffer[i][1] -= buffer[i-1-j][1]*coeffs[j];
			} else {
				buffer[i][1] += buffer[i-1-j][1]*coeffs[j];
			}
		}
		console.log("buffer["+i+"][1]",buffer[i][1]);
	}
	this.data = buffer;
	this.offset(mean);
	
	return this;
}
@muazhari muazhari changed the title Request to make forecasting feature work Request to make forecasting features work Mar 7, 2021
@muazhari muazhari changed the title Request to make forecasting features work Request to make forecasting new values feature work Mar 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant