docstr: Fit a BayesMixedGLM using a formula.
  
  Parameters
  ----------
  formula : str
      Formula for the endog and fixed effects terms (use ~ to
      separate dependent and independent expressions).
  vc_formulas : dictionary
      vc_formulas[name] is a one-sided formula that creates one
      collection of random effects with a common variance
      parameter.  If using categorical (factor) variables to
      produce variance components, note that generally `0 + ...`
      should be used so that an intercept is not included.
  data : data frame
      The data to which the formulas are applied.
  family : genmod.families instance
      A GLM family.
  vcp_p : float
      The prior standard deviation for the logarithms of the standard
      deviations of the random effects.
  fe_p : float
      The prior standard deviation for the fixed effects parameters.
docstr_tok: ["Fit","a","BayesMixedGLM","using","a","formula",".","Parameters","--","--","--","--","--","formula",":","str","Formula","for","the","endog","and","fixed","effects","terms","(","use","~","to","separate","dependent","and","independent","expressions",")",".","vc_formulas",":","dictionary","vc_formulas","[","name","]","is","a","one-sided","formula","that","creates","one","collection","of","random","effects","with","a","common","variance","parameter",".","If","using","categorical","(","factor",")","variables","to","produce","variance","components",",","note","that","generally","`","0","+","...","`","should","be","used","so","that","an","intercept","is","not","included",".","data",":","data","frame","The","data","to","which","the","formulas","are","applied",".","family",":","genmod.families","instance","A","GLM","family",".","vcp_p",":","float","The","prior","standard","deviation","for","the","logarithms","of","the","standard","deviations","of","the","random","effects",".","fe_p",":","float","The","prior","standard","deviation","for","the","fixed","effects","parameters","."]
code: def from_formula(
      cls, formula, vc_formulas, data, family=None, vcp_p=1, fe_p=2
  ):
      """
      Fit a BayesMixedGLM using a formula.
  
      Parameters
      ----------
      formula : str
          Formula for the endog and fixed effects terms (use ~ to
          separate dependent and independent expressions).
      vc_formulas : dictionary
          vc_formulas[name] is a one-sided formula that creates one
          collection of random effects with a common variance
          parameter.  If using categorical (factor) variables to
          produce variance components, note that generally `0 + ...`
          should be used so that an intercept is not included.
      data : data frame
          The data to which the formulas are applied.
      family : genmod.families instance
          A GLM family.
      vcp_p : float
          The prior standard deviation for the logarithms of the standard
          deviations of the random effects.
      fe_p : float
          The prior standard deviation for the fixed effects parameters.
      """
  
      ident = []
      exog_vc = []
      vcp_names = []
      j = 0
      for na, fml in vc_formulas.items():
          mat = patsy.dmatrix(fml, data, return_type="dataframe")
          exog_vc.append(mat)
          vcp_names.append(na)
          ident.append(j * np.ones(mat.shape[1], dtype=np.int_))
          j += 1
      exog_vc = pd.concat(exog_vc, axis=1)
      vc_names = exog_vc.columns.tolist()
  
      ident = np.concatenate(ident)
  
      model = super().from_formula(
          formula,
          data=data,
          family=family,
          subset=None,
          exog_vc=exog_vc,
          ident=ident,
          vc_names=vc_names,
          vcp_names=vcp_names,
          fe_p=fe_p,
          vcp_p=vcp_p,
      )
  
      return model
  
imports: import numpy
  from scipy.optimize import minimize
  from scipy import sparse
  import statsmodels.base.model
  from statsmodels.iolib import summary2
  from statsmodels.genmod import families
  import pandas
  import warnings
  import patsy
label_desc: Use image node_id 6 for calling the _BayesMixedGLM obj's underlying member method code with example usage: obj.from_formula(cls, formula, vc_formulas, data, family, vcp_p, fe_p) and returns: model