code: def test_smoothed_decomposition_dfm_mq():
      # Create the datasets
      index_M = pd.period_range(start="2000", periods=12, freq="M")
      index_Q = pd.period_range(start="2000", periods=4, freq="Q")
  
      dta_M = pd.DataFrame(
          np.zeros((12, 2)), index=index_M, columns=["M0", "M1"]
      )
      dta_Q = pd.DataFrame(
          np.zeros((4, 2)), index=index_Q, columns=["Q0", "Q1"]
      )
      # Add some noise so the variables aren't constants
      dta_M.iloc[0] = 1.0
      dta_Q.iloc[1] = 1.0
      # TODO: remove this once we have the intercept contributions figured out
      dta_M -= dta_M.mean()
      dta_Q -= dta_Q.mean()
  
      # Create the model instance
      mod = dynamic_factor_mq.DynamicFactorMQ(
          dta_M,
          endog_quarterly=dta_Q,
          factors=1,
          factor_orders=1,
          idiosyncratic_ar1=True,
      )
      params = [
          0.1,
          -0.4,
          0.2,
          0.3,  # loadings
          0.95,
          1.0,  # factor
          0.5,
          0.55,
          0.6,
          0.65,  # idio ar(1)
          1.1,
          1.2,
          1.0,
          0.9,  # idio variances
      ]
      res = mod.smooth(params)
  
      # Check smoothed state
  
      # Get the decomposition of the smoothed state
      cd, coi, csi, cp = res.get_smoothed_decomposition(
          decomposition_of="smoothed_state"
      )
  
      # Sum across contributions (i.e. from observations at each time period and
      # from the initial state)
      css = (cd + coi).sum(axis=1) + csi.sum(axis=1) + cp.sum(axis=1)
      css = css.unstack(level="state_to")[mod.state_names].values
  
      # Summing up all contributions should yield the actual smoothed state,
      # so the smoothed state vector is the desired result of this test
      ss = np.array(res.states.smoothed)
  
      assert_allclose(css, ss, atol=1e-12)
  
      # Check smoothed signal
  
      # Use the summed state contributions and multiply by the design matrix
      # to get the smoothed signal
      csf = (css.T * mod["design"][:, :, None]).sum(axis=1).T
      # Reverse the standardization
      csf = (
          csf.T * mod._endog_std.values[:, None]
          + mod._endog_mean.values[:, None]
      ).T
  
      # Summing up all contributions should yield the smoothed prediction of
      # the observed variables
      s_sig = res.predict(information_set="smoothed", signal_only=True)
      sf = res.predict(information_set="smoothed", signal_only=False)
  
      assert_allclose(csf, sf, atol=1e-12)
  
      # Now check the smoothed signal against the sum computed from the
      # decomposed smoothed signal
      cd, coi, csi, cp = res.get_smoothed_decomposition(
          decomposition_of="smoothed_signal"
      )
  
      # Sum across contributions (i.e. from observations and intercepts at each
      # time period and from the initial state) to get the smoothed signal
      cs_sig = (cd + coi).sum(axis=1) + csi.sum(axis=1) + cp.sum(axis=1)
      cs_sig = cs_sig.unstack(level="variable_to")[
          mod.endog_names
      ].values
  
      assert_allclose(cs_sig, s_sig, atol=1e-12)
  
      # Add in the observation intercept to get the smoothed forecast
      csf = cs_sig + mod["obs_intercept"].T
  
      assert_allclose(csf, sf)
  
file_path: statsmodels/statsmodels/tsa/statespace/tests/test_decompose.py
imports: import pytest
  import numpy
  import pandas
  from numpy.testing import assert_allclose
  from statsmodels import datasets
  from statsmodels.tsa.statespace import sarimax, varmax, dynamic_factor_mq
  from statsmodels.tsa.statespace.tests.test_impulse_responses import TVSS
label_desc: Use image node_id 3 for calling a global function with example usage: test_smoothed_decomposition_dfm_mq() without return types