exponential regression

395 views
Skip to first unread message

cres...@gmail.com

unread,
Jan 21, 2014, 6:03:37 AM1/21/14
to ggp...@googlegroups.com
Hello everyone

I'm looking for a little tip on how to fit an exponential curve on data. I believe this would be very simple, but I'm a new user of ggplot, so I could not find any answer elsewhere.

My dataset is composed of biometric data on 8 fish species, and also mercury concentrations. I'd like to plot length in x axis, Hg concentration in y axis, with one exponential curve fitting the data for each species.

Currently I have this script :

regre<-qplot(data, x=length, y= Hg, color=species)
regre<-regre+stat_smooth(method="lm", formula= "y~exp(x))
regre

As a result, I have odd representation which looks like one horizontal line and then a vertical line, but not an exponential curve.

Can anyone help me ?

Thanks

Pierre

Roman Luštrik

unread,
Jan 21, 2014, 9:00:13 AM1/21/14
to cres...@gmail.com, ggplot2
Care to provide a small but reproducible example?

Cheers,
Roman


--
--
You received this message because you are subscribed to the ggplot2 mailing list.
Please provide a reproducible example: https://github.com/hadley/devtools/wiki/Reproducibility
 
To post: email ggp...@googlegroups.com
To unsubscribe: email ggplot2+u...@googlegroups.com
More options: http://groups.google.com/group/ggplot2
 
---
You received this message because you are subscribed to the Google Groups "ggplot2" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ggplot2+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



--
In God we trust, all others bring data.

Ben Bolker

unread,
Jan 21, 2014, 9:04:01 AM1/21/14
to Roman Luštrik, cres...@gmail.com, ggplot2
On 14-01-21 09:00 AM, Roman Luštrik wrote:
> Care to provide a small but reproducible example?
>
> Cheers,
> Roman
>

There's a trick for this:

geom_smooth(method="glm",family=gaussian(link="log"))

The confidence intervals are a bit weird but otherwise the fit is
appropriate.

Alternatively you can scale the y-axis logarithmically and fit a
linear regression, but that implies a multiplicative rather than an
additive error ...
> <mailto:ggp...@googlegroups.com>
> To unsubscribe: email ggplot2+u...@googlegroups.com
> <mailto:ggplot2%2Bunsu...@googlegroups.com>
> More options: http://groups.google.com/group/ggplot2
>
> ---
> You received this message because you are subscribed to the Google
> Groups "ggplot2" group.
> To unsubscribe from this group and stop receiving emails from it,
> send an email to ggplot2+u...@googlegroups.com
> <mailto:ggplot2%2Bunsu...@googlegroups.com>.
Reply all
Reply to author
Forward
0 new messages