Description Usage Arguments Details Value Author(s) Examples
Identify linearly dependent rows or columns in a matrix
1 | findDepMat(X, rows = TRUE, tol = 1e-10)
|
X |
A numeric matrix |
rows |
Set |
tol |
The tolerance used to determine whether one row (or column) is a linear combination of another. |
A row (or column) is considered to be a linear combination of another if
the maximum of the absolute succesive differences of the ratios of the two
rows (columns) exceeds the tolerance, tol
. This is a fairly crude
criterion and may need improvement–but it at least will identify the
almost-exact linear dependencies.
findDepMat
identifies linearly dependent rows (columns) similar to
the way duplicated
identifies duplicates. As such, the first
instance (row or column) of a set of linearly dependent rows (or columns)
is not flagged as being dependent.
The sum of the negated output of findDepMat
should be the number of
linearly independent rows (columns). This quanity is compared to the rank
produced by qr
, and if not equal, a warning is issued. The
value of tol
is passed to qr
, but the criteria of
convergence for qr
is assuredly different from that used here
to identify the linearly dependent rows (columns).
Currently this uses nested 'for' loops within R (not C). Consequently,
findDepMat
is likely to be slow for large matrices.
A logical vector, equal in length to the number of rows (columns)
of X
, with TRUE
indicating that the row (column) is linearly
dependent on a previous row (column).
Landon Sego
1 2 3 4 5 6 7 8 9 10 11 12 | # A matrix
Y <- matrix(c(1, 3, 4,
2, 6, 8,
7, 2, 9,
4, 1, 7,
3.5, 1, 4.5), byrow = TRUE, ncol = 3)
# Note how row 2 is multiple of row 1, row 5 is a multiple of row 3
print(Y)
findDepMat(Y)
findDepMat(t(Y), rows = FALSE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.