Learn R Programming

olr (version 1.0)

olr: olr: Optimal Linear Regression

Description

The main olr() runs all of the possible linear regression equation combinations, which are all of the combinations of dependent variables respect to the independent variable. In essence, the olr() returns the best fit linear regression model. The user can prompt the olr() to either return the best fit statistical summary of either the greatest adjusted R-squared or R-squared term.

Usage

olr(datasetname, resvarname, expvarnames, adjr2 = TRUE)

olrmodels(datasetname, resvarname, expvarnames)

olrformulas(datasetname, resvarname, expvarnames)

olrformulaorder(datasetname, resvarname, expvarnames)

adjr2list(datasetname, resvarname, expvarnames)

r2list(datasetname, resvarname, expvarnames)

Arguments

datasetname

is defined by the user and points to the name of the dataset that is being used.

resvarname

the response variable name defined as a string. For example. It represents a header in the data table.

expvarnames

is a variable that you must define as a list before your function. Place desired headers from the data table in here as a list.

adjr2

adjr2 = TRUE means you want to return the regression summary for the maximum adjusted R-squared term. adjr2 = FALSE means you want to return the regression summary for the maximum R-squared term.

Value

The regression summary for the adjusted R-squared or the R-squared, specified with TRUE or FALSE in the olr().

Details

Complimentary functions below follow the format: function(datasetname, resvarname, expvarnames) olrmodels: returns the list of models accompanied by the coefficients. After typing in olrmodels(datasetname, resvarname, expvarnames) type the desired summary number to the right of the comma in the brackets: [,x] where x equals the desired summary number. For example, olrmodels(datasetname, resvarname, expvarnames)[,8] olrformulas: returns the list of olr() formulas olrformulasorder: returns the formulas with the predictors (dependent variables) in ascending order adjr2list: list of the adjusted R-squared terms r2list: list of the R-squared terms

A 'Python' version is available at <https://pypi.org/project/olr>.

Examples

Run this code
# NOT RUN {
file <- system.file("extdata", "oildata.csv", package = "olr", mustWork = TRUE)
oildata <- read.csv(file, header = TRUE)

datasetname <- oildata
resvarname <- 'OilPrices'
expvarnames <- c('SP500', 'RigCount', 'API', 'Field_Production', 'RefinerNetInput', 'Imports')

olr(datasetname, resvarname, expvarnames, adjr2 = TRUE)

# }

Run the code above in your browser using DataLab