I am working with poisson regression with pandas
and I have a question about this specific command
.
with y,x being respectively the dependent, independent variables.
the following code takes two columns from an excel file and works properly
but now I want x and y to be two rows instead of columns, but I am a bit lost
and don't know how to proceed.
I have tried to convert those two columns into lists, since I will be able to do the same with rows,
but once I implement them into the
command, I get an error.
Thank you in advance.
and I have a question about this specific command
1 |
poisson(y,x) |
with y,x being respectively the dependent, independent variables.
the following code takes two columns from an excel file and works properly
1 2 3 4 5 6 7 8 |
import pandas as pd from statsmodels.formula.api import poisson from statsmodels.formula.api import negativebinomial data = pd.read_csv(r 'file.csv' ) varcomp = 'y ~ x' model_1 = poisson(varcomp, data).fit() print ( model_1.summary()) |
but now I want x and y to be two rows instead of columns, but I am a bit lost
and don't know how to proceed.
I have tried to convert those two columns into lists, since I will be able to do the same with rows,
but once I implement them into the
1 |
poisson |
Thank you in advance.
1 2 3 4 5 |
x_list = data[ 'x' ].tolist() y_list = data[ 'y' ].tolist() model_1 = poisson( 'y_list ~ x_list' , data).fit() print ( model_1.summary()) |
Error:File "C:\Users\lib\site-packages\patsy\highlevel.py", line 312, in dmatrices
raise PatsyError("model is missing required outcome variables")
patsy.PatsyError: model is missing required outcome variables