Re: [R] back-transform predictors for x-axis in plot -- mgcv package

From: hadley wickham <h.wickham_at_gmail.com>
Date: Fri, 15 Jun 2007 12:33:03 +0200

Hi Suzan,

You can do sort of backtransformation inside of ggplot2 (http://had.co.nz/ggplot2).

library(ggplot2)

# Create the base scatterplot with y and x axes transformed by logging, # and then back transformed by exponentiating (base <- qplot(carat, price, data=diamonds) + scale_x_log10() + scale_y_log10() + coord_trans(y="pow10", x="pow10"))

base + geom_smooth(method="lm")

library(mgcv)
base + geom_smooth(method="gam", formula = y ~ s(x, bs="cr")) base + geom_smooth(method="gam", formula = y ~ s(x, bs="cr"), fill="grey50")

# cf.

qplot(carat, price, data=diamonds) + geom_smooth(method="lm") qplot(carat, price, data=diamonds) + geom_smooth(method="gam", formula = y ~ s(x, bs="cr"), fill="grey50")

Regards,

Hadley

On 6/14/07, Suzan Pool <Suzan.Pool_at_noaa.gov> wrote:
> My question is related to plot( ) in the mgcv package. Before modelling
> the data, a few predictors were transformed to normalize them.
> Therefore, the x-axes in the plots show transformed predictor values.
> How do I back-transform the predictors so that the plots are easier to
> interpret?
>
> Thanks in advance,
> Suzan
>
> --
> Suzan Pool
> Oregon State University
> Cooperative Institute for Marine Resources Studies
> c/o NOAA Fisheries
> 520 Heceta Place
> P.O. Box 155
> Hammond, OR 97121
>
> Suzan.Pool_at_oregonstate.edu
> Suzan.Pool_at_noaa.gov
> Phone: 503-861-1818 x36 TTY
> Voice to TTY: 711
> Fax: 503-861-2589
>
> ______________________________________________
> R-help_at_stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



R-help_at_stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Fri 15 Jun 2007 - 10:49:41 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 15 Jun 2007 - 11:31:47 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.