# [R-sig-ME] Multilevel logistic regression guessing parameter

Kenneth Knoblauch ken.knoblauch at inserm.fr
Sat May 13 13:56:02 CEST 2017

```Hi,

I think that you can achieve this with one of the alternate links in the
psyphy package, like mafc.logit(.m = 2). Here is an example that is
contrived but I don't have time to generate toy data and you didn't
supply any. And it is set-up for 4 alternatives so it gives a lower
asymptote of 0.25 instead of 2.

I had suggested this to you offline, but you said it didn't work, but it
works fine for me in the example code below.  As I said, the actually
example doesn't make any sense but it should work for data where it
does.

library(psyphy)
library(lattice)
library(lme4)

m1 <- glm(cbind(Correct, Incorrect) ~ factor(Size) * Contr,
binomial(mafc.logit(.m = 4)), ecc2, subset = task == "DET")

contr <- seq(0.01, 0.5, len = 50)

nd2 <- nd <- expand.grid(Contr = contr,
Size = factor(unique(ecc2\$Size)))

nd\$pr <- predict(m1, newdata = nd, type = "response")
xyplot(pr ~ Contr | Size, nd, type = "l", ylim = c(0, 1.1))

m2 <- glmer(cbind(Correct, Incorrect) ~  Contr + (Contr | Size),
ecc2, binomial(mafc.logit(.m = 4)),
subset = task == "DET")

nd2\$pr <- predict(m2, newdata = nd2, re.form = NA,  type = "response")
dev.new()
xyplot(pr ~ Contr | Size, nd2, type = "l", ylim = c(0, 1.1))

HTH,

Ken

>> I  have a following situation:
>>
>> I want to predict variable B (which is dichotomous) from variable A
>> (continous) controlling for random effects on the level of a)
>> Subjects; b)
>>
>> A -> B (1)
>>
>> The problem is that when I use model to predict the values of B from
>> A,
>> values below probability of 0.5 get predicted, and in my case that
>> doesn´t
>> make sense, because, if you guess at random, the probability of
>> correct
>> answer on B would be 0.5.
>>
>> I want to know how I can constrain the model (1) in lme4 so that it
>> doesn´t
>> predict values lower than 0.5 in variable B.
>>
>> Thank you,
>>
>> Dominik!

--
Kenneth Knoblauch
Inserm U1208
Stem-cell and Brain Research Institute
18 avenue du Doyen Lépine
69500 Bron
France
tel: +33 (0)4 72 91 34 77
fax: +33 (0)4 72 91 34 61
portable: +33 (0)6 84 10 64 10
http://www.sbri.fr/members/kenneth-knoblauch.html

```