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

**Contents**hide

#### Best 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) } `

### Similar Posts:

- Solved – How to fit a generalized logistic function
- Solved – How to fit a generalized logistic function
- Solved – Is it possible to simulate logistic regression without randomness
- Solved – Correct interpretation of confidence interval for logistic regression
- Solved – Calculation confidence interval for estimated logit in logistic regression in R