Get Started

Fitting an ARMAX model

In this exercise you will fit an ARMAX model to a time series which represents the wait times at an accident and emergency room for urgent medical care.

The variable you would like to model is the wait times to be seen by a medical professional wait_times_hrs. This may be related to an exogenous variable that you measured nurse_count which is the number of nurses on shift at any given time. These can be seen below.

This is a particularly interesting case of time series modeling as, if the number of nurses has an effect, you could change this to affect the wait times.

The time series data is available in your environment as hospital and has the two columns mentioned above. The ARMA class is also available for you.

This is a part of the course

“ARIMA Models in Python”

View Course

Exercise instructions

  • Instantiate an ARMAX(2,1) model to train on the 'wait_times_hrs' column of hospital using the 'nurse_count' column as an exogenous variable.
  • Fit the model.
  • Print the summary of the model fit.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# Instantiate the model
model = ____

# Fit the model
results = ____

# Print model fit summary
____

This exercise is part of the course

ARIMA Models in Python

AdvancedSkill Level
4.8+
22 reviews

Learn about ARIMA models in Python and become an expert in time series analysis.

What lies ahead in this chapter is you predicting what lies ahead in your data. You'll learn how to use the elegant statsmodels package to fit ARMA, ARIMA and ARMAX models. Then you'll use your models to predict the uncertain future of stock prices!

Exercise 1: Fitting time series modelsExercise 2: Fitting AR and MA modelsExercise 3: Fitting an ARMA modelExercise 4: Fitting an ARMAX model
Exercise 5: ForecastingExercise 6: Generating one-step-ahead predictionsExercise 7: Plotting one-step-ahead predictionsExercise 8: Generating dynamic forecastsExercise 9: Plotting dynamic forecastsExercise 10: Intro to ARIMA modelsExercise 11: Differencing and fitting ARMAExercise 12: Unrolling ARMA forecastExercise 13: Fitting an ARIMA modelExercise 14: Choosing ARIMA model

What is DataCamp?

Learn the data skills you need online at your own pace—from non-coding essentials to data science and machine learning.

Start Learning for Free