Skip to main content

olr: Optimal Linear Regression

Project description

The olr function systematically evaluates multiple linear regression models by exhaustively considering all possible combinations of independent variables against the dependent variable. It then provides a statistical summary based on either the highest adjusted R-squared or R-squared value obtained from these models.

In the realm of model evaluation, both R-squared and adjusted R-squared serve as prominent metrics, each offering unique insights into the quality of the model fit. R-squared, while widely used, has a tendency to increase with the inclusion of any explanatory variable, regardless of its significance. This characteristic can potentially lead to the incorporation of unnecessary variables, contributing to overfitting issues.

To address this concern, adjusted R-squared penalizes the addition of superfluous variables, offering a more refined assessment of model fit. Within the olr function framework, the primary objective is to identify the model that best aligns with the underlying data, maximizing predictive accuracy without sacrificing model complexity. Thus, while adjusted R-squared provides valuable insights into model parsimony, the inclusion of R-squared alongside it ensures a comprehensive evaluation of model performance.

By considering both metrics, the olr function facilitates the identification of the most suitable model, striking a balance between explanatory power and complexity. This approach ensures that the selected model effectively captures the inherent relationships within the data while mitigating the risk of overfitting.

dataset = pd.read_csv('C:\Users\wfky1\OneDrive\Documents\PythonFolder\PythonOlr\olr_python_package\data\crudeoildata.csv')
responseName = dataset[['OilPrices']]
predictorNames = dataset[['SPX', 'RigCount', 'API', 'FieldProduction', 'RefinerNetInput', 'OperableCapacity', 'Imports', 'StocksExcludingSPR', 'NonCommercialLong', 'NonCommercialShort', 'CommercialLong', 'CommercialShort', 'TotalLong', 'TotalShort', 'NonReportablePositionsLong', 'NonReportablePositionsShort', 'OpenInterest']]

The TRUE or FALSE in the olr function, specifies either the adjusted R-squared or the R-squared regression summary, respectfully.

When responseName and predictorNames are None (NULL), then the first column in the dataset is set as the responseName and the remaining columns are the predictorNames.

Adjusted R-squared
olr(datasetname, resvarname = None, expvarnames = None, adjr2 = "True")

R-squared
olr(datasetname, resvarname = None, expvarnames = None, adjr2 = "False")

list of summaries
olrmodels(datasetname, resvarname = None, expvarnames = None)

list of formulas
olrformulas(datasetname, resvarname = None, expvarnames = None)

list of forumlas with the dependant variables in ascending order
olrformulasorder(datasetname, resvarname = None, expvarnames = None)

the list of adjusted R-squared terms
adjr2list(datasetname, resvarname = None, expvarnames = None)

the list of R-squared terms
r2list(datasetname, resvarname = None, expvarnames = None)

An R version of this package olr is available on CRAN.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

olr-1.3.6.tar.gz (21.0 kB view details)

Uploaded Source

Built Distribution

olr-1.3.6-py3-none-any.whl (20.2 kB view details)

Uploaded Python 3

File details

Details for the file olr-1.3.6.tar.gz.

File metadata

  • Download URL: olr-1.3.6.tar.gz
  • Upload date:
  • Size: 21.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.4

File hashes

Hashes for olr-1.3.6.tar.gz
Algorithm Hash digest
SHA256 06ab3b2eb8c7199943f9be48be960ac7e3d12970a5a0ce63776b76185a309bed
MD5 a5e332cf286f735285981428addfeb6f
BLAKE2b-256 c62bc11e765e83fe07687bd55d30cd2b155a882625ead61ea1bf2b13896852d3

See more details on using hashes here.

File details

Details for the file olr-1.3.6-py3-none-any.whl.

File metadata

  • Download URL: olr-1.3.6-py3-none-any.whl
  • Upload date:
  • Size: 20.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.4

File hashes

Hashes for olr-1.3.6-py3-none-any.whl
Algorithm Hash digest
SHA256 fe54e195f6694325aea1595ed29f50e9aa65060263aa378617de39c846514493
MD5 5695ac2e961b7030231efc7ab9d75924
BLAKE2b-256 c4115c02819543525b115b301bede80d42d7c8eb0a6c5cd78da403b2d46c1756

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page