Alternatives to the Regular Matrix Inverse
In the last video, we talked briefly about generalized or pseudo-inverses.
In this exercise, you'll use the Moore-Penrose generalized inverse in the `MASS' package and find that it produces the regular inverse if the matrix you're working with is already invertible!
The command ginv()
computes the Moore-Penrose generalized inverse in R.
For more information on the Moore-Penrose inverse, see the following link.
This exercise is part of the course
Linear Algebra for Data Science in R
Exercise instructions
- The WNBA Massey Matrix
M
and vector of point differentialsf
are loaded for you. PrintM
again. - Apply the regular inverse to
M
tof
and print the result. - The
MASS
package is already loaded for you. Apply the generalized inverseginv(M)
to `f' and print the result.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Print M
print(M)
# Find the rating vector the conventional way
r <- ___%*%f
colnames(r) <- "Rating"
print(r)
# Find the rating vector using ginv
r <- ___ ___ ___
colnames(r) <- "Rating"
print(r)