简体   繁体   中英

Python Dynamic Factor Modelling

I want to estimate Turkish gdp growth using the monthly train data below.

`       elcyoy  sanayiüretim sanayi tüketicigüven sanayikullanım
2022-08 -4.26   2.40    4.151   6.06    -0.2
2022-09 -3.03   -1.66   0.452   0.26    -0.5
2022-10 -5.14   2.82    3.05    5.26    -0.9
2022-11 -7.80   -1.13   2.08    0.62    -1.7
2022-12  2.00   NaN     2.00  -1.28     -2.0`

And below is my train gdp data, it is in quarter index. 2022Q4 does not exist and it is what I want to forecast.

    `  gdpyoy   gdpqq   eurozone
2021Q3  7.89    2.71    3.94339
2021Q4  9.60    1.58    4.77457
2022Q1  7.52    0.59    5.48059
2022Q2  7.74    1.87    4.24867
2022Q3  3.85    -0.12   2.27869`

However, when I implement the code, it gives me outcome this and forecast is below. It does not forecast 2022Q4 but it does forecast 2023 Q1. What am I missing?

Dep. Variable:  "elcyoy", and 5 more    No. Observations:   180
Model:  Dynamic Factor Model    Log Likelihood  -941.547
+ 2 factors in 2 blocks AIC 1943.095
+ Mixed frequency (M/Q) BIC 2038.884
+ AR(1) idiosyncratic   HQIC    1981.933
Date:   Sun, 22 Jan 2023    EM Iterations   264
Time:   23:46:27        
Sample: 01-31-2008      
- 12-31-2022        
Covariance Type:    Not computed



 mod.forecast(10).resample('Q').last()['gdpyoy']

    2023Q1    3.957968
    2023Q2    4.964555
    2023Q3    5.016538
    2023Q4    5.023323
    Freq: Q-DEC, Name: gdpyoy, dtype: float64

I tried converting quarterly gdp data into monthly data, added it to the "trainaylık" series where every 2 month is blank and third month is the growth rate. I tried to model again using "DynamicFactor" but it gave me a terrible results.

Your data ends in 2022Q4, so it is part of the sample. This is why it is not part of the forecast (which only provides out-of-sample predictions). Instead you can use the predict method (which provides both in-sample and out-of-sample predictions):

mod.predict(start='2022-12', end='2023-12').resample('Q').last()['gdpyoy']

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM