How can I write a prediction formula if I can't use the glm's predict function ? If I have a model that uses the family=binomial(link="logic") I would write the model like this: model_1<-glm(IsUp ~ var1+var2,data-train ,family=binomial(link="logic"))

Then I would run the model summary, get the coefficients, including the intercept, and create the prediction formula:for example:

intercept = 0.78, var1 coeff is 0.28 and var2 coeff is 0.5

train$glm_pred1<-1/(1+exp(-(0.78+(train$var1* 0.28 + train$var2 *0.5)))) 

But how can I create a prediction function when my model is based on Gaussian like in this model:model_2<-glm(IsUp ~ var1+var2,data=train)

The summary of the model indicates that the intercept is 0.66, var1 coeff is 0.3 and var2 coeff is 0.8?

  • 2
    $\begingroup$ If I understand you correctly, the answer you seek is just 0.66 + 0.3 var1 + 0.8 var2. i.e. like your other example, but without inverting the link. It's odd that the question is phrased in terms of R syntax, because no R issues are involved here and because the model formula is usually explained at the outset before there is any question of using software. $\endgroup$
    – Nick Cox
    Nov 15, 2015 at 14:41
  • $\begingroup$ The title and content don't match. You are not asking about how to write a logistic regression model down. You already know that. $\endgroup$
    – Nick Cox
    Nov 15, 2015 at 14:43


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.