We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
With MultiIndex, stats.api.ols returns prediction of a different shape than outcome variable:
"set up the example" x1 = np.arange(0,4) x2 = 2*np.random.rand(4) y = x1+x2 + .2*np.random.randn(4) df = pd.DataFrame( np.c_[y,x1, x2] , columns = ["y", "x1","x2"], index = pd.MultiIndex.from_tuples([("chr1", 1), ("chr1",2), ("chr2",2), ("chr2", 4)])) df.index.names = ["chr", "pos"] df["y"] "set up the model" from pandas.stats.api import ols res = ols(y = df["y"] , x = df[["x1","x2"]]) unexpected_output = res.predict() unexpected_output
following post-formating recovers expected shape:
cols = unexpected_output.columns unexpected_output.reset_index() expected_output = pd.melt(unexpected_output.reset_index(), id_vars= res.y.index.names[0] \ ).dropna().set_index(res.y.index.names).loc[res.y.index.get_values()] expected_output
The text was updated successfully, but these errors were encountered:
pandas.stats.api is basically deprecated (and will be in the next version)
pandas.stats.api
use statsmodels instead
statsmodels
Sorry, something went wrong.
see #6077
No branches or pull requests
With MultiIndex, stats.api.ols returns prediction of a different shape than outcome variable:
following post-formating recovers expected shape:
The text was updated successfully, but these errors were encountered: