code: def ols(Y, X, axis=0):
      """Essentially, compute pinv(X)*Y"""
      ndims = len(Y.shape)
      pX = np.linalg.pinv(X)
      beta = np.rollaxis(
          np.inner(pX, np.rollaxis(Y, axis, ndims)), 0, axis + 1
      )
      nvbeta = np.inner(pX, pX)
      res = Y - np.rollaxis(
          np.inner(X, np.rollaxis(beta, axis, ndims)), 0, axis + 1
      )
      n = res.shape[axis]
      s2 = (res**2).sum(axis) / float(n - X.shape[1])
      dof = float(X.shape[0] - X.shape[1])
      return beta, nvbeta, s2, dof
  
imports: import numpy
  import scipy.stats
  from nipy.algorithms.statistics.utils import z_score
  from ..utils import mahalanobis
  from .None import kalman
label_desc: Use image node_id 1 for calling a global function with example usage: ols(Y, X, axis) and returns: beta,  nvbeta,  s2,  dof