1
$\begingroup$

Can I please get direction on what is wrong in the code? All forecasts provide output except the ones listed bellow.

so basically doesn't pick ['UserDefinedData4'] and ['ItemId'] separate ... only when both are in group_level ...

this link is with the program: program location

elif forecast_type == 4:
    # forecast weekly order quantity at item level with the dummy variable 'Quarter' using AR(8)
    mape = forecast(dataset, 'W', ['ItemId'], 'Quarter', 8, output_file)
elif forecast_type == 5:
    # forecast weekly order quantity at item level with the dummy variable 'Month' using AR(8)
    mape = forecast(dataset, 'W', ['ItemId'], 'Month', 8, output_file)
elif forecast_type == 6:
    # forecast monthly order quantity at item level with the dummy variable 'Quarter' using AR(2)
    mape = forecast(dataset, 'M', ['ItemId'], 'Quarter', 2, output_file)
elif forecast_type == 7:
    # forecast weekly order quantity at customer level with the dummy variable 'Month' using AR(8)
    mape = forecast(dataset, 'W', ['UserDefinedData4'], 'Month', 8, output_file)
elif forecast_type == 8:
    # forecast weekly order quantity at customer level with the dummy variable 'Quarter' using AR(8)
    mape = forecast(dataset, 'W', ['UserDefinedData4'], 'Quarter', 8, output_file)
elif forecast_type == 9:
    # forecast monthly order quantity at customer level with the dummy variable 'Quarter' using AR(2)
    mape = forecast(dataset, 'M', ['UserDefinedData4'], 'Quarter', 2, output_file)

Thank you for help.

$\endgroup$
1
  • $\begingroup$ Don't know if this answer is helpful, but I found ARIMA modeling way easier in R. $\endgroup$
    – Ben F
    Sep 17 '16 at 22:43
0
$\begingroup$

Found the issue and I will post the answer in case anybody will get this issue with ARMA.

model = sm.tsa.ARMA(endog=dataset_period[col], order=(nlag,0), exog= dataset_period[dummy_variable_period]).fit()
dataset_period['predict_'+str(col[1])+'_'+str(col[2])] = model.predict()
dataset_period['ape_'+str(col[1])+'_'+str(col[2])] = abs(  (dataset_period[col] - dataset_period['predict_'+str(col[1])+'_'+str(col[2])]) / dataset_period[col])
valid_ape = dataset_period['ape_'+str(col[1])+'_'+str(col[2])][dataset_period['ape_'+str(col[1])+'_'+str(col[2])] < 50]

issue was with the parameters. the model accepted 2 parameters for group_level and I was basically providing 1 so in this case automatically become zero and raise error.

solved with creating a new def and the model will use single column as the parameter for group_level

model = sm.tsa.ARMA(endog=dataset_period[col], order=(nlag,0),exog= dataset_period[dummy_variable_period]).fit()
dataset_period['predict_'+str(col[1])] = model.predict()
dataset_period['ape_'+str(col[1])] = abs((dataset_period[col] - dataset_period['predict_'+str(col[1])]) / dataset_period[col])
valid_ape = dataset_period['ape_'+str(col[1])][dataset_period['ape_'+str(col[1])] < 50]`
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.