Description Usage Arguments Value Examples
Apply the Gram-Schmidt process to a matrix. This orthogonalizes the columns of a matrix iteratively starting with the left-most column and moving to the right after a pivoting step to ensure numerical stability.
1 | gram_schmidt(x, drop_colinear = TRUE, order_pivot = TRUE)
|
x |
a matrix |
drop_colinear |
should colinear columns be dropped? (default TRUE) |
order_pivot |
should the columns of the return be orderd by the pivot? (default TRUE) |
the return matrix is an orthogonalized version of the input.
1 2 3 4 5 6 7 8 9 10 11 12 13 | # Create a matrix from iris.
x <- model.matrix(~ Sepal.Length+Petal.Width+Petal.Length + Petal.Width - 1,
data = iris)
# Colinear columns removed and columns are orthogonal.
crossprod(gram_schmidt(x))
# Same linear subspace information as before:
summary(lm(Sepal.Width ~ Sepal.Length+Petal.Width+Petal.Length - 1,
data = iris))
summary(lm(iris$Sepal.Width ~ Sepal.Length+Petal.Width+Petal.Length - 1,
data = as.data.frame(gram_schmidt(x))))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.