How "type" attribute affect the logistic model in R



I am working on logistic model in R and while predicting results of my model I am getting different values when I am using type attribute in predication

without type attribute in predication

with type attribute in predication

I am not able to understand why I am getting different result??


Can you elaborate further by sharing your code and objective. Explaining what you are trying to do ?


I am trying to develop the model of logistic regression on the data set of mtcars in r
currently I have written the type=“response” but I am getting different result when I not include it


Okay here is it.

" the type of prediction required. The default is on the scale of the linear predictors; the alternative “response” is on the scale of the response variable. Thus for a default binomial model the default predictions are of log-odds (probabilities on logit scale) and type = “response” gives the predicted probabilities. The “terms” option returns a matrix giving the fitted values of each term in the model formula on the linear predictor scale."

I picked this up from

You would need to use response because the predicted probability is what we are interested in.
Now you would need to put a cut off for it , 0.5 being the default. If the predicted probability is lower than 0.5 then 0 else 1.

Which in this case makes your prediction from model as “0”.

You might want to read about logistic regression a bit, you will then be able to make sense about what I wrote. Let me know if things are still not clear.