pbreheny / visreg

Visualization of regression functions
http://pbreheny.github.io/visreg/
61 stars 18 forks source link

Log transformed response in lmer not located #72

Closed aande763 closed 3 years ago

aande763 commented 4 years ago

Hi had previously used visreg for multiple lmer models with a log transformed response variable. visreg would automatically detect this and create the plot. This appears to no longer be working under the "action of the toes" version of R. Here's an example

library(visreg)
## Basic####
fit <- lm(Ozone ~ Solar.R + Wind + Temp, data=airquality)
visreg(fit) 
str(airquality)

#add a categorical variable as a random effect####
library(dplyr)
airquality<- airquality %>% mutate(groups= ifelse(Month>5,"yes","no"))
airquality

library(lme4)
fit2 <- lmer(log(Ozone) ~ Solar.R + Wind + Temp +(1|groups), data=airquality)
visreg(fit2, "Wind", trans=exp, ylab="Ozone")

#lmer is not finding the data visreg
#Error in eval(inp, data, env) : object 'Ozone' not found
pbreheny commented 4 years ago

Hmm...OK, thanks for pointing this out. The issue is that the fitted model object returned by lme4 doesn't include the original airquality data frame, just the computed data frame for the model -- i.e., it doesn't include Ozone, only the log of Ozone.

I'll have to think of the best way to work around this, but thank you very much for bringing this to my attention -- definitely an important bug.

aande763 commented 4 years ago

Thanks Patrick! I was able to work off of the previous version of visreg, which works just fine for this issue.

Looking forward to the changes so I can stay up to date with the latest version.

Allie

On Wed, Oct 2, 2019 at 5:52 PM Patrick Breheny notifications@github.com wrote:

Hmm...OK, thanks for pointing this out. The issue is that the fitted model object returned by lme4 doesn't include the original airquality data frame, just the computed data frame for the model -- i.e., it doesn't include Ozone, only the log of Ozone.

I'll have to think of the best way to work around this, but thank you very much for bringing this to my attention -- definitely an important bug.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/pbreheny/visreg/issues/72?email_source=notifications&email_token=ANLFN6VWNVIGZIXS46OOXRDQMUJ2BA5CNFSM4I335IZ2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEAGJ2MI#issuecomment-537697585, or mute the thread https://github.com/notifications/unsubscribe-auth/ANLFN6VFRXHRJSJV243MEBLQMUJ2BANCNFSM4I335IZQ .

-- Alexandra Anderson MS Raptor Biology PhD Candidate Environment and Life Sciences Trent University

pbreheny commented 3 years ago

I'm not exactly sure when this was fixed, but it is fixed in the current version of visreg.