class_docstr: Penalty for Generalized Additive Models
  
  Parameters
  ----------
  multivariate_smoother : instance
      instance of additive smoother or spline class
  alpha : list of float
      default penalty weight, list with length equal to the number of smooth
      terms. ``alpha`` can also be provided to each method.
  weights : array_like
      currently not used
      is a list of doubles of the same length as alpha or a list
      of ndarrays where each component has the length equal to the number
      of columns in that component
  start_idx : int
      number of parameters that come before the smooth terms. If the model
      has a linear component, then the parameters for the smooth components
      start at ``start_index``.
  
  Attributes
  ----------
  Parameters are stored, additionally
  nob s: The number of samples used during the estimation
  
  dim_basis : number of columns of additive smoother. Number of columns
      in all smoothers.
  k_variables : number of smooth terms
  k_params : total number of parameters in the regression model
class_docstr_tok: ["Penalty","for","Generalized","Additive","Models","Parameters","--","--","--","--","--","multivariate_smoother",":","instance","instance","of","additive","smoother","or","spline","class","alpha",":","list","of","float","default","penalty","weight",",","list","with","length","equal","to","the","number","of","smooth","terms",".","``","alpha","``","can","also","be","provided","to","each","method",".","weights",":","array_like","currently","not","used","is","a","list","of","doubles","of","the","same","length","as","alpha","or","a","list","of","ndarrays","where","each","component","has","the","length","equal","to","the","number","of","columns","in","that","component","start_idx",":","int","number","of","parameters","that","come","before","the","smooth","terms",".","If","the","model","has","a","linear","component",",","then","the","parameters","for","the","smooth","components","start","at","``","start_index","``",".","Attributes","--","--","--","--","--","Parameters","are","stored",",","additionally","nob","s",":","The","number","of","samples","used","during","the","estimation","dim_basis",":","number","of","columns","of","additive","smoother",".","Number","of","columns","in","all","smoothers",".","k_variables",":","number","of","smooth","terms","k_params",":","total","number","of","parameters","in","the","regression","model"]
docstr: penalty matrix for generalized additive model
  
  Parameters
  ----------
  alpha : list of floats or None
      penalty weights
  
  Returns
  -------
  penalty matrix
      block diagonal, square penalty matrix for quadratic penalization.
      The number of rows and columns are equal to the number of
      parameters in the regression model ``k_params``.
  
  Notes
  -----
  statsmodels does not support backwards compatibility when keywords are
  used as positional arguments. The order of keywords might change.
  We might need to add a ``params`` keyword if the need arises.
docstr_tok: ["penalty","matrix","for","generalized","additive","model","Parameters","--","--","--","--","--","alpha",":","list","of","floats","or","None","penalty","weights","Returns","--","--","--","-","penalty","matrix","block","diagonal",",","square","penalty","matrix","for","quadratic","penalization",".","The","number","of","rows","and","columns","are","equal","to","the","number","of","parameters","in","the","regression","model","``","k_params","``",".","Notes","--","--","-","statsmodels","does","not","support","backwards","compatibility","when","keywords","are","used","as","positional","arguments",".","The","order","of","keywords","might","change",".","We","might","need","to","add","a","``","params","``","keyword","if","the","need","arises","."]
code: def penalty_matrix(self, alpha=None):
      """penalty matrix for generalized additive model
  
      Parameters
      ----------
      alpha : list of floats or None
          penalty weights
  
      Returns
      -------
      penalty matrix
          block diagonal, square penalty matrix for quadratic penalization.
          The number of rows and columns are equal to the number of
          parameters in the regression model ``k_params``.
  
      Notes
      -----
      statsmodels does not support backwards compatibility when keywords are
      used as positional arguments. The order of keywords might change.
      We might need to add a ``params`` keyword if the need arises.
      """
      if alpha is None:
          alpha = self.alpha
  
      s_all = [np.zeros((self.start_idx, self.start_idx))]
      for i in range(self.k_variables):
          s_all.append(self.gp[i].penalty_matrix(alpha=alpha[i]))
  
      return block_diag(*s_all)
  
file_path: statsmodels/statsmodels/gam/gam_penalties.py
imports: import numpy
  from scipy.linalg import block_diag
  from statsmodels.base._penalties import Penalty
label_desc: Use image node_id 5 for calling the MultivariateGamPenalty obj's underlying member method code with example usage: obj.penalty_matrix(alpha) and returns: block_diag