Package dev.nm.stat.regression.linear
Class LMProblem
java.lang.Object
dev.nm.stat.regression.linear.LMProblem
- Direct Known Subclasses:
ConstrainedLASSOProblem
,GLMProblem
,LARSProblem
,LogisticProblem
,UnconstrainedLASSOProblem
This is a linear regression or a linear model (LM) problem. Linear regression models the
relationship between a scalar variable y and one or more variables denoted as X. In
linear regression, models of the unknown parameters are estimated from the data using linear
functions. Most commonly, linear regression refers to a model in which the conditional mean of
y given the value of y is an affine function of y.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs a linear regression problem, assuming a constant term (the intercept) equal weights assigned to all observationsConstructs a linear regression problem, assuming equal weights to all observations.Constructs a linear regression problem.Constructs a linear regression problem, assuming a constant term (the intercept).Copy constructor. -
Method Summary
Modifier and TypeMethodDescriptionA()
Gets the regressor matrix.protected void
Checks whether thisLMProblem
instance is valid.boolean
Checks if an intercept term is added to the linear regression.(wA' * wA)-1int
Gets the number of factors, excluding the intercept.int
nFactors()
Gets the number of factors, including the intercept if any.int
nObs()
Gets the number of observations.wA()
Gets the weighted regressor matrix.weights()
Gets the weights assigned to each observation.wy()
Gets the weighted response vector.X()
Gets the factor matrix.y()
Gets the response vector, the regressands, the dependent variables.
-
Constructor Details
-
LMProblem
Constructs a linear regression problem.- Parameters:
y
- the dependent variablesX
- the factorsintercept
-true
if to additionally add an intercept term to the linear regressionweights
- the weights assigned to each observation
-
LMProblem
Constructs a linear regression problem, assuming a constant term (the intercept).- Parameters:
y
- the dependent variablesX
- the factorsweights
- the weights assigned to each observation
-
LMProblem
Constructs a linear regression problem, assuming equal weights to all observations.- Parameters:
y
- the dependent variablesX
- the factorsintercept
-true
if to additionally add an intercept term to the linear regression
-
LMProblem
Constructs a linear regression problem, assuming- a constant term (the intercept)
- equal weights assigned to all observations
- Parameters:
y
- the dependent variablesX
- the factors
-
LMProblem
Copy constructor.- Parameters:
that
- anotherLMProblem
-
-
Method Details
-
nObs
public int nObs()Gets the number of observations.- Returns:
- the number of observations
-
nFactors
public int nFactors()Gets the number of factors, including the intercept if any.- Returns:
- the number of factors, including the intercept if any
-
y
Gets the response vector, the regressands, the dependent variables.- Returns:
- the response vector
-
wy
Gets the weighted response vector.- Returns:
- the weighted response vector
-
A
Gets the regressor matrix.- Returns:
- the regressor matrix
-
wA
Gets the weighted regressor matrix.- Returns:
- the weighted regressor matrix
-
intercept
public boolean intercept()Checks if an intercept term is added to the linear regression.- Returns:
true
if an intercept term is added
-
weights
Gets the weights assigned to each observation.- Returns:
- the weights assigned to each observation
-
nExogenousFactors
public int nExogenousFactors()Gets the number of factors, excluding the intercept.- Returns:
- the number of factors, excluding the intercept
-
X
Gets the factor matrix. Note: the automatically appended intercept is not included.- Returns:
- the factor matrix.
-
invOfwAtwA
(wA' * wA)-1- Returns:
- (wA' * wA)-1
-
checkInputs
protected void checkInputs()Checks whether thisLMProblem
instance is valid.- Throws:
IllegalArgumentException
- if this problem is invalid
-