How to get the prediction of test from 2D parameters of WLS regression in statsmodels

坚强是说给别人听的谎言 提交于 2019-12-02 05:51:49

np.dot(X_test, temp_g.params) should still work.

In some cases you need to check what the orientation of the matrices are, sometimes it's necessary to transpose

However predict and most other methods of the results will not work, because the model assumes that dependent variable, z, is 1D.

The question is again what you are trying to do?

If you want to independently fit columns of z, then iterate over it so each y is 1D.

for y in z.T: res = WLS(y, X).fit()

z.T allows iteration over columns.

In other cases, we usually stack the model so that y is 1D and first part of it is z[:,0] and the second part of the column is z[:,1]. The design matrix or matrix of explanatory variables has to be expanded correspondingly.

Support for multivariate dependent variables is in the making for statsmodels but will still take some time to be ready.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!