SuanShu, a Java numerical and statistical library

com.numericalmethod.suanshu.stats.regression.linear
Class LmProblem

java.lang.Object
  extended by com.numericalmethod.suanshu.stats.regression.linear.LmProblem
Direct Known Subclasses:
GlmProblem, LogisticProblem

public class LmProblem
extends java.lang.Object

This class represents 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 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:
Wikipedia: Linear regression

Field Summary
 ImmutableMatrix A
          the design matrix, the regressors, including the intercept if any; each column corresponds to one regressor a n x m matrix
 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 a vector of length n
 
Constructor Summary
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).
 
Method Summary
protected  void checkInputs()
          Check whether this LmProblem instance is valid.
 Matrix 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
 Matrix X()
          Get a copy of the factor matrix.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

y

public final ImmutableVector y
the response vector; the regressands; the dependent variables

a vector of length n


wy

public final ImmutableVector wy
the weighted response vector


A

public final ImmutableMatrix A
the design matrix, the regressors, including the intercept if any; each column corresponds to one regressor

a n x m matrix


wA

public final ImmutableMatrix wA
the weighted design matrix, w


addIntercept

public final boolean addIntercept
true iff to add an intercept term to the linear regression


weights

public final ImmutableVector weights
the weights to each observation

Constructor Detail

LmProblem

public LmProblem(Vector y,
                 Matrix X,
                 boolean addIntercept,
                 Vector weights)
Construct a linear regression problem.

Parameters:
y - the dependent variables
X - the factors
addIntercept - true iff to add an intercept term to the linear regression
weights - the weights to each observation

LmProblem

public LmProblem(Vector y,
                 Matrix X,
                 Vector weights)
Construct a linear regression problem, assuming a constant term (the intercept).

Parameters:
y - the dependent variables
X - the factors
weights - the weights to each observation

LmProblem

public LmProblem(Vector y,
                 Matrix X,
                 boolean addIntercept)
Construct a linear regression problem, assuming equal weights to all observations.

Parameters:
y - the dependent variables
X - the factors
addIntercept - true iff to add an intercept term to the linear regression

LmProblem

public LmProblem(Vector y,
                 Matrix X)
Construct a linear regression problem, assuming

Parameters:
y - the dependent variables
X - the factors

LmProblem

public LmProblem(LmProblem that)
Copy constructor.

Parameters:
that - another LmProblem
Method Detail

nObs

public int nObs()
the number of observations

Returns:
the number of observations

nFactors

public int nFactors()
the number of factors, including the intercept if any

Returns:
the number of factors, including the intercept if any

nExogenousFactors

public int nExogenousFactors()
the number of factors, excluding the intercept

Returns:
the number of factors, excluding the intercept

X

public Matrix X()
Get a copy of the factor matrix.

The automatically appended intercept is not included.

Returns:
a copy of the factor matrix.

invOfwAtwA

public Matrix invOfwAtwA()
(wA' %*% wA)-1

Returns:
(wA' %*% wA)-1

checkInputs

protected void checkInputs()
Check whether this LmProblem instance is valid.

Throws:
java.lang.IllegalArgumentException - if this problem is invalid

SuanShu, a Java numerical and statistical library

Copyright © 2011 Numerical Method Inc. Ltd. All Rights Reserved.