class_docstr: Bayesian Imputation using a Gaussian model.
  
  The approach is Bayesian.  The goal is to sample from the joint
  distribution of the mean vector, covariance matrix, and missing
  data values given the observed data values.  Conjugate priors for
  the population mean and covariance matrix are used.  Gibbs
  sampling is used to update the mean vector, covariance matrix, and
  missing data values in turn.  After burn-in, the imputed complete
  data sets from the Gibbs chain can be used in multiple imputation
  analyses (MI).
  
  Parameters
  ----------
  data : ndarray
      The array of data to be imputed.  Values in the array equal to
      NaN are imputed.
  mean_prior : ndarray, optional
      The covariance matrix of the Gaussian prior distribution for
      the mean vector.  If not provided, the identity matrix is
      used.
  cov_prior : ndarray, optional
      The center matrix for the inverse Wishart prior distribution
      for the covariance matrix.  If not provided, the identity
      matrix is used.
  cov_prior_df : positive float
      The degrees of freedom of the inverse Wishart prior
      distribution for the covariance matrix.  Defaults to 1.
  
  Examples
  --------
  A basic example with OLS. Data is generated assuming 10% is missing at
  random.
  
  >>> import numpy as np
  >>> x = np.random.standard_normal((1000, 2))
  >>> x.flat[np.random.sample(2000) < 0.1] = np.nan
  
  The imputer is used with ``MI``.
  
  >>> import statsmodels.api as sm
  >>> def model_args_fn(x):
  ...     # Return endog, exog from x
  ...    return x[:, 0], x[:, 1:]
  >>> imp = sm.BayesGaussMI(x)
  >>> mi = sm.MI(imp, sm.OLS, model_args_fn)
class_docstr_tok: ["Bayesian","Imputation","using","a","Gaussian","model",".","The","approach","is","Bayesian",".","The","goal","is","to","sample","from","the","joint","distribution","of","the","mean","vector",",","covariance","matrix",",","and","missing","data","values","given","the","observed","data","values",".","Conjugate","priors","for","the","population","mean","and","covariance","matrix","are","used",".","Gibbs","sampling","is","used","to","update","the","mean","vector",",","covariance","matrix",",","and","missing","data","values","in","turn",".","After","burn-in",",","the","imputed","complete","data","sets","from","the","Gibbs","chain","can","be","used","in","multiple","imputation","analyses","(","MI",")",".","Parameters","--","--","--","--","--","data",":","ndarray","The","array","of","data","to","be","imputed",".","Values","in","the","array","equal","to","NaN","are","imputed",".","mean_prior",":","ndarray",",","optional","The","covariance","matrix","of","the","Gaussian","prior","distribution","for","the","mean","vector",".","If","not","provided",",","the","identity","matrix","is","used",".","cov_prior",":","ndarray",",","optional","The","center","matrix","for","the","inverse","Wishart","prior","distribution","for","the","covariance","matrix",".","If","not","provided",",","the","identity","matrix","is","used",".","cov_prior_df",":","positive","float","The","degrees","of","freedom","of","the","inverse","Wishart","prior","distribution","for","the","covariance","matrix",".","Defaults","to","1",".","Examples","--","--","--","--","A","basic","example","with","OLS",".","Data","is","generated","assuming","10","%","is","missing","at","random",".",">",">",">","import","numpy","as","np",">",">",">","x","=","np.random.standard_normal","(","(","1000",",","2",")",")",">",">",">","x.flat","[","np.random.sample","(","2000",")","<","0.1","]","=","np.nan","The","imputer","is","used","with","``","MI","``",".",">",">",">","import","statsmodels.api","as","sm",">",">",">","def","model_args_fn","(","x",")",":","...","#","Return","endog",",","exog","from","x","...","return","x","[",":",",","0","]",",","x","[",":",",","1",":","]",">",">",">","imp","=","sm.BayesGaussMI","(","x",")",">",">",">","mi","=","sm.MI","(","imp",",","sm.OLS",",","model_args_fn",")"]
docstr: Gibbs update of the mean vector.
  
  Do not call until update_data has been called once.
docstr_tok: ["Gibbs","update","of","the","mean","vector",".","Do","not","call","until","update_data","has","been","called","once","."]
code: def update_mean(self):
      """
      Gibbs update of the mean vector.
  
      Do not call until update_data has been called once.
      """
      # https://stats.stackexchange.com/questions/28744/multivariate-normal-posterior
  
      # Posterior covariance matrix of the mean
      cm = np.linalg.solve(
          self.cov / self.nobs + self.mean_prior,
          self.mean_prior / self.nobs,
      )
      cm = np.dot(self.cov, cm)
  
      # Posterior mean of the mean
      vm = np.linalg.solve(self.cov, self._data.sum(0))
      vm = np.dot(cm, vm)
  
      # Sample
      r = np.linalg.cholesky(cm)
      self.mean = vm + np.dot(r, np.random.normal(0, 1, self.nvar))
  
file_path: statsmodels/statsmodels/imputation/bayes_mi.py
imports: import numpy
  import pandas
  from statsmodels.base.model import LikelihoodModelResults
label_desc: Use image node_id 4 for calling the BayesGaussMI obj's underlying member method code with example usage: obj.update_mean() without return types