DynamicFactorMQ Model Matrices

92 views
Skip to first unread message

Jose A. Sidaoui Gali

unread,
Aug 6, 2024, 1:50:59 PM8/6/24
to pystat...@googlegroups.com
I have been fitting state space models with DynamicFactorMQ but the documentation is quite unclear on how to extract the estimated State Space matrices (transition matrix, observation equation matrix, observation and factor covariant matrices). Is there a functionality built in to extract these? 

Jose A. Sidaoui
Ph.D. Degree Student
Industrial Engineering & Operations Research
The Fu Foundation School of Engineering & Applied Science
Columbia University in the City of New York

Chad Fulton

unread,
Aug 6, 2024, 10:00:09 PM8/6/24
to pystat...@googlegroups.com
--
You received this message because you are subscribed to the Google Groups "pystatsmodels" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pystatsmodel...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pystatsmodels/CABCURYOKEFEJ5gfL0u%3DO%2BEm%2BVaO9g5Vm_1pCf608OsroLcCUiw%40mail.gmail.com.

Hi Jose,

Yes, you can do the following:

```
model = sm.tsa.DynamicFactorMQ(y)
results = model.fit()

d = results.filter_results.obs_intercept
Z = results.filter_results.design
H = results.filter_results.obs_cov

c = results.filter_results.state_intercept
T = results.filter_results.transition
R = results.filter_results.selection
Q = results.filter_results.state_cov
```

Note that these arrays have an extra dimension at the end (in time-varying models, the extra dimension is the time dimension, but the dynamic factor model is time-invariant, so the extra dimension is extraneous).  So if you wanted just the vector or matrix, you could do e.g.:

```
d = results.filter_results.obs_intercept[..., 0]  # <- now d is a 1d vector
Z = results.filter_results.design[..., 0]         # <- now Z is a 2d matrix
```

etc.

Hope that helps,
Chad

Jose A. Sidaoui Gali

unread,
Aug 7, 2024, 12:06:33 AM8/7/24
to pystat...@googlegroups.com
Thanks Chad this is very helpful! A follow up question on this: the dimensions of these matrices seem a bit mysterious, for example, if the number of factors in the model is k_factors and the number of observed variables is n, the matrices for the factors appear to take the number of factors as n+k_factors, specifically, the transition matrix should be k_factors by k_factors but it is k_factors+n by k_factors+n; similarly for the state_cov matrix. Also the design matrix should be n by k_factors but it is n by k_factors+n. 

I am fitting my models as follows:

# Initialize the model
model = sm.tsa.DynamicFactorMQ(x, factors=k_factors, factor_orders=1)

# Fit the model using the EM algorithm
result = model.fit(disp=False)


Any idea why this happens?

Chad Fulton

unread,
Aug 9, 2024, 9:25:20 PM8/9/24
to pystat...@googlegroups.com
To view this discussion on the web visit https://groups.google.com/d/msgid/pystatsmodels/CABCURYPEeN%3DJFbToe%2BJmei7JYRkZDy%2BEghXpkcR8s%3D%3DwYHJ%3DbA%40mail.gmail.com.

Hi Jose,

It is because the default is to allow the n idiosyncratic error terms to follow AR(1) processes. This means they are incorporated as part of the state space, and so part of the transition matrix, etc., describes their behavior.

This can be turned off by using the argument idiosyncratic_ar1=False

Best,
Chad

Reply all
Reply to author
Forward
0 new messages