# Can I use lmBF() for logistic regression?

**42**

Hi,

I need to perform a logistic regression with two categorical predictor variables (two levels each). I am trying to figure out whether I can use the `lmBF()`

function from the `BayesFactor`

package to do this. I could not find any information on this in the documentation. Bringing up `?regressionBF`

in R gives me this information:

The vector of observations y is assumed to be distributed as: y ~ Normal(α 1 + Xβ, σ^2 I).

This suggests to me that binomial `y`

s are not appropriate.

I did go ahead and tried it anyways. And `lmBF`

will happily fit the models and give me results. I just don't know whether they actually *mean* anything. Specifically, I compared the output of

`glmer(y ~ f1 + f2 + f1:f2+ (1|subj) + (1|item), data=data, family = binomial)`

with the output of

`lmBF(y ~ f1 + f2 + f1:f2, whichRandom = c("subj", "item"), data=data)`

and they corresponded quite closely.

I constructed a simpler example (without the random effects etc.) to test whether the outcomes converge. And they seem to:

```
set.seed(3)
data <- data.frame(y = rbinom(100, 1, .5),
f1 = as.factor(sample(rep(LETTERS[1:2], 50))),
f2 = as.factor(sample(rep(letters[1:2], 50))))
# Traditional log. regression:
m.trad <- glm(y ~ .,family=binomial(link='logit'),data=data)
# Using lmBF:
m.bf <- lmBF(y ~ ., data=data)
chains <- posterior(m.bf, iterations = 10000)
coeff.est <- colMeans(chains)
# Comparing param. estimates for observation in f1 = B and f2 = b
# Trad. glm:
invlogit <- function(X) { 1 / (1+exp(-X)) }
invlogit(sum(coef(m.trad)))
# lmBF:
coeff.est['mu'] + coeff.est['f1-B'] + coeff.est['f2-b']
```

Can someone put my mind at ease and confirm that I am doing this right and that `lmBF`

does return meaningful parameter estimates (etc.) for binomially distributed `y`

s?

Thanks a lot!

- Florian

## Comments

42EJ Wagenmakers was visiting my faculty today so I had a chance to ask him in person. Logistic regression is not yet possible but they'll start working on it soon.

That means, what I outlined above should not be used.

1https://sincrenete.blogspot.am/2017/07/logistic-regression-explained-and.html I also put here an example of Logistic regression done by R. In a case of any question I am ready. Thanks ))