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
Mand vector of point differentialsfare loaded for you. PrintMagain. - Apply the regular inverse to
Mtofand print the result. - The
MASSpackage 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)