估计的自由度不足

时间:2019-04-13 10:19:13

标签: python pandas statsmodels arima forecast

我的自由度小于数据集中的行数。为什么出现错误“估计的自由度不足”。我该怎么办才能解决此错误?

我试图减小differenced = difference(X,11)中的值,但是它仍然显示错误。

dataset, validation = series[0:split_point], series[split_point:]
print('Dataset %d, Validation %d' % (len(dataset), len(validation)))
dataset.to_csv('dataset.csv')
validation.to_csv('validation.csv')
from pandas import Series
from statsmodels.tsa.arima_model import ARIMA
import numpy
# load dataset
series = Series.from_csv('dataset.csv', header=None)
series = series.iloc[1:]
series.head()
series.shape

from pandas import Series
from statsmodels.tsa.arima_model import ARIMA
import numpy
# create a differenced series
def difference(dataset, interval=1):
    diff = list()
    for i in range(interval+1, len(dataset)):
        value = int(dataset[i]) - int(dataset[i - interval])
        diff.append(value)
    return numpy.array(diff)

# load dataset
series = Series.from_csv('dataset.csv', header=None)
# seasonal difference
X = series.values
differenced = difference(X,11)
# fit model
model = ARIMA(differenced, order=(7,0,1))
model_fit = model.fit(disp=0)
# print summary of fit model
print(model_fit.summary())

series.head() result

形状为(17,)

1 个答案:

答案 0 :(得分:2)

微分后,您将获得6个观察值(17-11 = 6)。对于ARIMA(7,0,1)而言,这还不够。

只有很少的数据,使用任何模型都不太可能获得良好的预测性能,但是如果有必要,那么我建议使用更简单的方法,例如ARIMA(1、0、0)或指数平滑模型。