Type: | Package |
Title: | Constrained Least Squares and Generalized QR Factorization |
Version: | 1.0.0 |
Date: | 2022-02-01 |
Author: | 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 <sergio05acm@gmail.com> |
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. |
URL: | https://github.com/sergio05acm/LSE |
Imports: | MASS, pracma |
License: | GPL-3 |
Encoding: | UTF-8 |
RoxygenNote: | 7.1.1 |
NeedsCompilation: | no |
Packaged: | 2022-02-02 00:25:25 UTC; Sergio |
Repository: | CRAN |
Date/Publication: | 2022-02-02 09:00:02 UTC |
Antiquaternion
Description
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).
Usage
Antiquaternion(x)
Arguments
x |
Quaternion matrix object. |
Details
This function shows in each row a quaternion, and in each column an axis in the order a+bi+cj+dk.
Value
Numeric matrix.
Author(s)
Sergio Andrés Cabrera Miranda Statician sergio05acm@gmail.com
See Also
See Also as Quaternion
Examples
Antiquaternion(Quaternion(1,0,1,0))
Direct Elimination for LSE problem.
Description
Direct Elimination allows to give an analytic solution for equality constrained least squares problem (LSE). Requires MASS and pracma library.
Usage
Dir_Elimination(A,C,b,d)
Arguments
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. |
Details
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.
Value
Numerical vector for a LSE problem.
Author(s)
Sergio Andrés Cabrera Miranda Statician sergio05acm@gmail.com
References
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.
Examples
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)
Generalized QR Factorization
Description
This code provides a simultaneous orthogonal factorization for two matrices A and B. This code requires pracma library.
Usage
GQR(x,y)
Arguments
x |
Numerical matrix with m rows and n columns. |
y |
Numerical matrix with p rows and n columns. |
Details
Given two matrices, with the same number of rows, this algorithm provides a single factorization, such that A=QR and (Q^T)B=WS.
Value
Q |
Orthogonal matrix for A |
R |
Trapezoidal matrix for A |
W |
Orthogonal matrix for (Q^T)B |
S |
Trapezoidal matrix for (Q^T)B |
Author(s)
Sergio Andrés Cabrera Miranda Statician sergio05acm@gmail.com
References
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.
Examples
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))
LSE package
Description
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.
Author(s)
Sergio Andrés Cabrera Miranda sergio05acm@gmail.com
LSE and GQR Factorization
Description
This code provides the solution of equality constrained least squares problem through Generalized QR Factorization. Require MASS package.
Usage
LSE_GQR(A,C,b,d)
Arguments
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. |
Details
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.
Value
Numerical vector for a LSE problem.
Author(s)
Sergio Andrés Cabrera Miranda Statician sergio05acm@gmail.com
References
Anderson, E., Bai, Z., & Dongarra, J. (1992). Generalized QR factorization and its applications. Linear Algebra and its Applications, 162, 243-271.
Examples
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.
Lagrange multipliers for LSE problem.
Description
Lagrange multipliers allows to give a analytic solution for equality constrained least squares problem (LSE).
Usage
Lagrange(A,C,b,d)
Arguments
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. |
Details
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.
Value
Numerical vector for a LSE problem.
Author(s)
Sergio Andrés Cabrera Miranda Statician sergio05acm@gmail.com
References
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.).
Examples
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)
Nullspace method for LSE problem.
Description
Null Space method allows to give an analytic solution for equality constrained least squares problem (LSE). Requires pracma library.
Usage
Nullspace(A,C,b,d)
Arguments
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. |
Details
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.
Value
Numerical vector for a LSE problem.
Author(s)
Sergio Andrés Cabrera Miranda Statician sergio05acm@gmail.com
References
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.
Examples
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)
Quaternion transformation
Description
A quaternion q=a+bi+cj+dk can be transformed into a real value matrix M(4x4).
Usage
Quaternion(a,b,c,d)
Arguments
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. |
Value
Real value matrix to represent a quaternion.
Author(s)
Sergio Andrés Cabrera Miranda Statician sergio05acm@gmail.com
References
Al-Zhour, Z. (2019). Some new linear representations of matrix quaternions with some applications. Journal of King Saud University-Science, 31(1), 42-47.
Examples
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 of a matrix
Description
RQ factorization allows to develop an orthogonal transformation in a matrix through Householder reflections. Requires pracma package.
Usage
RQ(y)
Arguments
y |
Numeric matrix or vector. |
Details
RQ factorization make a orthogonal transformation at the rows of the matrix, beginning in the last one, and finishing with the first one row.
Value
Q |
Orthogonal matrix for x |
R |
Triangular matrix for x |
Author(s)
Sergio Andrés Cabrera Miranda Statician sergio05acm@gmail.com
Examples
A = matrix(runif(12,0,5),4,3,byrow=TRUE)
RQ(A)