BestModelSubset.jl

A julia package to implement model selection algorithms on basic regression models.

Build Status Coverage License

Installation

You can install BestModelSubset.jl using Julia's package manager

julia> using Pkg; Pkg.add("BestModelSubset.jl")

Example

Instantiate a ModelSelection object

# To execute best subset selection with primary parameter to be R-squared score  
# and secondary parameter to be aic.
julia> obj = ModelSelection("bess", "r2", "aic")
ModelSelection(BestModelSubset.best_subset, nothing, StatsAPI.r2, nothing, StatsAPI.aic,
               nothing, StatsAPI.r2, StatsAPI.aic)

Fit the ModelSelectionobject to the data

# The fit! function updates the fields of the `ModelSelection` object.
julia> Random.seed!(123); df = hcat(rand(Float64, (50, 21))); # 50*21 Matrix

julia> fit!(obj, df)
1-element Vector{Vector{Int64}}:
 [5, 6, 16, 17, 18, 20]

Access various statistics like r2, adjr2, aic and bic for the selected model

julia> obj.r2
0.8161760683631274

julia> obj.aic
21.189713760250477