Python Error: Len() Of Unsized Object While Using Statsmodels With One Row Of Data
I'm able to use the statsmodel's WLS (weighted least squares regression) fine when I have lots of datapoints. However, I seem to be having a problem with the numpy arrays when I tr
Solution 1:
There's no such thing as WLS for one observation. The single weight would simply become 1 when they're normalized to sum to 1. If you want to do this, though I supsect you don't, just use OLS. The solution will be a consequence of the SVD not any actual relationship in the data though.
OLS solution using pinv/svd
np.dot(np.linalg.pinv(X[[0]]), y[0])
Though you could just make up any answer that works and get the same result. I'm not sure offhand what exactly the properties of the SVD solution are vs. the other non-unique solutions.
[~/]
[26]: beta = [-.5, .25, 1/3.]
[~/]
[27]: np.dot(beta, X[0])
[27]: 1.0
Post a Comment for "Python Error: Len() Of Unsized Object While Using Statsmodels With One Row Of Data"