code: def test_invalid_model_specification():
      # Test for errors that can be raised for invalid model specifications
      # during __init__
      dta = np.zeros((10, 2))
      dta[0] = 1.0
      dta_pd = pd.DataFrame(dta)
      dta_period_W = pd.DataFrame(
          dta, index=pd.period_range(start="2000", periods=10, freq="W")
      )
      dta_date_W = pd.DataFrame(
          dta, index=pd.date_range(start="2000", periods=10, freq="W")
      )
      dta_period_M = pd.DataFrame(
          dta, index=pd.period_range(start="2000", periods=10, freq="M")
      )
      dta_date_M = pd.DataFrame(
          dta,
          index=pd.date_range(start="2000", periods=10, freq=MONTH_END),
      )
      dta_period_Q = pd.DataFrame(
          dta, index=pd.period_range(start="2000", periods=10, freq="Q")
      )
  
      # Error if k_factors == 0
      msg = "The model must contain at least one factor."
      with pytest.raises(ValueError, match=msg):
          dynamic_factor_mq.DynamicFactorMQ(dta, factors=0)
  
      # Error if k_factors, factor_multiplicities, or factor_orders is something
      # besides int or dict
      msg = (
          "`factors` argument must an integer number of factors, a list of"
          " global factor names, or a dictionary, mapping observed variables"
          " to factors."
      )
      with pytest.raises(ValueError, match=msg):
          dynamic_factor_mq.DynamicFactorMQ(dta, factors=True)
      msg = "`factor_orders` argument must either be an integer or a dictionary."
      with pytest.raises(ValueError, match=msg):
          dynamic_factor_mq.DynamicFactorMQ(dta, factor_orders=True)
      msg = (
          "`factor_multiplicities` argument must either be an integer or a"
          " dictionary."
      )
      with pytest.raises(ValueError, match=msg):
          dynamic_factor_mq.DynamicFactorMQ(
              dta, factor_multiplicities=True
          )
  
      # Error if k_factors > k_endog_M
      msg = rf"Number of factors \({dta.shape[1] + 1}\) cannot be greater than"
      with pytest.raises(ValueError, match=msg):
          dynamic_factor_mq.DynamicFactorMQ(
              dta, factors=dta.shape[1] + 1
          )
  
      # Error if factor assigned to more than one block
      factor_orders = {("a", "b"): 1, "b": 2}
      msg = (
          "Each factor can be assigned to at most one block of factors in"
          " `factor_orders`."
      )
      with pytest.raises(ValueError, match=msg):
          dynamic_factor_mq.DynamicFactorMQ(
              dta, factors=["a", "b"], factor_orders=factor_orders
          )
  
      # Error if k_endog_monthly and endog_quarterly both specified
      msg = (
          "If `endog_quarterly` is specified, then `endog` must contain only"
          " monthly variables, and so `k_endog_monthly` cannot be specified"
          " since it will be inferred from the shape of `endog`."
      )
      with pytest.raises(ValueError, match=msg):
          dynamic_factor_mq.DynamicFactorMQ(
              dta_period_M, k_endog_monthly=2, endog_quarterly=dta
          )
  
      # Error if invalid standardize
      msg = "Invalid value passed for `standardize`."
      with pytest.raises(ValueError, match=msg):
          dynamic_factor_mq.DynamicFactorMQ(
              dta_period_M, standardize="a"
          )
  
      # No factors for one endog
      msg = (
          "If a `factors` dictionary is provided, then it must include"
          " entries for each observed variable."
      )
      with pytest.raises(ValueError, match=msg):
          dynamic_factor_mq.DynamicFactorMQ(dta, factors={"y1": ["a"]})
      msg = (
          "Each observed variable must be mapped to at"
          " least one factor in the `factors` dictionary."
      )
      with pytest.raises(ValueError, match=msg):
          dynamic_factor_mq.DynamicFactorMQ(
              dta, factors={"y1": ["a"], "y2": []}
          )
  
      # Singular column of data + standardization
      msg = (
          r"Constant variable\(s\) found in observed variables, but constants"
          " cannot be included in this model."
      )
      with pytest.raises(ValueError, match=msg):
          dynamic_factor_mq.DynamicFactorMQ(dta * 0)
  
      # Non-pandas data when given both monthly and quarterly
      msg = "Given monthly dataset is not a Pandas object."
      with pytest.raises(ValueError, match=msg):
          dynamic_factor_mq.DynamicFactorMQ(dta, endog_quarterly=dta)
      msg = "Given quarterly dataset is not a Pandas object."
      with pytest.raises(ValueError, match=msg):
          dynamic_factor_mq.DynamicFactorMQ(
              dta_period_M, endog_quarterly=dta
          )
  
      # Pandas data without date index when given both monthly and quarterly
      msg = "Given monthly dataset has an index with non-date values."
      with pytest.raises(ValueError, match=msg):
          dynamic_factor_mq.DynamicFactorMQ(
              dta_pd, endog_quarterly=dta_period_Q
          )
      msg = "Given quarterly dataset has an index with non-date values."
      # (test once with period index for monthly...)
      with pytest.raises(ValueError, match=msg):
          dynamic_factor_mq.DynamicFactorMQ(
              dta_period_M, endog_quarterly=dta_pd
          )
      # (...and once with date index for monthly)
      with pytest.raises(ValueError, match=msg):
          dynamic_factor_mq.DynamicFactorMQ(
              dta_date_M, endog_quarterly=dta_pd
          )
  
      # Pandas data with date index of wrong freq
      msg = "Index of given monthly dataset has a non-monthly frequency"
      # (test once with period index for monthly...)
      with pytest.raises(ValueError, match=msg):
          dynamic_factor_mq.DynamicFactorMQ(
              dta_period_W, endog_quarterly=dta_period_Q
          )
      # (...and once with date index for monthly)
      with pytest.raises(ValueError, match=msg):
          dynamic_factor_mq.DynamicFactorMQ(
              dta_date_W, endog_quarterly=dta_period_Q
          )
      msg = "Index of given quarterly dataset has a non-quarterly frequency"
      # (test once with period index for quarterly...)
      with pytest.raises(ValueError, match=msg):
          dynamic_factor_mq.DynamicFactorMQ(
              dta_period_M, endog_quarterly=dta_period_W
          )
      # (and once with date index for quarterly...)
      with pytest.raises(ValueError, match=msg):
          dynamic_factor_mq.DynamicFactorMQ(
              dta_date_M, endog_quarterly=dta_date_W
          )
  
imports: from statsmodels.compat.pandas import MONTH_END, QUARTER_END, assert_frame_equal, assert_series_equal
  import numpy
  from numpy.testing import assert_, assert_allclose, assert_equal
  import pandas
  import pytest
  from statsmodels.regression.linear_model import OLS
  from statsmodels.tools import add_constant
  from statsmodels.tsa.statespace import dynamic_factor, dynamic_factor_mq, sarimax
  from statsmodels.tsa.statespace.tests import test_dynamic_factor_mq_monte_carlo
label_desc: Use image node_id 6 for calling a global function with example usage: test_invalid_model_specification() without return types