Why is the back-transformation of the predicted values so different from the observed when the observed are log-transformed?
Sample data:
trt=c("a","a","a","a","a","a","a","b","b","b","b","b","b","b","c","c","c","c","c","c","c")
resp=c(1,2,3,1,2,3,1,10,20,30,10,20,30,10,100,200,300,100,200,300,100)
resp=(log(resp))
observed=cbind(by(resp,trt,mean))
colnames(observed)="obs"
data1=data.frame(trt,resp)
Models: log.transformed and untransformed
model.nolog=lm(resp~trt,data=data1)
model.log=lm(log(resp)~trt,data=data1)
Predicted means
library(predictmeans)
estimated.nolog=predictmeans(model.nolog,"trt",adj="tukey")[[1]]
estimated.log=exp(predictmeans(model.log,"trt",adj="tukey")[[1]])
compare=cbind(observed,"est.nolog"=estimated.nolog,"est.log"=estimated.log)
options(digits=2)
> compare
obs est.nolog est.log
a 0.51 0.51 1.7
b 2.81 2.81 16.7
c 5.12 5.12 166.9
resp=(log(resp))
before you make the data frame, but the results of your fitted models don't jibe with this, and seem to be reversed from what they should be. I suggest typing all the statements again and recomputing, because what you're showing cannot have been produced by the statements shown-- at least in the order shown. $\endgroup$ – Russ Lenth Dec 12 '14 at 1:59i=c(1,8,15); data.frame(orig=fitted(lm(resp~trt))[i], explog=exp(fitted(lm(log(resp)~trt))[i]))
then you should make that explicit in your question. You need to fix your code and ask a clear question. $\endgroup$ – Glen_b Dec 12 '14 at 3:06