Created
September 26, 2019 21:43
-
-
Save marcosan93/12180986b6a48a64256e2d3239b3e1d7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def best_param(model, data, pdq, pdqs): | |
| """ | |
| Loops through each possible combo for pdq and pdqs | |
| Runs the model for each combo | |
| Retrieves the model with lowest AIC score | |
| """ | |
| ans = [] | |
| for comb in tqdm(pdq): | |
| for combs in tqdm(pdqs): | |
| try: | |
| mod = model(data, | |
| order=comb, | |
| seasonal_order=combs, | |
| enforce_stationarity=False, | |
| enforce_invertibility=False, | |
| freq='D') | |
| output = mod.fit() | |
| ans.append([comb, combs, output.aic]) | |
| except: | |
| continue | |
| ans_df = pd.DataFrame(ans, columns=['pdq', 'pdqs', 'aic']) | |
| return ans_df.loc[ans_df.aic.idxmin()] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment