public class LMProblem extends Object
Each row of X is one observation; each column is one predictor.
The length of y must equal the number of rows. When
intercept == true, a column of ones is appended as the last
column; do not also put that constant column into X. Coefficients
therefore follow predictor-column order, with the intercept last.
Weights, when supplied, have one nonnegative entry per observation;
null selects equal weights. Avoid rank-deficient designs. For
meaningful residual-variance estimates, use more observations than fitted
coefficients. Inputs are exposed through read-only wrappers, not necessarily
copied: do not mutate their underlying data after constructing the problem.
OLSRegression,
Wikipedia: Linear regression| Constructor and Description |
|---|
LMProblem(LMProblem that)
Copy constructor.
|
LMProblem(Vector y,
Matrix X)
Constructs a linear regression problem, assuming
a constant term (the intercept)
equal weights assigned to all observations
|
LMProblem(Vector y,
Matrix X,
boolean intercept)
Constructs a linear regression problem, assuming equal weights to all observations.
|
LMProblem(Vector y,
Matrix X,
boolean intercept,
Vector weights)
Constructs a linear regression problem.
|
LMProblem(Vector y,
Matrix X,
Vector weights)
Constructs a linear regression problem, assuming a constant term (the intercept).
|
| Modifier and Type | Method and Description |
|---|---|
ImmutableMatrix |
A()
Gets the regressor matrix.
|
protected void |
checkInputs()
Checks whether this
LMProblem instance is valid. |
boolean |
intercept()
Checks if an intercept term is added to the linear regression.
|
ImmutableMatrix |
invOfwAtwA()
(wA' * wA)-1
|
int |
nExogenousFactors()
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.
|
ImmutableMatrix |
wA()
Gets the weighted regressor matrix.
|
ImmutableVector |
weights()
Gets the weights assigned to each observation.
|
ImmutableVector |
wy()
Gets the weighted response vector.
|
ImmutableMatrix |
X()
Gets the factor matrix.
|
ImmutableVector |
y()
Gets the response vector, the regressands, the dependent variables.
|
public LMProblem(Vector y, Matrix X, boolean intercept, Vector weights)
y - the dependent variablesX - the factorsintercept - true if to additionally add an intercept term to the linear
regressionweights - the weights assigned to each observationpublic LMProblem(Vector y, Matrix X, Vector weights)
y - the dependent variablesX - the factorsweights - the weights assigned to each observationpublic LMProblem(Vector y, Matrix X, boolean intercept)
y - the dependent variablesX - the factorsintercept - true if to additionally add an intercept term to the linear
regressionpublic LMProblem(Vector y, Matrix X)
y - the dependent variablesX - the factorspublic LMProblem(LMProblem that)
that - another LMProblempublic int nObs()
public int nFactors()
public ImmutableVector y()
public ImmutableVector wy()
public ImmutableMatrix A()
public ImmutableMatrix wA()
public boolean intercept()
true if an intercept term is addedpublic ImmutableVector weights()
public int nExogenousFactors()
public ImmutableMatrix X()
public ImmutableMatrix invOfwAtwA()
protected void checkInputs()
LMProblem instance is valid.IllegalArgumentException - if this problem is invalidCopyright © 2010-2026 NM Group. All Rights Reserved.