[R-sig-ME] Fwd: Re: problem with lme4

Ben Bolker bbolker at gmail.com
Thu Jan 23 19:44:24 CET 2014


 [cc'ing back to r-sig-mixed-models; I strongly prefer to keep
conversations on-list]

  It's a little hard to say without the original data, but I'm pretty
sure your problem is with ggplot rather than lme4.  In particular, you
should probably use geom_line(aes(y=F1, col=factor(ind) )), or
geom_line(aes(y=F1,col=ind, group=ind)); ggplot interprets continuous
and categorical variables differently.


-------- Original Message --------
Subject: 	Re: problem with lme4
Date: 	Thu, 23 Jan 2014 14:25:47 +0100
From: 	Linda Heeb <linda.heeb at uzh.ch>
To: 	Ben Bolker <bbolker at gmail.com>



Thanks for your help, but I still have a problem.
Do you know how I can make a smooth line out of my „alone" data, like
the blue line that i got from the method=glm? So that the zigzag
disappear (you can see it on the attached picture)

thanks

model.s2<-glmer(number~session+treatment+amount.pup+drink+alone+lick+(1|ind),data=bold.t,
family=poisson)
bold.t$F0 <- inv.logit(getME(model.s2,"X") %*% fixef(model.s2))
bold.t$F1 <- fitted(model.s2)
p <- qplot(alone,geom="smooth", number,data=bold.t, method="glm")
p + theme_bw() + geom_line(aes(y=F0)) + geom_line(aes(y=F1, col=ind )) +
theme(legend.position = "none")




Am 22.01.2014 um 19:30 schrieb Ben Bolker <bbolker at gmail.com
<mailto:bbolker at gmail.com>>:

>  [cc'ing to r-sig-mixed-models]
>
>  You haven't given a reproducible example, but I believe that simply
> replacing   model.s2 at X with getME(model.s2,"X") in the second line
> should work.  I think you should also be able to get the same results
> (predictions with and without random values) via the 'REform' argument
> to predict() (possibly switching to 'ReForm' more recently): see
> `?predict.merMod
>
> On 14-01-22 12:59 PM, Linda Heeb wrote:
>> Dear Mr Bolker
>>
>> Since the new lme4 package this script doesn’t work any more….
>>
>> model.s2<-glmer(y~licking.duration+CN+(1|nest)+(1|session),data=bold.t,
>> family=poisson)
>> bold.t$F0 <- inv.logit(model.s2 at X %*% fixef(model.s2))*100
>> bold.t$F1 <- fitted(model.s2)*100
>> p <- qplot(licking.duration, interactions*100, facets=.~CN, data=bold.t)
>> p + theme_bw() + geom_line(aes(y=F0)) + geom_line(aes(y=F1,
>> col=mumID)) + opts(legend.position = "none")
>>
>>
>> Fehler in plogis(x) :
>>  kein Slot des Namens "X" für dieses Objekt der Klasse „glmerMod“
>>
>>
>> I hope you can tell my why and show me how I can improve it.
>>
>> Cheers, Linda Heeb
>>
>>
>



More information about the R-sig-mixed-models mailing list