I need you help with GARCH model in python I got the error below. Dataset Apple Stock Returns split data into 80% train

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

I need you help with GARCH model in python I got the error below. Dataset Apple Stock Returns split data into 80% train

Post by answerhappygod »

I need you help with GARCH model in python I got the error
below.
Dataset Apple Stock Returns
I Need You Help With Garch Model In Python I Got The Error Below Dataset Apple Stock Returns Split Data Into 80 Train 1
I Need You Help With Garch Model In Python I Got The Error Below Dataset Apple Stock Returns Split Data Into 80 Train 1 (30.58 KiB) Viewed 95 times
split data into 80% train and test 20%:
I Need You Help With Garch Model In Python I Got The Error Below Dataset Apple Stock Returns Split Data Into 80 Train 2
I Need You Help With Garch Model In Python I Got The Error Below Dataset Apple Stock Returns Split Data Into 80 Train 2 (61.51 KiB) Viewed 95 times
forecasting on test data using garch model (1,1)
I Need You Help With Garch Model In Python I Got The Error Below Dataset Apple Stock Returns Split Data Into 80 Train 3
I Need You Help With Garch Model In Python I Got The Error Below Dataset Apple Stock Returns Split Data Into 80 Train 3 (54.56 KiB) Viewed 95 times
I get error in the above code.
In [101]: returns Out[101]: Date 2018-01-03 2018-01-04 2018-01-05 2018-01-08 2018-01-09 -0.017415 0.464497 1.138532 -0.371425 -0.011474 2021-09-23 0.671920 2021-09-24 0.061293 2021-09-27 -1.054998 2021-09-28 -2.380128 2021-09-29 0.648297 Name: Close, Length: 942, dtype: float64

In [102]: train Out[102]: Date 2018-01-03 2018-01-04 2018-01-05 2018-01-08 2018-01-09 -0.017415 0.464497 1.138532 -0.371425 -0.011474 2020-12-22 2.846455 2020-12-23 -0.697602 2020-12-24 0.771224 2020-12-28 3.576571 2020-12-29 -1.331485 Name: Close, Length: 753, dtype: float64 In [103]: test Out[103]: Date 2020-12-30 2020-12-31 2021-01-04 2021-01-05 2021-01-06 -0.852668 -0.770265 -2.471926 1.236373 -3.366152 2021-09-23 0.671920 2021-09-24 0.061293 2021-09-27 -1.054998 2021-09-28 -2.380128 2021-09-29 0.648297 Name: Close, Length: 189, dtype: float64

= rolling predictions = [] for i in range(test): train = returns[:-(test-i)] model = arch_model(train, p=2, q=2) model_fit = model.fit(disp='off') pred = model_fit. forecast(horizon=1) rolling predictions.append(np.sqrt(pred.variance.values[-1,:][0])) TypeError Traceback (most recent call last) <ipython-input-110-17b5849be2c8> in <module> 1 rolling_predictions = [] --> 2 for i in range(test): 3 train = returns[:-(test-i)] 4 model = arch_model(train, p=2, q=2) 5 model_fit = model.fit(disp='off') TypeError: 'Series' object cannot be interpreted as an integer
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply