You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
BUG: append broken in DynamicFactorMQ if updated months do not span updated quarters #7452
I have a statsmodels.tsa.statespace.mlemodel.MLEResultsWrapper object obtained after fitting a DynamicFactorMQ model. I would like to apply the append method to the result object with a new step of data (adding one month to the monthly endog and one quarter to the quarterly endog ) but i don't seem to find the right index format for my monthly and quarterly endog DataFrames. I always get the following error Given "endog" does not have an index that extends the index of the model.. I should mention that the same happens when using the extend method but the apply works properly.
Code Sample, a copy-pastable example if possible
here is where i call the method
here are the monthly and quarterly endog
here is the original endog data
Expected Output
A new result object containing the filtered.
Output of import statsmodels.api as sm; sm.show_versions()
Can you please post copy-and-pastable and runnable code? This is a lot more helpful than screenshots of code.
I'm sorry i've only put screen shots because the code i showed is data dependent, i will try to write something to replicate the error. In the mean time by tracing it through the package i found that the functions append and extend can't handle adding less than 3 months in the monthly endog when adding a quarter, the reason why is in the function construct_endog in the DynamicFactorMQ class. The two frequencies are joined on a monthly basis which skips a month (because the resample function takes end as convention)
Thanks for posting the replication code and for looking into the cause. This should be straightforward to fix. In the meantime, I think a workaround (you may have already discovered) is to extend updated_endog_m with nan values to the last month of the last quarter given in updated_endog_q.
changed the title [-]Trouble with the append method [/-][+]BUG: append broken in DynamicFactorMQ if updated months do not span updated quarters[/+]on May 19, 2021
Activity
bashtage commentedon May 18, 2021
Can you please post copy-and-pastable and runnable code? This is a lot more helpful than screenshots of code.
Mlaouar commentedon May 18, 2021
I'm sorry i've only put screen shots because the code i showed is data dependent, i will try to write something to replicate the error. In the mean time by tracing it through the package i found that the functions
appendandextendcan't handle adding less than 3 months in the monthly endog when adding a quarter, the reason why is in the functionconstruct_endogin theDynamicFactorMQclass. The two frequencies are joined on a monthly basis which skips a month (because theresamplefunction takesendasconvention)bashtage commentedon May 18, 2021
Feel free to simulate some data that is like your original data, e.g, same shape.
Mlaouar commentedon May 19, 2021
I apologize for the delay, here's some code to replicate the error
As you can see the updated monthly and quarterly data's indexes directly extend the original data.
Much thanks in advance.
ChadFulton commentedon May 19, 2021
Thanks for posting the replication code and for looking into the cause. This should be straightforward to fix. In the meantime, I think a workaround (you may have already discovered) is to extend
updated_endog_mwithnanvalues to the last month of the last quarter given inupdated_endog_q.[-]Trouble with the append method [/-][+]BUG: append broken in DynamicFactorMQ if updated months do not span updated quarters[/+]Mlaouar commentedon May 19, 2021
Thank you for the the response and the workaround tip, i have already tried it and it works greatly.