public class LMProblem
extends java.lang.Object
implements java.io.Serializable
Linear regression models the relationship between a scalar variable y and one or more variables denoted 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.
| Modifier and Type | Field and Description |
|---|---|
ImmutableMatrix |
A
the design matrix, the regressors, including the intercept if any; each column corresponds to one regressor
|
boolean |
addIntercept
true iff to add an intercept term to the linear regression |
ImmutableMatrix |
wA
the weighted design matrix, w
|
ImmutableVector |
weights
the weights to each observation
|
ImmutableVector |
wy
the weighted response vector
|
ImmutableVector |
y
the response vector; the regressands; the dependent variables
|
| Constructor and Description |
|---|
LMProblem(LMProblem that)
Copy constructor.
|
LMProblem(Vector y,
Matrix X)
Construct a linear regression problem, assuming
a constant term (the intercept)
equal weights to all observations
|
LMProblem(Vector y,
Matrix X,
boolean addIntercept)
Construct a linear regression problem, assuming equal weights to all observations.
|
LMProblem(Vector y,
Matrix X,
boolean addIntercept,
Vector weights)
Construct a linear regression problem.
|
LMProblem(Vector y,
Matrix X,
Vector weights)
Construct a linear regression problem, assuming a constant term (the intercept).
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
checkInputs()
Check whether this LMProblem instance is valid.
|
ImmutableMatrix |
invOfwAtwA()
(wA' %*% wA)-1
|
int |
nExogenousFactors()
the number of factors, excluding the intercept
|
int |
nFactors()
the number of factors, including the intercept if any
|
int |
nObs()
the number of observations
|
ImmutableMatrix |
X()
Get a copy of the factor matrix.
|
public final ImmutableVector y
a vector of length n
public final ImmutableVector wy
public final ImmutableMatrix A
a n x m matrix
public final ImmutableMatrix wA
public final boolean addIntercept
true iff to add an intercept term to the linear regressionpublic final ImmutableVector weights
public LMProblem(Vector y, Matrix X, boolean addIntercept, Vector weights)
y - the dependent variablesX - the factorsaddIntercept - true iff to add an intercept term to the linear regressionweights - the weights to each observationpublic LMProblem(Vector y, Matrix X, Vector weights)
y - the dependent variablesX - the factorsweights - the weights to each observationpublic LMProblem(Vector y, Matrix X, boolean addIntercept)
y - the dependent variablesX - the factorsaddIntercept - true iff to 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 int nExogenousFactors()
public ImmutableMatrix X()
The automatically appended intercept is not included.
public ImmutableMatrix invOfwAtwA()
protected void checkInputs()
java.lang.IllegalArgumentException - if this problem is invalid