Title: | Constrained Least Squares and Generalized QR Factorization |
---|---|
Description: | The solution of equality constrained least squares problem (LSE) is given through four analytics methods (Generalized QR Factorization, Lagrange Multipliers, Direct Elimination and Null Space method). We expose the orthogonal decomposition called Generalized QR Factorization (GQR) and also RQ factorization. Finally some codes for the solution of LSE applied in quaternions. |
Authors: | Sergio Andrés Cabrera Miranda <https://orcid.org/0000-0002-8126-8521>, Juan Gabriel Triana Laverde <https://orcid.org/0000-0003-2991-6082> |
Maintainer: | Sergio Andrés Cabrera Miranda <[email protected]> |
License: | GPL-3 |
Version: | 1.0.0 |
Built: | 2025-02-15 04:24:01 UTC |
Source: | https://github.com/sergio05acm/lse |
A quaternion matrix obtained by the Quaternion function, can be transformed into a matrix, which contains as many quaternions as rows obtained, each column represent an imaginary axis (1,i,j,k).
Antiquaternion(x)
Antiquaternion(x)
x |
Quaternion matrix object. |
This function shows in each row a quaternion, and in each column an axis in the order a+bi+cj+dk.
Numeric matrix.
Sergio Andrés Cabrera Miranda Statician [email protected]
See Also as Quaternion
Antiquaternion(Quaternion(1,0,1,0))
Antiquaternion(Quaternion(1,0,1,0))
Direct Elimination allows to give an analytic solution for equality constrained least squares problem (LSE). Requires MASS and pracma library.
Dir_Elimination(A,C,b,d)
Dir_Elimination(A,C,b,d)
A |
Design matrix, m rows and n columns. |
C |
Constraint matrix, p rows and n columns. |
b |
Response vector for A, Ax=b, m rows and 1 column. |
d |
Response vector for C, Cx=d, p rows and 1 column. |
Direct Elimination method gives a numerical vector as the solution of a least squares problem (Ax=b), when impose some restrictions (additional information, extramuestral information or a priori information) that lead to another linear equality system (Cx=d). See significance constraint (x=0) or inclusion restriction (x+y=1), etc.
Numerical vector for a LSE problem.
Sergio Andrés Cabrera Miranda Statician [email protected]
Lawson, C. L., & Hanson, R. J. (1974). Linear least squares with linear inequality constraints. Solving least squares problems, 158-173.
Van Benthem, M. H., Keenan, M. R., & Haaland, D. M. (2002). Application of equality constraints on variables during alternating least squares procedures. Journal of Chemometrics: A Journal of the Chemometrics Society, 16(12), 613-622.
A = matrix(runif(50,-1,1),10,5) C = matrix(runif(20,-1,1),4,5) b = matrix(runif(10,-1,1),10,1) d = matrix(runif(4,-1,1),4,1) Dir_Elimination(A,C,b,d)
A = matrix(runif(50,-1,1),10,5) C = matrix(runif(20,-1,1),4,5) b = matrix(runif(10,-1,1),10,1) d = matrix(runif(4,-1,1),4,1) Dir_Elimination(A,C,b,d)
This code provides a simultaneous orthogonal factorization for two matrices A and B. This code requires pracma library.
GQR(x,y)
GQR(x,y)
x |
Numerical matrix with m rows and n columns. |
y |
Numerical matrix with p rows and n columns. |
Given two matrices, with the same number of rows, this algorithm provides a single factorization, such that A=QR and (Q^T)B=WS.
Q |
Orthogonal matrix for A |
R |
Trapezoidal matrix for A |
W |
Orthogonal matrix for (Q^T)B |
S |
Trapezoidal matrix for (Q^T)B |
Sergio Andrés Cabrera Miranda Statician [email protected]
Cabrera Miranda, S. A., & Triana Laverde, J. G. (2021). El problema de los mínimos cuadrados con restricciones de igualdad mediante la factorización QR generalizada. Selecciones Matemáticas, 8(02), 437-443. (English Article).
Anderson, E., Bai, Z., & Dongarra, J. (1992). Generalized QR factorization and its applications. Linear Algebra and its Applications, 162, 243-271.
A = matrix(c(1,1,1,1,3,1,1,-1,1,1,1,1),4,3,byrow=TRUE) C = matrix(c(1,1,1,1,1,-1),2,3,byrow=TRUE) GQR(t(A),t(C))
A = matrix(c(1,1,1,1,3,1,1,-1,1,1,1,1),4,3,byrow=TRUE) C = matrix(c(1,1,1,1,1,-1),2,3,byrow=TRUE) GQR(t(A),t(C))
Lagrange multipliers allows to give a analytic solution for equality constrained least squares problem (LSE).
Lagrange(A,C,b,d)
Lagrange(A,C,b,d)
A |
Design matrix, m rows and n columns. |
C |
Constraint matrix, p rows and n columns. |
b |
Response vector for A, Ax=b, m rows and 1 column. |
d |
Response vector for C, Cx=d, p rows and 1 column. |
The Lagrange multipliers method gives a numerical vector as the solution of a least squares problem (Ax=b) through unification the model and their restrictions in one function, the restrictions impose in the model (additional information, extramuestral information or a priori information) lead to another linear equality system (Cx=d). See significance constraint (x=0) or inclusion restriction (x+y=1), etc.
Numerical vector for a LSE problem.
Sergio Andrés Cabrera Miranda Statician [email protected]
Rao, C. R., Toutenburg, H., Shalabh, H. C., & Schomaker, M. (2008). Linear models and generalizations. Least Squares and Alternatives (3rd edition) Springer, Berlin Heidelberg New York.
Theil, H. (1971). Principles of econometrics (No. 04; HB139, T44.).
A = matrix(runif(50,-1,1),10,5) C = matrix(runif(20,-1,1),4,5) b = matrix(runif(10,-1,1),10,1) d = matrix(runif(4,-1,1),4,1) Lagrange(A,C,b,d)
A = matrix(runif(50,-1,1),10,5) C = matrix(runif(20,-1,1),4,5) b = matrix(runif(10,-1,1),10,1) d = matrix(runif(4,-1,1),4,1) Lagrange(A,C,b,d)
Solve the equality constrained least sqaures problem for real value and for quaternions, also allows to use the Generalized QR factorization for two matrices simlutaneously.
Sergio Andrés Cabrera Miranda [email protected]
This code provides the solution of equality constrained least squares problem through Generalized QR Factorization. Require MASS package.
LSE_GQR(A,C,b,d)
LSE_GQR(A,C,b,d)
A |
Design matrix, m rows and n columns. |
C |
Constraint matrix, p rows and n columns. |
b |
Response vector for A, Ax=b, m rows and 1 column. |
d |
Response vector for C, Cx=d, p rows and 1 column. |
This algorithm provides the solution of the equality constrained least squares problem through Generalized QR factorization. This algorithm requires the same number of columns for matrices A and C.
Numerical vector for a LSE problem.
Sergio Andrés Cabrera Miranda Statician [email protected]
Anderson, E., Bai, Z., & Dongarra, J. (1992). Generalized QR factorization and its applications. Linear Algebra and its Applications, 162, 243-271.
A = matrix(c(1,2,3,4,5,6),3,2,byrow = TRUE) C = matrix(c(1,1),1,2,byrow=TRUE) b = matrix(c(7,1,3),3,1,byrow=TRUE) d = matrix(c(1),1,1,byrow=TRUE) LSE_GQR(A,C,b,d) #You can verify that x+y=1 satisfies the constraint.
A = matrix(c(1,2,3,4,5,6),3,2,byrow = TRUE) C = matrix(c(1,1),1,2,byrow=TRUE) b = matrix(c(7,1,3),3,1,byrow=TRUE) d = matrix(c(1),1,1,byrow=TRUE) LSE_GQR(A,C,b,d) #You can verify that x+y=1 satisfies the constraint.
Null Space method allows to give an analytic solution for equality constrained least squares problem (LSE). Requires pracma library.
Nullspace(A,C,b,d)
Nullspace(A,C,b,d)
A |
Design matrix, m rows and n columns. |
C |
Constraint matrix, p rows and n columns. |
b |
Response vector for A, Ax=b, m rows and 1 column. |
d |
Response vector for C, Cx=d, p rows and 1 column. |
Null Space method gives a numerical vector as the solution of a least squares problem (Ax=b), using an unconstrained problem equivalent to the LSE proposed, this method an be applied when impose some restrictions (additional information, extramuestral information or a priori information) that lead to another linear equality system (Cx=d). See significance constraint (x=0) or inclusion restriction (x+y=1), etc.
Numerical vector for a LSE problem.
Sergio Andrés Cabrera Miranda Statician [email protected]
Lawson, C. L., & Hanson, R. J. (1974). Linear least squares with linear inequality constraints. Solving least squares problems, 158-173.
Van Benthem, M. H., Keenan, M. R., & Haaland, D. M. (2002). Application of equality constraints on variables during alternating least squares procedures. Journal of Chemometrics: A Journal of the Chemometrics Society, 16(12), 613-622.
A = matrix(runif(50,-1,1),10,5) C = matrix(runif(20,-1,1),4,5) b = matrix(runif(10,-1,1),10,1) d = matrix(runif(4,-1,1),4,1) Nullspace(A,C,b,d)
A = matrix(runif(50,-1,1),10,5) C = matrix(runif(20,-1,1),4,5) b = matrix(runif(10,-1,1),10,1) d = matrix(runif(4,-1,1),4,1) Nullspace(A,C,b,d)
A quaternion q=a+bi+cj+dk can be transformed into a real value matrix M(4x4).
Quaternion(a,b,c,d)
Quaternion(a,b,c,d)
a |
Real value coefficient. |
b |
Coefficient of the imaginary i-axis. |
c |
Coefficient of the imaginary j-axis. |
d |
Coefficient of the imaginary k-axis. |
Real value matrix to represent a quaternion.
Sergio Andrés Cabrera Miranda Statician [email protected]
Al-Zhour, Z. (2019). Some new linear representations of matrix quaternions with some applications. Journal of King Saud University-Science, 31(1), 42-47.
Quaternion(1,0,1,0) rbind(cbind(Quaternion(-1,0,1,0),Quaternion(0,0,0,-1)), cbind(Quaternion(0,1,0,0),Quaternion(1,0,1,0)) )
Quaternion(1,0,1,0) rbind(cbind(Quaternion(-1,0,1,0),Quaternion(0,0,0,-1)), cbind(Quaternion(0,1,0,0),Quaternion(1,0,1,0)) )
RQ factorization allows to develop an orthogonal transformation in a matrix through Householder reflections. Requires pracma package.
RQ(y)
RQ(y)
y |
Numeric matrix or vector. |
RQ factorization make a orthogonal transformation at the rows of the matrix, beginning in the last one, and finishing with the first one row.
Q |
Orthogonal matrix for x |
R |
Triangular matrix for x |
Sergio Andrés Cabrera Miranda Statician [email protected]
A = matrix(runif(12,0,5),4,3,byrow=TRUE) RQ(A)
A = matrix(runif(12,0,5),4,3,byrow=TRUE) RQ(A)