docstr: Ensure that `Factor.linear_regression` is consistent with the built-in
  factor `RollingLinearRegressionOfReturns`.
docstr_tok: ["Ensure","that","`","Factor.linear_regression","`","is","consistent","with","the","built-in","factor","`","RollingLinearRegressionOfReturns","`","."]
code: def _test_factor_regression_method(
      self, returns_length, regression_length
  ):
      """
      Ensure that `Factor.linear_regression` is consistent with the built-in
      factor `RollingLinearRegressionOfReturns`.
      """
      my_asset = self.my_asset
      start_date = self.pipeline_start_date
      end_date = self.pipeline_end_date
      run_pipeline = self.run_pipeline
  
      returns = Returns(window_length=returns_length, inputs=[self.col])
      returns_slice = returns[my_asset]
  
      regression = returns.linear_regression(
          target=returns_slice,
          regression_length=regression_length,
      )
      expected_regression = RollingLinearRegressionOfReturns(
          target=my_asset,
          returns_length=returns_length,
          regression_length=regression_length,
      )
  
      # This built-in constructs its own Returns factor to use as an input,
      # so the only way to set our own input is to do so after the fact. This
      # should not be done in practice. It is necessary here because we want
      # Returns to use our random data as an input, but by default it is
      # using USEquityPricing.close.
      expected_regression.inputs = [returns, returns_slice]
  
      columns = {
          "regression": regression,
          "expected_regression": expected_regression,
      }
  
      results = run_pipeline(
          Pipeline(columns=columns), start_date, end_date
      )
      regression_results = results["regression"].unstack()
      expected_regression_results = results[
          "expected_regression"
      ].unstack()
  
      assert_frame_equal(
          regression_results, expected_regression_results
      )
  
imports: from numpy import arange, full, full_like, nan, where
  from pandas import DataFrame, date_range, Int64Index, Timestamp
  from pandas.util.testing import assert_frame_equal
  from scipy.stats import linregress, pearsonr, spearmanr
  from catalyst.assets import Equity
  from catalyst.errors import IncompatibleTerms, NonExistentAssetInTimeFrame
  from catalyst.pipeline import CustomFactor, Pipeline
  from catalyst.pipeline.data import USEquityPricing
  from catalyst.pipeline.data.testing import TestingDataSet
  from catalyst.pipeline.engine import SimplePipelineEngine
  from catalyst.pipeline.factors.equity import Returns, RollingLinearRegressionOfReturns, RollingPearsonOfReturns, RollingSpearmanOfReturns
  from catalyst.pipeline.loaders.frame import DataFrameLoader
  from catalyst.pipeline.sentinels import NotSpecified
  from catalyst.testing import AssetID, AssetIDPlusDay, check_arrays, make_alternating_boolean_array, make_cascading_boolean_array, parameter_space
  from catalyst.testing.fixtures import WithSeededRandomPipelineEngine, WithTradingEnvironment, CatalystTestCase
  from catalyst.utils.numpy_utils import bool_dtype, datetime64ns_dtype, float64_dtype
label_desc: Use image node_id 4 for calling the StatisticalMethodsTestCase obj's underlying member method code with example usage: obj._test_factor_regression_method(returns_length, regression_length) without return types