class_docstr: Linear Mixed Effects Model
  
  Parameters
  ----------
  endog : 1d array_like
      The dependent variable
  exog : 2d array_like
      A matrix of covariates used to determine the
      mean structure (the "fixed effects" covariates).
  groups : 1d array_like
      A vector of labels determining the groups -- data from
      different groups are independent
  exog_re : 2d array_like
      A matrix of covariates used to determine the variance and
      covariance structure (the "random effects" covariates).  If
      None, defaults to a random intercept for each group.
  exog_vc : VCSpec instance or dict-like (deprecated)
      A VCSPec instance defines the structure of the variance
      components in the model.  Alternatively, see notes below
      for a dictionary-based format.  The dictionary format is
      deprecated and may be removed at some point in the future.
  use_sqrt : bool
      If True, optimization is carried out using the lower
      triangle of the square root of the random effects
      covariance matrix, otherwise it is carried out using the
      lower triangle of the random effects covariance matrix.
  missing : str
      The approach to missing data handling
  
  Notes
  -----
  If `exog_vc` is not a `VCSpec` instance, then it must be a
  dictionary of dictionaries.  Specifically, `exog_vc[a][g]` is a
  matrix whose columns are linearly combined using independent
  random coefficients.  This random term then contributes to the
  variance structure of the data for group `g`.  The random
  coefficients all have mean zero, and have the same variance.  The
  matrix must be `m x k`, where `m` is the number of observations in
  group `g`.  The number of columns may differ among the top-level
  groups.
  
  The covariates in `exog`, `exog_re` and `exog_vc` may (but need
  not) partially or wholly overlap.
  
  `use_sqrt` should almost always be set to True.  The main use case
  for use_sqrt=False is when complicated patterns of fixed values in
  the covariance structure are set (using the `free` argument to
  `fit`) that cannot be expressed in terms of the Cholesky factor L.
  
  Examples
  --------
  A basic mixed model with fixed effects for the columns of
  ``exog`` and a random intercept for each distinct value of
  ``group``:
  
  >>> model = sm.MixedLM(endog, exog, groups)
  >>> result = model.fit()
  
  A mixed model with fixed effects for the columns of ``exog`` and
  correlated random coefficients for the columns of ``exog_re``:
  
  >>> model = sm.MixedLM(endog, exog, groups, exog_re=exog_re)
  >>> result = model.fit()
  
  A mixed model with fixed effects for the columns of ``exog`` and
  independent random coefficients for the columns of ``exog_re``:
  
  >>> free = MixedLMParams.from_components(
                   fe_params=np.ones(exog.shape[1]),
                   cov_re=np.eye(exog_re.shape[1]))
  >>> model = sm.MixedLM(endog, exog, groups, exog_re=exog_re)
  >>> result = model.fit(free=free)
  
  A different way to specify independent random coefficients for the
  columns of ``exog_re``.  In this example ``groups`` must be a
  Pandas Series with compatible indexing with ``exog_re``, and
  ``exog_re`` has two columns.
  
  >>> g = pd.groupby(groups, by=groups).groups
  >>> vc = {}
  >>> vc['1'] = {k : exog_re.loc[g[k], 0] for k in g}
  >>> vc['2'] = {k : exog_re.loc[g[k], 1] for k in g}
  >>> model = sm.MixedLM(endog, exog, groups, vcomp=vc)
  >>> result = model.fit()
