1

I have a GLS with a logarithmic transformed dependent variable. Using visreg() for visualization gives an error code:

 library(visreg); library(nlme)
 fit1 <- gls(log(Ozone) ~ Wind , data=na.omit(airquality))
 visreg(fit1,"Wind",trans=exp,ylab="Ozone")

Interestingly the very same works just fine with a LM:

library(visreg); library(nlme)
fit2 <- lm(log(Ozone) ~ Wind , data=na.omit(airquality))
visreg(fit2,"Wind",trans=exp,ylab="Ozone")
Stefan
  • 13
  • 4
  • `try(visreg(fit1,"Wind",trans=exp,ylab="Ozone"))` works neither – Stefan Oct 03 '15 at 07:27
  • The issue is that visreg doesn't have a method for your model's class, "glm"...glm has a predict method but not a model.frame one. Try defining that method for glm objects – Chris Oct 03 '15 at 07:27
  • Really? Because `visreg(fit1,"Wind",trans=I,ylab="Ozone")` works fine. Just back transforming does not work. – Stefan Oct 03 '15 at 07:28
  • fit2 is an object of class lm...it has the predict and model.frame methods neccisary for visreg – Chris Oct 03 '15 at 07:31
  • ...sry, meant to say "gls" not "glm" – Chris Oct 03 '15 at 07:32
  • Sorry, my bad. The code im my last comment was wrong. I have just edited it. Try `visreg(fit1,"Wind",trans=I,ylab="Ozone")`. It works with a GLS. I can't use a GLM for other reasons. – Stefan Oct 03 '15 at 07:34
  • The error is about the lack of finite `ylim` values. A quick work around is to put in your own `ylim` - e.g., `ylim = c(0, 120)`. – aosmith Oct 05 '15 at 16:09

0 Answers0