I have a (edited, silly typo) independent variable matrix, X. I would like to either take the trace of the hat matrix computed from X, or find some computational shortcut for getting that trace without actually computing the hat matrix. The issue is that X has 14826 rows.
res = glm_binom.fit()
YHatTemp = res.mu
HatMatTemp = X*res.pinv_wexog
(alternatively, replace the third line with)
HatMatTemp = X*np.linalg.inv(np.transpose(X)*X)*np.transpose(X)
The above gives me the following:
File "C:\Python27\lib\site-packages\numpy\matrixlib\defmatrix.py", line 341, in __mul__
return N.dot(self, asmatrix(other))
MemoryError
The reason I want the trace of the hat matrix in the first place is to compute the GCV criterion for the purpose of model selection, so upon getting this to work, I'll be repeating this process a fair amount.
I'd greatly appreciate some means of solving or bypassing this problem altogether. Thank you!