Re: [R] inverse for formula transformations on LHS

2013-05-21 Thread Paul Johnson
On Sat, May 18, 2013 at 7:05 AM, Stephen Milborrow wrote: > Paul Johnson wrote: >> >> m1 <- lm(log(y) ~ log(x), data = dat) >> >> termplot shows log(y) on the vertical. What if I want y on the vertical? >> > > plotmo in the plotmo package has an inverse.func argument, > so something like the fo

Re: [R] inverse for formula transformations on LHS

2013-05-18 Thread Stephen Milborrow
Paul Johnson wrote: m1 <- lm(log(y) ~ log(x), data = dat) termplot shows log(y) on the vertical. What if I want y on the vertical? plotmo in the plotmo package has an inverse.func argument, so something like the following might work for you? library(MASS) library(plotmo) log.brain <- log(An

Re: [R] inverse for formula transformations on LHS

2013-05-17 Thread Roger Koenker
Paul, Inverting log(y) is just the beginning of the problem, after that you need to teach predict.lm() that E(y |x) = exp(x'betahat + .5*sigmahat^2) and then further lessons are required to get it to understand how to adapt its confidence and prediction bands… and then you need to generalize

[R] inverse for formula transformations on LHS

2013-05-17 Thread Paul Johnson
This is an R formula handling question. It arose in class. We were working on the Animals data in the MASS package. In order to see a relationship, you need to log brain and body weight. It's a fun one for teaching regression, if you did not try it yet. There are outliers too! Students wanted to