I'm not sure that statsmodels is predicting out-of-sample I am fitting an ARMA model to my data and here is my code
import statsmodels.tsa.arima_model as ari

model=ari.ARMA(pivoted['price'],(2,1))
ar_res=model.fit()
preds=ar_res.predict(100,400)

What I want is to train the ARMA model up to the 100th data point and then test out-of-sample on the 100-400th data points.  But I don't think that is what's happening.  I think this is because the model is fit on the entire data set, so how can the predictions be out-of-sample?  It says here that out-of-sample prediction is possible. Can someone please help me understand this?  
OK here is my new code
model=ari.ARMA(pivoted['price'][:100],order=(2,1))
ar_res=model.fit()
preds=ar_res.predict(100,400)

however it return the error
AssertionError: Index length did not match values

 A: I ran into the same problem, and the documentation of statsmodel is unclear about this issue. I check the source code of ar_model, find the following parts in predict method(line 205):
    if dynamic:
        out_of_sample += end - start + 1
        return _ar_predict_out_of_sample(endog, params, k_ar,
                                         k_trend, out_of_sample, start)

Seems that in order to use out-of-sample prediction, the dynamic parameter must be set to True. However, the documentation said dynamic parameter only relates to in-sample prediction.
You can try this:
preds=ar_res.predict(100,400,dynamic = True)

A: You want to only give the first 100 data points to the ARMA call. Then you can predict out of sample, as you are doing. Alternatively, you can train on the whole dataset and then do dynamic prediction (using lagged predicted values) via the dynamic keyword to predict. Note that ARMA will fairly quickly converge to the long-run mean, provided that your series is well-behaved, so don't expect to get too much out of these very long-run prediction exercises. 
