How to get the P Value in a Variable from OLSResul

2019-04-23 15:26发布

问题:

The OLSResults of

df2 = pd.read_csv("MultipleRegression.csv")
X = df2[['Distance', 'CarrierNum', 'Day', 'DayOfBooking']]
Y = df2['Price']
X = add_constant(X)
fit = sm.OLS(Y, X).fit()
print(fit.summary())

shows the P values of each attribute to only 3 decimal places.

I need to extract the p value for each attribute like Distance, CarrierNum etc. and print it in scientific notation.

I can extract the coefficients using fit.params[0] or fit.params[1] etc.

Need to get it for all their P values.

Also what does all P values being 0 mean?

回答1:

We've to do fit.pvalues[i] to get the answer where i is the number of independent variables.

We can also look for all the attributes of an object using dir(<object>). This is another piece of helpful knowledge.