class_docstr: A Formula is a model for a mean in a regression model.
  
  It is often given by a sequence of sympy expressions, with the mean
  model being the sum of each term multiplied by a linear regression
  coefficient.
  
  The expressions may depend on additional Symbol instances, giving a
  non-linear regression model.
class_docstr_tok: ["A","Formula","is","a","model","for","a","mean","in","a","regression","model",".","It","is","often","given","by","a","sequence","of","sympy","expressions",",","with","the","mean","model","being","the","sum","of","each","term","multiplied","by","a","linear","regression","coefficient",".","The","expressions","may","depend","on","additional","Symbol","instances",",","giving","a","non-linear","regression","model","."]
docstr: Perform a sympy substitution on all terms in the Formula
  
  Returns a new instance of the same class
  
  Parameters
  ----------
  old : sympy.Basic
     The expression to be changed
  new : sympy.Basic
     The value to change it to.
  
  Returns
  -------
  newf : Formula
  
  Examples
  --------
  >>> s, t = [Term(l) for l in 'st']
  >>> f, g = [sympy.Function(l) for l in 'fg']
  >>> form = Formula([f(t),g(s)])
  >>> newform = form.subs(g, sympy.Function('h'))
  >>> newform.terms
  array([f(t), h(s)], dtype=object)
  >>> form.terms
  array([f(t), g(s)], dtype=object)
docstr_tok: ["Perform","a","sympy","substitution","on","all","terms","in","the","Formula","Returns","a","new","instance","of","the","same","class","Parameters","--","--","--","--","--","old",":","sympy.Basic","The","expression","to","be","changed","new",":","sympy.Basic","The","value","to","change","it","to",".","Returns","--","--","--","-","newf",":","Formula","Examples","--","--","--","--",">",">",">","s",",","t","=","[","Term","(","l",")","for","l","in","'st","'","]",">",">",">","f",",","g","=","[","sympy.Function","(","l",")","for","l","in","'fg","'","]",">",">",">","form","=","Formula","(","[","f","(","t",")",",","g","(","s",")","]",")",">",">",">","newform","=","form.subs","(","g",",","sympy.Function","(","'","h","'",")",")",">",">",">","newform.terms","array","(","[","f","(","t",")",",","h","(","s",")","]",",","dtype=object",")",">",">",">","form.terms","array","(","[","f","(","t",")",",","g","(","s",")","]",",","dtype=object",")"]
code: def subs(self, old, new):
      """Perform a sympy substitution on all terms in the Formula
  
      Returns a new instance of the same class
  
      Parameters
      ----------
      old : sympy.Basic
         The expression to be changed
      new : sympy.Basic
         The value to change it to.
  
      Returns
      -------
      newf : Formula
  
      Examples
      --------
      >>> s, t = [Term(l) for l in 'st']
      >>> f, g = [sympy.Function(l) for l in 'fg']
      >>> form = Formula([f(t),g(s)])
      >>> newform = form.subs(g, sympy.Function('h'))
      >>> newform.terms
      array([f(t), h(s)], dtype=object)
      >>> form.terms
      array([f(t), g(s)], dtype=object)
      """
      return self.__class__(
          [term.subs(old, new) for term in self.terms]
      )
  
imports: import itertools
  import warnings
  from string import ascii_letters, digits
  import numpy
  import sympy
  from scipy.linalg import pinv
  from sympy import Dummy, default_sort_key
  from sympy.utilities.lambdify import implemented_function, lambdify
  from nipy.algorithms.utils.matrices import full_rank, matrix_rank
  from nipy.utils import VisibleDeprecationWarning, _NoValue
label_desc: Use image node_id 10 for calling the Formula obj's underlying member method code with example usage: obj.subs(old, new) and returns: self