code: def test_simulation_smoothing(missing):
      # Test that the simulation smoother works when the multivariate filter
      # switches to the univariate filter when it runs into problems
      # (see test_basic for a description of the model used here)
  
      # Get the model where switching will occur
      mod_switch = get_model(univariate=True, missing=missing)
      mod_switch.initialize_known([0], [[0]])
      sim_switch = mod_switch.simulation_smoother()
  
      # Get the model where we have specified univariate filtering (so there is
      # no need to switch)
      mod_uv = get_model(univariate=True, missing=missing)
      mod_uv.initialize_known([0], [[0]])
      mod_uv.ssm.filter_univariate = True
      sim_uv = mod_uv.simulation_smoother()
  
      # Test for basic simulationg of a new observed series
      simulate_switch = mod_switch.simulate([], 10, random_state=1234)
      simulate_uv = mod_uv.simulate([], 10, random_state=1234)
      assert_allclose(simulate_switch, simulate_uv)
  
      # Perform simulation smoothing
      sim_switch.simulate(random_state=1234)
      sim_uv.simulate(random_state=1234)
  
      # Make sure that switching happened in the first model but not the second
      kfilter = sim_switch._simulation_smoother.simulated_kfilter
      uf_switch = np.array(kfilter.univariate_filter, copy=True)
      assert_allclose(uf_switch[0], 1)
      assert_allclose(uf_switch[1:], 0)
      kfilter = (
          sim_uv._simulation_smoother.simulated_kfilter.univariate_filter
      )
      uf_uv = np.array(kfilter, copy=True)
      assert_allclose(uf_uv, 1)
      if missing == "mixed":
          kfilter = (
              sim_switch._simulation_smoother.secondary_simulated_kfilter.univariate_filter
          )
          uf_switch = np.array(kfilter, copy=True)
          assert_allclose(uf_switch[0], 1)
          assert_allclose(uf_switch[1:], 0)
          kfilter = (
              sim_uv._simulation_smoother.secondary_simulated_kfilter.univariate_filter
          )
          uf_uv = np.array(kfilter, copy=True)
          assert_allclose(uf_uv, 1)
  
      # Test all simulation smoothing output
      attrs = [
          "generated_measurement_disturbance",
          "generated_state_disturbance",
          "generated_obs",
          "generated_state",
          "simulated_state",
          "simulated_measurement_disturbance",
          "simulated_state_disturbance",
      ]
      for attr in attrs:
          assert_allclose(
              getattr(sim_switch, attr), getattr(sim_uv, attr)
          )
  
file_path: statsmodels/statsmodels/tsa/statespace/tests/test_multivariate_switch_univariate.py
imports: import numpy
  import pytest
  from statsmodels.tsa.statespace import mlemodel, sarimax, structural, varmax, dynamic_factor
  from statsmodels.tsa.statespace.tests.test_impulse_responses import TVSS
  from numpy.testing import assert_allclose
label_desc: Use image node_id 12 for calling a global function with example usage: test_simulation_smoothing(missing) without return types