statsmodel.SARIMAX .forecast() method do not execute












0















I am trying to use SARIMAX model for TS forecasting. However, I got some kind of error i dont know how to handle. My code is simple:



import statsmodels.api as sm

fit = sm.tsa.statespace.SARIMAX(train).fit()
sarima = fit.forecast()


train data looks like



            y
ds
2015-01-07 1
2015-01-14 64
2015-01-21 16
2015-01-28 50
2015-02-04 7


I got the error



 /usr/local/lib/python3.6/dist-packages/statsmodels/tsa/base/datetools.py in 
_date_from_idx(d1, idx, freq)
84 offset. For now, this needs to be taken care of before you get
here.
85 """
---> 86 return _maybe_convert_period(d1) + int(idx) *
_freq_to_pandas[freq]
87
88

TypeError: unsupported operand type(s) for *: 'int' and 'NoneType'


Any ideas what I am doing wrong?










share|improve this question























  • What is your desired output, the model summary, a plot, or just y hat?

    – W.Dodge
    Nov 23 '18 at 15:25













  • @W.Dodge i just want forecast for 50 days, thats yhat

    – Nekit
    Nov 23 '18 at 15:57











  • Did you check that all your data is valid? Maybe some of the dates or y values are None. Are you getting this error when fitting or at prediction?

    – zsomko
    Nov 23 '18 at 16:11
















0















I am trying to use SARIMAX model for TS forecasting. However, I got some kind of error i dont know how to handle. My code is simple:



import statsmodels.api as sm

fit = sm.tsa.statespace.SARIMAX(train).fit()
sarima = fit.forecast()


train data looks like



            y
ds
2015-01-07 1
2015-01-14 64
2015-01-21 16
2015-01-28 50
2015-02-04 7


I got the error



 /usr/local/lib/python3.6/dist-packages/statsmodels/tsa/base/datetools.py in 
_date_from_idx(d1, idx, freq)
84 offset. For now, this needs to be taken care of before you get
here.
85 """
---> 86 return _maybe_convert_period(d1) + int(idx) *
_freq_to_pandas[freq]
87
88

TypeError: unsupported operand type(s) for *: 'int' and 'NoneType'


Any ideas what I am doing wrong?










share|improve this question























  • What is your desired output, the model summary, a plot, or just y hat?

    – W.Dodge
    Nov 23 '18 at 15:25













  • @W.Dodge i just want forecast for 50 days, thats yhat

    – Nekit
    Nov 23 '18 at 15:57











  • Did you check that all your data is valid? Maybe some of the dates or y values are None. Are you getting this error when fitting or at prediction?

    – zsomko
    Nov 23 '18 at 16:11














0












0








0








I am trying to use SARIMAX model for TS forecasting. However, I got some kind of error i dont know how to handle. My code is simple:



import statsmodels.api as sm

fit = sm.tsa.statespace.SARIMAX(train).fit()
sarima = fit.forecast()


train data looks like



            y
ds
2015-01-07 1
2015-01-14 64
2015-01-21 16
2015-01-28 50
2015-02-04 7


I got the error



 /usr/local/lib/python3.6/dist-packages/statsmodels/tsa/base/datetools.py in 
_date_from_idx(d1, idx, freq)
84 offset. For now, this needs to be taken care of before you get
here.
85 """
---> 86 return _maybe_convert_period(d1) + int(idx) *
_freq_to_pandas[freq]
87
88

TypeError: unsupported operand type(s) for *: 'int' and 'NoneType'


Any ideas what I am doing wrong?










share|improve this question














I am trying to use SARIMAX model for TS forecasting. However, I got some kind of error i dont know how to handle. My code is simple:



import statsmodels.api as sm

fit = sm.tsa.statespace.SARIMAX(train).fit()
sarima = fit.forecast()


train data looks like



            y
ds
2015-01-07 1
2015-01-14 64
2015-01-21 16
2015-01-28 50
2015-02-04 7


I got the error



 /usr/local/lib/python3.6/dist-packages/statsmodels/tsa/base/datetools.py in 
_date_from_idx(d1, idx, freq)
84 offset. For now, this needs to be taken care of before you get
here.
85 """
---> 86 return _maybe_convert_period(d1) + int(idx) *
_freq_to_pandas[freq]
87
88

