Fits a logistic regression model