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

ARIMA forecast returns same repeated value for future. #180

Open
jgustave opened this issue Nov 24, 2016 · 2 comments
Open

ARIMA forecast returns same repeated value for future. #180

jgustave opened this issue Nov 24, 2016 · 2 comments

Comments

@jgustave
Copy link

jgustave commented Nov 24, 2016

Hello,
I've noticed in some cases that ARIMA.forecast will return the same value continuously for the future part of the forecast. Seems suspicious to me. (This is using a fresh build off of master, but I've also seen it in 0.4.1, and is fairly common) (Scala 2.11.7)

Here is a scala unit test:

package junk

import com.cloudera.sparkts.models.ARIMA
import org.apache.spark.mllib.linalg.Vectors
import org.junit.Test

class ArimaTest {
  
  @Test
  def testArimaFoo() {

    val data = Seq(32.284, 32.0722, 31.9126, 33.1172, 33.5671,
                   34.0824, 34.4891, 34.4198, 33.4821, 32.836,
                   32.5691, 31.808, 32.7928, 33.142, 33.2493,
                   33.9647, 34.4421, 35.5485, 35.8389, 35.3523,
                   35.8036)
    val dv = Vectors.dense(data.toArray)
    val model = ARIMA.autoFit( dv )

    println("p="+model.p+" q="+model.q+" d="+model.d+" Invertible:"+model.isInvertible()+ " intercept="+ model.hasIntercept + " stationary:" + model.isStationary())
    println("Coeffs"+model.coefficients.mkString(","))
    println("AIC:" + model.approxAIC(dv) )

    println("###")
    println("Values:"+ data.mkString(","))
    println("Forecast:"+model.forecast(dv,5).toArray.mkString(","))
  }
}


And this is the stdout:

Nov 23, 2016 5:19:22 PM com.github.fommil.jni.JniLoader liberalLoad
INFO: successfully loaded /var/folders/3c/7jzx8fts1_ngxgv3nqpdxc600000gn/T/jniloader5183904765086523584netlib-native_system-osx-x86_64.jnilib
Warning: MA parameters are not invertible
p=0 q=1 d=1 Invertable:true intercept=false stationary:true
AIC:37.874997884062026
Coeffs0.31643668642971895

Values:32.284,32.0722,31.9126,33.1172,33.5671,34.0824,34.4891,34.4198,33.4821,32.836,32.5691,31.808,32.7928,33.142,33.2493,33.9647,34.4421,35.5485,35.8389,35.3523,35.8036
Forecast:32.284,32.216978709814185,32.04290469983246,32.30304974018622,33.13601224322286,33.72420694060749,34.161380400670026,34.44217864134951,34.137924958389,33.36684586105238,32.7880136862178,32.34344466808555,32.19103247430219,32.7820941639381,33.1793413757428,33.46386262426504,34.04787138824745,34.76588707136306,35.537935105768284,35.688265028506464,35.8036,35.994074307825585,35.994074307825585,35.994074307825585,35.994074307825585,35.994074307825585

@jgustave jgustave changed the title ARIMA forecast returns same value ARIMA forecast returns same repeated value for future. Nov 24, 2016
@jgustave
Copy link
Author

I suppose this is because P is 0?

@ekote
Copy link
Contributor

ekote commented Jan 4, 2017

@jgustave, if p=0 then there is no autoregression operation when you use ARIMA. Your data are just first once differentiated (d=1) and then MovingAverage part is predicting value. So yes, your predicted data will be the same unless your p >= 1.

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

2 participants