本文介绍了如何计算python中的标准化残差?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何根据 arima 模型 sarimax
函数计算标准化残差?
How would I calculated standartized residuals from arima model sarimax
function?
假设我们有一些基本模型:
lets say we have some basic model:
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
sns.set(style='ticks', context='poster')
from statsmodels.tsa.statespace.sarimax import SARIMAX
from statsmodels.tsa.seasonal import seasonal_decompose
import seaborn as sns
#plt.style.use("ggplot")
import pandas_datareader.data as web
import pandas as pd
import statsmodels.api as sm
import scipy
import statsmodels.stats.api as sms
import matplotlib.pyplot as plt
import datetime
model = SARIMAX(df, order = (6, 0, 0), trend = "c");
model_results = model.fit(maxiter = 500);
print(model_results.summary());
我需要标准化器,所以当我们使用 model_results.plot_diagnostics(figsize = (16, 10));
函数,然后只是基本的 plot
函数残差应该看起来一样.
I need standardizer so when we use model_results.plot_diagnostics(figsize = (16, 10));
function and then just basic plot
function residuals should look the same.
推荐答案
我认为你可以使用函数internally_studentized_residual";来自 https://stackoverflow.com/a/57155553/14294235
I think you can use the function "internally_studentized_residual" from https://stackoverflow.com/a/57155553/14294235
它应该是这样工作的:
model = SARIMAX(df, order = (6, 0, 0), trend = "c");
model_results = model.fit(maxiter = 500);
model_fittebd_y = model_results.fittedvalues
resid_studentized = internally_studentized_residual(df,model_fitted_y)
resid_studentized = -resid_studentized
plt.plot(resid_studentized)
plt.axhline(y=0, color='b', linestyle='--')
plt.show()
这篇关于如何计算python中的标准化残差?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!