I have two logistic regression models in R made with

`glm()`

. They both use the same variables, but were made using different subsets of a matrix. Is there an easy way to get an average model which gives the means of the coefficients and then use this with the predict() function?[ sorry if this type of question should be posted on a programming site let me know and I’ll post it there ]

Thanks

**Answer**

Do you want to take the average of the predicted probabilities, or the average of the coefficients? They will give different results, because a logistic regression involves a nonlinear transform of the linear predictor.

A function to do either would be something like this. Set `avg`

to `"prob"`

to get the former, or something else for the latter.

```
pred_comb <- function(mod1, mod2, dat, avg="prob", ...)
{
xb1 <- predict(mod1, dat, type="link", ...)
xb2 <- predict(mod2, dat, type="link", ...)
if(avg == "prob")
(plogis(xb1) + plogis(xb2))/2
else plogis((xb1 + xb2)/2)
}
```

**Attribution***Source : Link , Question Author : Andrew , Answer Author : Hong Ooi*