class_docstr_tok: ["Linear","Mixed","Effects","Model","Parameters","--","--","--","--","--","endog",":","1d","array_like","The","dependent","variable","exog",":","2d","array_like","A","matrix","of","covariates","used","to","determine","the","mean","structure","(","the","``","fixed","effects","''","covariates",")",".","groups",":","1d","array_like","A","vector","of","labels","determining","the","groups","--","data","from","different","groups","are","independent","exog_re",":","2d","array_like","A","matrix","of","covariates","used","to","determine","the","variance","and","covariance","structure","(","the","``","random","effects","''","covariates",")",".","If","None",",","defaults","to","a","random","intercept","for","each","group",".","exog_vc",":","VCSpec","instance","or","dict-like","(","deprecated",")","A","VCSPec","instance","defines","the","structure","of","the","variance","components","in","the","model",".","Alternatively",",","see","notes","below","for","a","dictionary-based","format",".","The","dictionary","format","is","deprecated","and","may","be","removed","at","some","point","in","the","future",".","use_sqrt",":","bool","If","True",",","optimization","is","carried","out","using","the","lower","triangle","of","the","square","root","of","the","random","effects","covariance","matrix",",","otherwise","it","is","carried","out","using","the","lower","triangle","of","the","random","effects","covariance","matrix",".","missing",":","str","The","approach","to","missing","data","handling","Notes","--","--","-","If","`","exog_vc","`","is","not","a","`","VCSpec","`","instance",",","then","it","must","be","a","dictionary","of","dictionaries",".","Specifically",",","`","exog_vc","[","a","]","[","g","]","`","is","a","matrix","whose","columns","are","linearly","combined","using","independent","random","coefficients",".","This","random","term","then","contributes","to","the","variance","structure","of","the","data","for","group","`","g","`",".","The","random","coefficients","all","have","mean","zero",",","and","have","the","same","variance",".","The","matrix","must","be","`","m","x","k","`",",","where","`","m","`","is","the","number","of","observations","in","group","`","g","`",".","The","number","of","columns","may","differ","among","the","top-level","groups",".","The","covariates","in","`","exog","`",",","`","exog_re","`","and","`","exog_vc","`","may","(","but","need","not",")","partially","or","wholly","overlap",".","`","use_sqrt","`","should","almost","always","be","set","to","True",".","The","main","use","case","for","use_sqrt=False","is","when","complicated","patterns","of","fixed","values","in","the","covariance","structure","are","set","(","using","the","`","free","`","argument","to","`","fit","`",")","that","can","not","be","expressed","in","terms","of","the","Cholesky","factor","L.","Examples","--","--","--","--","A","basic","mixed","model","with","fixed","effects","for","the","columns","of","``","exog","``","and","a","random","intercept","for","each","distinct","value","of","``","group","``",":",">",">",">","model","=","sm.MixedLM","(","endog",",","exog",",","groups",")",">",">",">","result","=","model.fit","(",")","A","mixed","model","with","fixed","effects","for","the","columns","of","``","exog","``","and","correlated","random","coefficients","for","the","columns","of","``","exog_re","``",":",">",">",">","model","=","sm.MixedLM","(","endog",",","exog",",","groups",",","exog_re=exog_re",")",">",">",">","result","=","model.fit","(",")","A","mixed","model","with","fixed","effects","for","the","columns","of","``","exog","``","and","independent","random","coefficients","for","the","columns","of","``","exog_re","``",":",">",">",">","free","=","MixedLMParams.from_components","(","fe_params=np.ones","(","exog.shape","[","1","]",")",",","cov_re=np.eye","(","exog_re.shape","[","1","]",")",")",">",">",">","model","=","sm.MixedLM","(","endog",",","exog",",","groups",",","exog_re=exog_re",")",">",">",">","result","=","model.fit","(","free=free",")","A","different","way","to","specify","independent","random","coefficients","for","the","columns","of","``","exog_re","``",".","In","this","example","``","groups","``","must","be","a","Pandas","Series","with","compatible","indexing","with","``","exog_re","``",",","and","``","exog_re","``","has","two","columns",".",">",">",">","g","=","pd.groupby","(","groups",",","by=groups",")",".groups",">",">",">","vc","=","{","}",">",">",">","vc","[","'","1","'","]","=","{","k",":","exog_re.loc","[","g","[","k","]",",","0","]","for","k","in","g","}",">",">",">","vc","[","'","2","'","]","=","{","k",":","exog_re.loc","[","g","[","k","]",",","1","]","for","k","in","g","}",">",">",">","model","=","sm.MixedLM","(","endog",",","exog",",","groups",",","vcomp=vc",")",">",">",">","result","=","model.fit","(",")"]
docstr: Returns the score with respect to untransformed parameters.
  
  Calculates the score vector for the profiled log-likelihood of
  the mixed effects model with respect to the parameterization
  in which the random effects covariance matrix is represented
  in its full form (not using the Cholesky factor).
  
  Parameters
  ----------
  params : MixedLMParams or array_like
      The parameter at which the score function is evaluated.
      If array-like, must contain the packed random effects
      parameters (cov_re and vcomp) without fe_params.
  calc_fe : bool
      If True, calculate the score vector for the fixed effects
      parameters.  If False, this vector is not calculated, and
      a vector of zeros is returned in its place.
  
  Returns
  -------
  score_fe : array_like
      The score vector with respect to the fixed effects
      parameters.
  score_re : array_like
      The score vector with respect to the random effects
      parameters (excluding variance components parameters).
  score_vc : array_like
      The score vector with respect to variance components
      parameters.
  
  Notes
  -----
  `score_re` is taken with respect to the parameterization in
  which `cov_re` is represented through its lower triangle
  (without taking the Cholesky square root).
