Skip to content
Prev 14346 / 20628 Next

lme4 categorical outcome probability values at each time point

Dear Igor,
Am new to the list, so defer by all means to more experienced opinions.
My suggestion would be to use the "lsmeans" package and the inverse logit
transformation
(to get back to the scale of probabilities from the hard-to-interpret
logits)

If you have time as a factor this will be no problem.
So before you run the model, specify
vse$Time<-as.factor(vse$Time)
#then use lsmeans by R Lenth
#see
https://cran.r-project.org/web/packages/lsmeans/vignettes/using-lsmeans.pdf
#example
# lsmeans(oranges.lm1, "day", at = list(price1 = 50, price2 = c(40,60), day
= c("2","3","4")) )
Newdf<- summary(lsmeans(workshop, ~Time*Condition))
#or if Time is numeric:
Newdf<- summary(lsmeans(workshop, ~Time*Condition, at=list(Time=c(1, 2, 3))

#if you need to graph standard errors, create a new column with raw std
errors first,
#then transform the mean +/- SE
Newdf$sehi<-Newdf$lsmean+ Newdf$SE
Newdf$selo<-Newdf$lsmeans - Newdf$SE
#now apply inverse logit
library(boot)
Newdf$meanprop<-inv.logit (Newdf$lsmean)
Newdf$prophi<-inv.logit(Newdf$sehi)
Newdf$proplo<-inv.logit(Newdf$selo)

You should be able to plot the resulting variables using ggplot2 or your
package of choice.
You could also use inv.logit on the 95% confidence limits, though the error
bars tend to get pretty enormous with these reverse transformations and may
not seem to reflect any significant differences in your model.
Hope this helps!
Evan


On Fri, Mar 25, 2016 at 12:20 AM, Igor Yakovenko <iyakoven at ucalgary.ca>
wrote: