code: def test_formulas(self):
      np.random.seed(2410)
      exog = np.random.normal(size=(300, 4))
      exog_re = np.random.normal(size=300)
      groups = np.kron(np.arange(100), [1, 1, 1])
      g_errors = exog_re * np.kron(
          np.random.normal(size=100), [1, 1, 1]
      )
      endog = exog.sum(1) + g_errors + np.random.normal(size=300)
  
      mod1 = MixedLM(endog, exog, groups, exog_re)
      # test the names
      assert_(mod1.data.xnames == ["x1", "x2", "x3", "x4"])
      assert_(mod1.data.exog_re_names == ["x_re1"])
      assert_(mod1.data.exog_re_names_full == ["x_re1 Var"])
      rslt1 = mod1.fit()
  
      # Fit with a formula, passing groups as the actual values.
      df = pd.DataFrame({"endog": endog})
      for k in range(exog.shape[1]):
          df["exog%d" % k] = exog[:, k]
      df["exog_re"] = exog_re
      fml = "endog ~ 0 + exog0 + exog1 + exog2 + exog3"
      re_fml = "0 + exog_re"
      mod2 = MixedLM.from_formula(
          fml, df, re_formula=re_fml, groups=groups
      )
  
      assert_(mod2.data.xnames == ["exog0", "exog1", "exog2", "exog3"])
      assert_(mod2.data.exog_re_names == ["exog_re"])
      assert_(mod2.data.exog_re_names_full == ["exog_re Var"])
  
      rslt2 = mod2.fit()
      assert_almost_equal(rslt1.params, rslt2.params)
  
      # Fit with a formula, passing groups as the variable name.
      df["groups"] = groups
      mod3 = MixedLM.from_formula(
          fml, df, re_formula=re_fml, groups="groups"
      )
      assert_(mod3.data.xnames == ["exog0", "exog1", "exog2", "exog3"])
      assert_(mod3.data.exog_re_names == ["exog_re"])
      assert_(mod3.data.exog_re_names_full == ["exog_re Var"])
  
      rslt3 = mod3.fit(start_params=rslt2.params)
      assert_allclose(rslt1.params, rslt3.params, rtol=1e-4)
  
      # Check default variance structure with non-formula model
      # creation, also use different exog_re that produces a zero
      # estimated variance parameter.
      exog_re = np.ones(len(endog), dtype=np.float64)
      mod4 = MixedLM(endog, exog, groups, exog_re)
      with warnings.catch_warnings():
          warnings.simplefilter("ignore")
          rslt4 = mod4.fit()
      from statsmodels.formula.api import mixedlm
  
      mod5 = mixedlm(fml, df, groups="groups")
      assert_(mod5.data.exog_re_names == ["groups"])
      assert_(mod5.data.exog_re_names_full == ["groups Var"])
      with warnings.catch_warnings():
          warnings.simplefilter("ignore")
          rslt5 = mod5.fit()
      assert_almost_equal(rslt4.params, rslt5.params)
  
imports: from statsmodels.compat.platform import PLATFORM_OSX
  import os
  import csv
  import warnings
  import numpy
  import pandas
  from scipy import sparse
  import pytest
  from statsmodels.regression.mixed_linear_model import MixedLM, MixedLMParams, _smw_solver, _smw_logdet
  from numpy.testing import assert_almost_equal, assert_equal, assert_allclose, assert_
  from statsmodels.base import _penalties
  import statsmodels.tools.numdiff
  from .results import lme_r_results
label_desc: Use image node_id 13 for calling the TestMixedLM obj's underlying member method code with example usage: obj.test_formulas() without return types