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
Thank you in advance.
and I have a question about this specific command
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
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
poissoncommand, I get an error.
Thank you in advance.
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