TypeError: unsupported operand type(s) for *: 'int' and 'NoneType'


Any ideas what I am doing wrong?







python statsmodels






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 23 '18 at 15:06









NekitNekit

1




1













  • What is your desired output, the model summary, a plot, or just y hat?

    – W.Dodge
    Nov 23 '18 at 15:25













  • @W.Dodge i just want forecast for 50 days, thats yhat

    – Nekit
    Nov 23 '18 at 15:57











  • Did you check that all your data is valid? Maybe some of the dates or y values are None. Are you getting this error when fitting or at prediction?

    – zsomko
    Nov 23 '18 at 16:11



















  • What is your desired output, the model summary, a plot, or just y hat?

    – W.Dodge
    Nov 23 '18 at 15:25













  • @W.Dodge i just want forecast for 50 days, thats yhat

    – Nekit
    Nov 23 '18 at 15:57











  • Did you check that all your data is valid? Maybe some of the dates or y values are None. Are you getting this error when fitting or at prediction?

    – zsomko
    Nov 23 '18 at 16:11

















What is your desired output, the model summary, a plot, or just y hat?

– W.Dodge
Nov 23 '18 at 15:25







What is your desired output, the model summary, a plot, or just y hat?

– W.Dodge
Nov 23 '18 at 15:25















@W.Dodge i just want forecast for 50 days, thats yhat

– Nekit
Nov 23 '18 at 15:57





@W.Dodge i just want forecast for 50 days, thats yhat

– Nekit
Nov 23 '18 at 15:57













Did you check that all your data is valid? Maybe some of the dates or y values are None. Are you getting this error when fitting or at prediction?

– zsomko
Nov 23 '18 at 16:11





Did you check that all your data is valid? Maybe some of the dates or y values are None. Are you getting this error when fitting or at prediction?

– zsomko
Nov 23 '18 at 16:11












1 Answer
1






active

oldest

votes


















0














SARIMA is a fairly complex moving average predictive model with many parameters and nuances. You will need to research the details of this approach extensively to be sure that you are utilizing this appropriately. For the sake of simply implementing the model to obtain a result, the following example should help:



Code:



import matplotlib.pyplot as plt
import statsmodels.api as sm
import numpy as np

np.random.seed(100)

data = np.sort(np.random.uniform(0, 1, size=30))
steps_to_predict = 5

model = sm.tsa.statespace.SARIMAX(endog=data,order=(2,0,0),enforce_stationarity=False)
sarima = model.fit()
print(sarima.summary())

# plot
fig, ax = plt.subplots(1,1, figsize=(20,10))
ax.set_xlim(0,40)
ax.plot(train, "ro-", linewidth=2, markersize=12)
ax.plot(list(range(30,35)), sarima.forecast(steps_to_predict), "bo-", linewidth=2, markersize=12)


Output:



enter image description here



*** Note that the observed data is red and the predicted steps are blue.






share|improve this answer





















  • 1





    thanks for answer!

    – Nekit
    Nov 23 '18 at 18:34













Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53449025%2fstatsmodel-sarimax-forecast-method-do-not-execute%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














SARIMA is a fairly complex moving average predictive model with many parameters and nuances. You will need to research the details of this approach extensively to be sure that you are utilizing this appropriately. For the sake of simply implementing the model to obtain a result, the following example should help:



Code:



import matplotlib.pyplot as plt
import statsmodels.api as sm
import numpy as np

np.random.seed(100)

data = np.sort(np.random.uniform(0, 1, size=30))
steps_to_predict = 5

model = sm.tsa.statespace.SARIMAX(endog=data,order=(2,0,0),enforce_stationarity=False)
sarima = model.fit()
print(sarima.summary())

# plot
fig, ax = plt.subplots(1,1, figsize=(20,10))
ax.set_xlim(0,40)
ax.plot(train, "ro-", linewidth=2, markersize=12)
ax.plot(list(range(30,35)), sarima.forecast(steps_to_predict), "bo-", linewidth=2, markersize=12)


