The Moore-Penrose g-inverse is unstable and does not recover the true sparsity pattern.
library(MASS)
xtx = t(x)%*%x
y1 <- t(x) %*% y
xtx <- as.matrix(xtx)
betahat <- ginv(xtx) %*% y1
t(betahat)
## [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8]
## [1,] 1.608659 2.055189 2.008242 1.483109 2.07467 -0.3614589 0.7423397 0.6313197
## [,9] [,10] [,11] [,12] [,13] [,14] [,15]
## [1,] -0.5369256 -0.6536013 -0.4607142 0.3530865 0.2274444 0.2260297 -0.4165202
## [,16] [,17] [,18] [,19] [,20] [,21] [,22]
## [1,] -0.1228928 -0.9067978 0.1028133 -0.6649684 0.1944959 0.1970185 0.006585257
## [,23] [,24] [,25] [,26] [,27] [,28] [,29]
## [1,] 0.5016977 -0.1721992 0.1778885 0.3185551 -0.3519374 -0.6238105 0.1718405
## [,30] [,31] [,32] [,33] [,34] [,35] [,36]
## [1,] -0.05045217 0.5132045 0.4552682 -0.2886573 0.2954796 -0.5662579 -0.1817709
## [,37] [,38] [,39] [,40] [,41] [,42] [,43]
## [1,] -0.09759172 0.1950746 -0.5980697 0.4918535 0.02023623 -0.1580072 0.2578998
## [,44] [,45] [,46] [,47] [,48] [,49] [,50]
## [1,] 0.4574696 -1.058922 0.126543 -0.2223721 -0.01834812 0.438076 -0.7194657
## [,51] [,52] [,53] [,54] [,55] [,56] [,57]
## [1,] 0.3673409 0.6158204 -0.5537395 0.3276649 0.006263418 0.02665544 -0.2796517
## [,58] [,59] [,60]
## [1,] -0.7236042 -0.1991801 -0.1380917