public class QRDSolver extends Object implements Serializable
m x n matrix A with m >= n, the QR decomposition
is an m x n orthogonal matrix Q and an n x n upper
triangular matrix R so that A = Q*R.| Constructor and Description |
|---|
QRDSolver(Matrix q,
Matrix r)
Constructs a new QR decomposition solver object.
|
| Modifier and Type | Method and Description |
|---|---|
Matrix |
calculateBetaVariance(int p)
Calculates the variance-covariance matrix of the regression parameters.
|
Matrix |
calculateHat()
Compute the "hat" matrix.
|
boolean |
equals(Object o) |
int |
hashCode() |
Matrix |
solve(Matrix mtx)
Least squares solution of
A*X = B; returns X. |
Vector |
solve(Vector vec)
Least squares solution of
A*X = B; returns X. |
String |
toString()
Returns a rough string rendition of a QRD solver.
|
public Matrix solve(Matrix mtx)
A*X = B; returns X.mtx - A matrix with as many rows as A and any number of cols.X< that minimizes the two norm of Q*R*X - B.IllegalArgumentException - if B.rows() != A.rows().public Vector solve(Vector vec)
A*X = B; returns X.vec - A vector with as many rows as A.X< that minimizes the two norm of Q*R*X - B.IllegalArgumentException - if B.rows() != A.rows().public Matrix calculateHat()
Compute the "hat" matrix.
The hat matrix is defined in terms of the design matrix X by X(XTX)-1XT
The implementation here uses the QR decomposition to compute the hat matrix as Q IpQT where Ip is the p-dimensional identity matrix augmented by 0's. This computational formula is from "The Hat Matrix in Regression and ANOVA", David C. Hoaglin and Roy E. Welsch, The American Statistician, Vol. 32, No. 1 (Feb., 1978), pp. 17-22.
Data for the model must have been successfully loaded using one of
the newSampleData methods before invoking this method; otherwise
a NullPointerException will be thrown.
NullPointerException - unless method newSampleData has been called beforehand.public Matrix calculateBetaVariance(int p)
Calculates the variance-covariance matrix of the regression parameters.
Var(b) = (XTX)-1
Uses QR decomposition to reduce (XTX)-1 to (RTR)-1, with only the top p rows of R included, where p = the length of the beta vector.
Data for the model must have been successfully loaded using one of
the newSampleData methods before invoking this method; otherwise
a NullPointerException will be thrown.
p - Size of the beta variance-covariance matrixSingularMatrixException - if the design matrix is singularNullPointerException - if the data for the model have not been loaded
Follow @ApacheIgnite
Ignite Fabric : ver. 2.6.0 Release Date : July 10 2018