Output:



enter image description here



*** Note that the observed data is red and the predicted steps are blue.






share|improve this answer





















  • 1





    thanks for answer!

    – Nekit
    Nov 23 '18 at 18:34


















0














SARIMA is a fairly complex moving average predictive model with many parameters and nuances. You will need to research the details of this approach extensively to be sure that you are utilizing this appropriately. For the sake of simply implementing the model to obtain a result, the following example should help:



Code:



import matplotlib.pyplot as plt
import statsmodels.api as sm
import numpy as np

np.random.seed(100)

data = np.sort(np.random.uniform(0, 1, size=30))
steps_to_predict = 5

model = sm.tsa.statespace.SARIMAX(endog=data,order=(2,0,0),enforce_stationarity=False)
sarima = model.fit()
print(sarima.summary())

# plot
fig, ax = plt.subplots(1,1, figsize=(20,10))
ax.set_xlim(0,40)
ax.plot(train, "ro-", linewidth=2, markersize=12)
ax.plot(list(range(30,35)), sarima.forecast(steps_to_predict), "bo-", linewidth=2, markersize=12)


Output:



enter image description here



*** Note that the observed data is red and the predicted steps are blue.






share|improve this answer





















  • 1





    thanks for answer!

    – Nekit
    Nov 23 '18 at 18:34
















0












0








0







SARIMA is a fairly complex moving average predictive model with many parameters and nuances. You will need to research the details of this approach extensively to be sure that you are utilizing this appropriately. For the sake of simply implementing the model to obtain a result, the following example should help:



Code:



import matplotlib.pyplot as plt
import statsmodels.api as sm
import numpy as np

np.random.seed(100)

data = np.sort(np.random.uniform(0, 1, size=30))
steps_to_predict = 5

model = sm.tsa.statespace.SARIMAX(endog=data,order=(2,0,0),enforce_stationarity=False)
sarima = model.fit()
print(sarima.summary())

# plot
fig, ax = plt.subplots(1,1, figsize=(20,10))
ax.set_xlim(0,40)
ax.plot(train, "ro-", linewidth=2, markersize=12)
ax.plot(list(range(30,35)), sarima.forecast(steps_to_predict), "bo-", linewidth=2, markersize=12)


Output:



enter image description here



*** Note that the observed data is red and the predicted steps are blue.






share|improve this answer















SARIMA is a fairly complex moving average predictive model with many parameters and nuances. You will need to research the details of this approach extensively to be sure that you are utilizing this appropriately. For the sake of simply implementing the model to obtain a result, the following example should help:



Code:



import matplotlib.pyplot as plt
import statsmodels.api as sm
import numpy as np

np.random.seed(100)

data = np.sort(np.random.uniform(0, 1, size=30))
steps_to_predict = 5

model = sm.tsa.statespace.SARIMAX(endog=data,order=(2,0,0),enforce_stationarity=False)
sarima = model.fit()
print(sarima.summary())

# plot
fig, ax = plt.subplots(1,1, figsize=(20,10))
ax.set_xlim(0,40)
ax.plot(train, "ro-", linewidth=2, markersize=12)
ax.plot(list(range(30,35)), sarima.forecast(steps_to_predict), "bo-", linewidth=2, markersize=12)


Output:



enter image description here



*** Note that the observed data is red and the predicted steps are blue.







share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 23 '18 at 23:27

























answered Nov 23 '18 at 16:52









W.DodgeW.Dodge

1,3691921




1,3691921








  • 1





    thanks for answer!

    – Nekit
    Nov 23 '18 at 18:34
















  • 1





    thanks for answer!

    – Nekit
    Nov 23 '18 at 18:34










1




1





thanks for answer!

– Nekit
Nov 23 '18 at 18:34







thanks for answer!

– Nekit
Nov 23 '18 at 18:34




















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53449025%2fstatsmodel-sarimax-forecast-method-do-not-execute%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Berounka

Sphinx de Gizeh

Different font size/position of beamer's navigation symbols template's content depending on regular/plain...