Path: blob/master/Time Forecasting using Python/1.3 Practice Questions based on moving Average.ipynb
3074 views
1. Determine the moving average
Determine the moving average with a window size of 2 for the list [30, 29, 35, 33, 31, 37, 39, 40, 41, 45].
Using the list [100, 95, 90, 85, 80, 75, 70, 65, 60, 55], calculate the moving average with a window size of 6.
Find the moving average for the list of integers [4, 8, 12, 16, 20, 24, 28, 32, 36, 40] with a window size of 3.
Calculate the moving average using a window size of 4 for the list [5, 10, 15, 20, 25, 30, 35, 40, 45, 50].
For the list [11, 22, 33, 44, 55, 66, 77, 88, 99, 110], find the moving average with a window size of 2.
Determine the moving average with a window size of 3 for the list [9, 18, 27, 36, 45, 54, 63, 72, 81, 90].
Objective:
2. Perform an Augmented Dickey-Fuller (ADF) test on a dataset containing attrition data to determine whether the attrition rate is stationary.
Dataset: You are provided with a dataset named attrition_data.csv that contains the following columns:
Date: The date of the recorded attrition rate (format: YYYY-MM-DD).
Attr_rate: The attrition rate for the corresponding date. Instructions:
Load the Data:
Import necessary libraries such as pandas, statsmodels, and matplotlib.
Load the dataset into a pandas DataFrame.
Ensure the Date column is parsed as datetime objects and set it as the index of the DataFrame.
Visualize the Data:
Plot the Attr_rate over time to visually inspect if the series appears to be stationary or non-stationary.
Perform the ADF Test:
Use the adfuller function from the statsmodels library to perform the ADF test on the Attr_rate series.
Extract and print the following from the test results:
ADF Statistic
p-value
Number of lags used
Number of observations used
Critical values for 1%, 5%, and 10% levels
Interpret the Results:
Based on the p-value and the critical values, determine whether to reject the null hypothesis of the ADF test. Discuss whether the attrition rate series is stationary or not.