logistic regression in r outside range [0,1] lreg02 <- glm(formula = hizortalama ~ hiz24saatonce + dummysezon1 + dummysezon2 +
  dummysezon3 + dummydilim1 + dummydilim2 + dummydilim3 + yon + yonestimated +
  nem6max + nem24max + nem6range + nem12range + nem24range + nem6var + nem24var +
  basinc6max + basinc24max + basinc6range + basinc12range +
  basinc6var + basinc24var + temp6max + temp12max +
  temp6range + temp12range + temp24range + temp6var + temp24var,
  family = binomial("logit"), data = dftrain)
pred <- predict(lreg02,dftest)

i am using glm function an i choose binomial as family, but in prediction i get results outside the range [0,1] any suggestions ?
 A: By default, predict.glm returns predicted values on the scale of the link function (linear predictor). On that scale, we fully expect values to lie beyond the 0-1 limits of the response.
You have a couple of options:


*

*if you only want the predicted values you can use predict(model, type= "response"), which will apply the inverse of the link function to the predicted values to map them back on to the scale of the response variable.

*if you want standard errors to form confidence intervals, you are better off working on the scale of the link function where you can form CI using the usual method from linear models and then manually map the predicted values and confidence interval limits back on to the response scale by applying the inverse of the link function yourself.


If you want to do 2. above, you can grab the inverse link function from the fitted model using:
linkinv <- family(model)$linkinv

This is a function and hence you can do:
pred <- predict(model, newdata)
linkinv(pred)

to do the mapping.
The family(model)$linkinv stays the same no matter what GLM you fit in R if it has implemented the family concept in the same way as glm(). the gam function in mgcv for example follows this way of working so this works the same with that package as with glm().
