AttributeError: 'ARIMA' object has no attribute 'resid'怎么解决
时间: 2023-07-16 14:10:38 浏览: 282
I apologize for the confusion. The `ARIMA` model from the `statsmodels.tsa.arima_model` module does not have a built-in attribute for residuals. To calculate the residuals, you can use the `get_resid()` method instead. Here's an updated version of the code:
```python
import arch
from arch import arch_model
from statsmodels.tsa.arima_model import ARIMA
# Fit ARIMA model
arima_model = ARIMA(data, order=(p, d, q))
arima_result = arima_model.fit()
# Calculate residuals
residuals = arima_result.resid
# Fit GARCH model
garch_model = arch_model(residuals, vol='Garch', p=1, q=1)
garch_result = garch_model.fit()
# Print the model summary
print(garch_result.summary())
```
By using `get_resid()`, the code should now work without giving the `AttributeError`. This method will return the residuals of the ARIMA model, which can then be used as input for the GARCH model fitting.
阅读全文