Class GLMModelSelection
- java.lang.Object
-
- dev.nm.stat.regression.linear.glm.modelselection.GLMModelSelection
-
- Direct Known Subclasses:
BackwardElimination
,ForwardSelection
public abstract class GLMModelSelection extends Object
Given a set of observations {y, X}, we would like to construct a GLM to explain the data. One way to do it is to examine each factor (a column in X) one by one, and include in the model the significant ones, i.e., those with z-value bigger than some critical value.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
GLMModelSelection.ModelNotFound
Throw aModelNotFound
exception when fail to construct a model to explain the data.
-
Constructor Summary
Constructors Modifier Constructor Description protected
GLMModelSelection(GLMProblem problem)
Constructs automatically a GLM model to explain the observations.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
addFactor(int factorIndex)
Adds the indexed factor.protected void
dropFactor(int factorIndex)
Drops the indexed factor.int[]
getFlags()
Gets the factor flags.GeneralizedLinearModel
getModel()
Gets the constructed model.boolean
isSelected(int factorIndex)
Checks whether a particular indexed factor is selected in the model.GLMProblem
problem()
Returns the original GLM problem.protected Matrix
subA()
Constructs a covariates subset.
-
-
-
Constructor Detail
-
GLMModelSelection
protected GLMModelSelection(GLMProblem problem)
Constructs automatically a GLM model to explain the observations.- Parameters:
problem
- a GLM problem
-
-
Method Detail
-
problem
public GLMProblem problem()
Returns the original GLM problem.- Returns:
- the original GLM problem
-
addFactor
protected void addFactor(int factorIndex)
Adds the indexed factor.- Parameters:
factorIndex
- index
-
dropFactor
protected void dropFactor(int factorIndex)
Drops the indexed factor.- Parameters:
factorIndex
- index relative in the current selected factor set
-
getModel
public GeneralizedLinearModel getModel() throws GLMModelSelection.ModelNotFound
Gets the constructed model.- Returns:
- a GLM model
- Throws:
GLMModelSelection.ModelNotFound
- if no factor is selected
-
getFlags
public int[] getFlags()
Gets the factor flags. A positive value indicates that the factor is selected; 0 otherwise.- Returns:
- factor flags
-
isSelected
public boolean isSelected(int factorIndex)
Checks whether a particular indexed factor is selected in the model. The indices count from 1.- Parameters:
factorIndex
- the factor index- Returns:
true
if the particular index is selected in the model
-
subA
protected Matrix subA()
Constructs a covariates subset.- Returns:
- the columns corresponding to the selected variables
-
-