docstr_tok: ["Returns","the","score","with","respect","to","untransformed","parameters",".","Calculates","the","score","vector","for","the","profiled","log-likelihood","of","the","mixed","effects","model","with","respect","to","the","parameterization","in","which","the","random","effects","covariance","matrix","is","represented","in","its","full","form","(","not","using","the","Cholesky","factor",")",".","Parameters","--","--","--","--","--","params",":","MixedLMParams","or","array_like","The","parameter","at","which","the","score","function","is","evaluated",".","If","array-like",",","must","contain","the","packed","random","effects","parameters","(","cov_re","and","vcomp",")","without","fe_params",".","calc_fe",":","bool","If","True",",","calculate","the","score","vector","for","the","fixed","effects","parameters",".","If","False",",","this","vector","is","not","calculated",",","and","a","vector","of","zeros","is","returned","in","its","place",".","Returns","--","--","--","-","score_fe",":","array_like","The","score","vector","with","respect","to","the","fixed","effects","parameters",".","score_re",":","array_like","The","score","vector","with","respect","to","the","random","effects","parameters","(","excluding","variance","components","parameters",")",".","score_vc",":","array_like","The","score","vector","with","respect","to","variance","components","parameters",".","Notes","--","--","-","`","score_re","`","is","taken","with","respect","to","the","parameterization","in","which","`","cov_re","`","is","represented","through","its","lower","triangle","(","without","taking","the","Cholesky","square","root",")","."]
code: def score_full(self, params, calc_fe):
      """
      Returns the score with respect to untransformed parameters.
  
      Calculates the score vector for the profiled log-likelihood of
      the mixed effects model with respect to the parameterization
      in which the random effects covariance matrix is represented
      in its full form (not using the Cholesky factor).
  
      Parameters
      ----------
      params : MixedLMParams or array_like
          The parameter at which the score function is evaluated.
          If array-like, must contain the packed random effects
          parameters (cov_re and vcomp) without fe_params.
      calc_fe : bool
          If True, calculate the score vector for the fixed effects
          parameters.  If False, this vector is not calculated, and
          a vector of zeros is returned in its place.
  
      Returns
      -------
      score_fe : array_like
          The score vector with respect to the fixed effects
          parameters.
      score_re : array_like
          The score vector with respect to the random effects
          parameters (excluding variance components parameters).
      score_vc : array_like
          The score vector with respect to variance components
          parameters.
  
      Notes
      -----
      `score_re` is taken with respect to the parameterization in
      which `cov_re` is represented through its lower triangle
      (without taking the Cholesky square root).
      """
  
      fe_params = params.fe_params
      cov_re = params.cov_re
      vcomp = params.vcomp
  
      try:
          cov_re_inv = np.linalg.inv(cov_re)
      except np.linalg.LinAlgError:
          cov_re_inv = np.linalg.pinv(cov_re)
          self._cov_sing += 1
  
      score_fe = np.zeros(self.k_fe)
      score_re = np.zeros(self.k_re2)
      score_vc = np.zeros(self.k_vc)
  
      # Handle the covariance penalty.
      if self.cov_pen is not None:
          score_re -= self.cov_pen.deriv(cov_re, cov_re_inv)
  
      # Handle the fixed effects penalty.
      if calc_fe and (self.fe_pen is not None):
          score_fe -= self.fe_pen.deriv(fe_params)
  
      # resid' V^{-1} resid, summed over the groups (a scalar)
      rvir = 0.0
  
      # exog' V^{-1} resid, summed over the groups (a k_fe
      # dimensional vector)
      xtvir = 0.0
  
      # exog' V^{_1} exog, summed over the groups (a k_fe x k_fe
      # matrix)
      xtvix = 0.0
  
      # V^{-1} exog' dV/dQ_jj exog V^{-1}, where Q_jj is the jj^th
      # covariance parameter.
      xtax = [
          0.0,
      ] * (self.k_re2 + self.k_vc)
  
      # Temporary related to the gradient of log |V|
      dlv = np.zeros(self.k_re2 + self.k_vc)
  
      # resid' V^{-1} dV/dQ_jj V^{-1} resid (a scalar)
      rvavr = np.zeros(self.k_re2 + self.k_vc)
  
      for group_ix, group in enumerate(self.group_labels):
          vc_var = self._expand_vcomp(vcomp, group_ix)
  
          exog = self.exog_li[group_ix]
          ex_r, ex2_r = self._aex_r[group_ix], self._aex_r2[group_ix]
          solver = _smw_solver(1.0, ex_r, ex2_r, cov_re_inv, 1 / vc_var)
  
          # The residuals
          resid = self.endog_li[group_ix]
          if self.k_fe > 0:
              expval = np.dot(exog, fe_params)
              resid = resid - expval
  
          if self.reml:
              viexog = solver(exog)
              xtvix += np.dot(exog.T, viexog)
  
          # Contributions to the covariance parameter gradient
          vir = solver(resid)
          for jj, matl, matr, vsl, vsr, sym in self._gen_dV_dPar(
              ex_r, solver, group_ix
          ):
              dlv[jj] = _dotsum(matr, vsl)
              if not sym:
                  dlv[jj] += _dotsum(matl, vsr)
  
              ul = _dot(vir, matl)
              ur = ul.T if sym else _dot(matr.T, vir)
              ulr = np.dot(ul, ur)
              rvavr[jj] += ulr
              if not sym:
                  rvavr[jj] += ulr.T
  
              if self.reml:
                  ul = _dot(viexog.T, matl)
                  ur = ul.T if sym else _dot(matr.T, viexog)
                  ulr = np.dot(ul, ur)
                  xtax[jj] += ulr
                  if not sym:
                      xtax[jj] += ulr.T
  
          # Contribution of log|V| to the covariance parameter
          # gradient.
          if self.k_re > 0:
              score_re -= 0.5 * dlv[0 : self.k_re2]
          if self.k_vc > 0:
              score_vc -= 0.5 * dlv[self.k_re2 :]
  
          rvir += np.dot(resid, vir)
  
          if calc_fe:
              xtvir += np.dot(exog.T, vir)
  
      fac = self.n_totobs
      if self.reml:
          fac -= self.k_fe
  
      if calc_fe and self.k_fe > 0:
          score_fe += fac * xtvir / rvir
  
      if self.k_re > 0:
          score_re += 0.5 * fac * rvavr[0 : self.k_re2] / rvir
      if self.k_vc > 0:
          score_vc += 0.5 * fac * rvavr[self.k_re2 :] / rvir
  
      if self.reml:
          xtvixi = np.linalg.inv(xtvix)
          for j in range(self.k_re2):
              score_re[j] += 0.5 * _dotsum(xtvixi.T, xtax[j])
          for j in range(self.k_vc):
              score_vc[j] += 0.5 * _dotsum(
                  xtvixi.T, xtax[self.k_re2 + j]
              )
  
      return score_fe, score_re, score_vc
  
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 14 for calling the MixedLM obj's underlying member method code with example usage: obj.score_full(params, calc_fe) and returns: score_fe,  score_re,  score_vc