Multiple Linear Regression

If the p value of a specific independent variable is less than 0.05 then it is considered to be a statistically significant variable. How to extract these variables from the dataset using Python ?


  1. The statsmodels.regression.linear_model.OLSResults.pvalues should give you the pvalues of the respective variables. pvalues[0] should give you the pvalues of the 1st variable. You can filter out the names of the variables wherever pvalues[i]<0.05 and then use the list of variable names to filter out data as per need.

    1. 'OLS' object has no attribute 'pvalues'
      This is the error I am getting when I use this method.

Leave a comment