class_docstr: A private class for simulating data from a given mixed linear model.
  
  Parameters
  ----------
  model : MixedLM instance
      A mixed linear model
  params : array_like
      A parameter vector defining a mixed linear model.  See
      notes for more information.
  scale : scalar
      The unexplained variance
  exog : array_like
      An array of fixed effect covariates.  If None, model.exog
      is used.
  
  Notes
  -----
  The params array is a vector containing fixed effects parameters,
  random effects parameters, and variance component parameters, in
  that order.  The lower triangle of the random effects covariance
  matrix is stored.  The random effects and variance components
  parameters are divided by the scale parameter.
  
  This class is used in Mediation, and possibly elsewhere.
class_docstr_tok: ["A","private","class","for","simulating","data","from","a","given","mixed","linear","model",".","Parameters","--","--","--","--","--","model",":","MixedLM","instance","A","mixed","linear","model","params",":","array_like","A","parameter","vector","defining","a","mixed","linear","model",".","See","notes","for","more","information",".","scale",":","scalar","The","unexplained","variance","exog",":","array_like","An","array","of","fixed","effect","covariates",".","If","None",",","model.exog","is","used",".","Notes","--","--","-","The","params","array","is","a","vector","containing","fixed","effects","parameters",",","random","effects","parameters",",","and","variance","component","parameters",",","in","that","order",".","The","lower","triangle","of","the","random","effects","covariance","matrix","is","stored",".","The","random","effects","and","variance","components","parameters","are","divided","by","the","scale","parameter",".","This","class","is","used","in","Mediation",",","and","possibly","elsewhere","."]
docstr: Return a vector of simulated values from a mixed linear
  model.
  
  The parameter n is ignored, but required by the interface
docstr_tok: ["Return","a","vector","of","simulated","values","from","a","mixed","linear","model",".","The","parameter","n","is","ignored",",","but","required","by","the","interface"]
code: def rvs(self, n):
      """
      Return a vector of simulated values from a mixed linear
      model.
  
      The parameter n is ignored, but required by the interface
      """
  
      model = self.model
  
      # Fixed effects
      y = np.dot(self.exog, self.fe_params)
  
      # Random effects
      u = np.random.normal(size=(model.n_groups, model.k_re))
      u = np.dot(u, np.linalg.cholesky(self.cov_re).T)
      y += (u[self.group_idx, :] * model.exog_re).sum(1)
  
      # Variance components
      for j, _ in enumerate(model.exog_vc.names):
          ex = model.exog_vc.mats[j]
          v = self.vcomp[j]
          for i, g in enumerate(model.group_labels):
              exg = ex[i]
              ii = model.row_indices[g]
              u = np.random.normal(size=exg.shape[1])
              y[ii] += np.sqrt(v) * np.dot(exg, u)
  
      # Residual variance
      y += np.sqrt(self.scale) * np.random.normal(size=len(y))
  
      return y
  
imports: import warnings
  import numpy
  import pandas
  import patsy
  from scipy import sparse
  from scipy.stats.distributions import norm
  from statsmodels.base._penalties import Penalty
  import statsmodels.base.model
  from statsmodels.tools import data
  from statsmodels.tools.decorators import cache_readonly
  from statsmodels.tools.sm_exceptions import ConvergenceWarning
label_desc: Use image node_id 2 for calling the _mixedlm_distribution obj's underlying member method code with example usage: obj.rvs(n) and returns: y