class_docstr: Repeated measures Anova using least squares regression
  
  The full model regression residual sum of squares is
  used to compare with the reduced model for calculating the
  within-subject effect sum of squares [1].
  
  Currently, only fully balanced within-subject designs are supported.
  Calculation of between-subject effects and corrections for violation of
  sphericity are not yet implemented.
  
  Parameters
  ----------
  data : DataFrame
  depvar : str
      The dependent variable in `data`
  subject : str
      Specify the subject id
  within : list[str]
      The within-subject factors
  between : list[str]
      The between-subject factors, this is not yet implemented
  aggregate_func : {None, 'mean', callable}
      If the data set contains more than a single observation per subject
      and cell of the specified model, this function will be used to
      aggregate the data before running the Anova. `None` (the default) will
      not perform any aggregation; 'mean' is s shortcut to `numpy.mean`.
      An exception will be raised if aggregation is required, but no
      aggregation function was specified.
  
  Returns
  -------
  results : AnovaResults instance
  
  Raises
  ------
  ValueError
      If the data need to be aggregated, but `aggregate_func` was not
      specified.
  
  Notes
  -----
  This implementation currently only supports fully balanced designs. If the
  data contain more than one observation per subject and cell of the design,
  these observations need to be aggregated into a single observation
  before the Anova is calculated, either manually or by passing an aggregation
  function via the `aggregate_func` keyword argument.
  Note that if the input data set was not balanced before performing the
  aggregation, the implied heteroscedasticity of the data is ignored.
  
  References
  ----------
  .. [*] Rutherford, Andrew. Anova and ANCOVA: a GLM approach. John Wiley & Sons, 2011.
class_docstr_tok: ["Repeated","measures","Anova","using","least","squares","regression","The","full","model","regression","residual","sum","of","squares","is","used","to","compare","with","the","reduced","model","for","calculating","the","within-subject","effect","sum","of","squares","[","1","]",".","Currently",",","only","fully","balanced","within-subject","designs","are","supported",".","Calculation","of","between-subject","effects","and","corrections","for","violation","of","sphericity","are","not","yet","implemented",".","Parameters","--","--","--","--","--","data",":","DataFrame","depvar",":","str","The","dependent","variable","in","`","data","`","subject",":","str","Specify","the","subject","id","within",":","list","[","str","]","The","within-subject","factors","between",":","list","[","str","]","The","between-subject","factors",",","this","is","not","yet","implemented","aggregate_func",":","{","None",",","'mean","'",",","callable","}","If","the","data","set","contains","more","than","a","single","observation","per","subject","and","cell","of","the","specified","model",",","this","function","will","be","used","to","aggregate","the","data","before","running","the","Anova",".","`","None","`","(","the","default",")","will","not","perform","any","aggregation",";","'mean","'","is","s","shortcut","to","`","numpy.mean","`",".","An","exception","will","be","raised","if","aggregation","is","required",",","but","no","aggregation","function","was","specified",".","Returns","--","--","--","-","results",":","AnovaResults","instance","Raises","--","--","--","ValueError","If","the","data","need","to","be","aggregated",",","but","`","aggregate_func","`","was","not","specified",".","Notes","--","--","-","This","implementation","currently","only","supports","fully","balanced","designs",".","If","the","data","contain","more","than","one","observation","per","subject","and","cell","of","the","design",",","these","observations","need","to","be","aggregated","into","a","single","observation","before","the","Anova","is","calculated",",","either","manually","or","by","passing","an","aggregation","function","via","the","`","aggregate_func","`","keyword","argument",".","Note","that","if","the","input","data","set","was","not","balanced","before","performing","the","aggregation",",","the","implied","heteroscedasticity","of","the","data","is","ignored",".","References","--","--","--","--","--","..","[","*","]","Rutherford",",","Andrew",".","Anova","and","ANCOVA",":","a","GLM","approach",".","John","Wiley","&","Sons",",","2011","."]
code: def __init__(
      self,
      data,
      depvar,
      subject,
      within=None,
      between=None,
      aggregate_func=None,
  ):
      self.data = data
      self.depvar = depvar
      self.within = within
      if "C" in within:
          raise ValueError(
              "Factor name cannot be 'C'! This is in conflict "
              "with patsy's contrast function name."
          )
      self.between = between
      if between is not None:
          raise NotImplementedError(
              "Between subject effect not " "yet supported!"
          )
      self.subject = subject
  
      if aggregate_func == "mean":
          self.aggregate_func = pd.Series.mean
      else:
          self.aggregate_func = aggregate_func
  
      if not data.equals(
          data.drop_duplicates(subset=[subject] + within)
      ):
          if self.aggregate_func is not None:
              self._aggregate()
          else:
              msg = (
                  "The data set contains more than one observation per "
                  "subject and cell. Either aggregate the data manually, "
                  "or pass the `aggregate_func` parameter."
              )
              raise ValueError(msg)
  
      self._check_data_balanced()
  
imports: from statsmodels.compat.python import lrange
  import numpy
  import pandas
  from pandas import DataFrame, Index
  import patsy
  from scipy import stats
  from statsmodels.formula.formulatools import _has_intercept, _intercept_idx, _remove_intercept_patsy
  from statsmodels.iolib import summary2
  from statsmodels.regression.linear_model import OLS
label_desc: Use image node_id 1 to create a new AnovaRM object  with example: obj = AnovaRM(data, depvar, subject, within, between, aggregate_func)