Discussion:
[R] EXAMPLE OF HOW TO USE R FOR EXPONENTIAL DISTRIBUTION & EXPONENTIAL REGRESSION
Tolulope Adeagbo
2018-11-27 09:53:03 UTC
Permalink
Good day,
Please i nee useful materials to understand how to use R for exponential
regression.
Many thanks.

[[alternative HTML version deleted]]

______________________________________________
R-***@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.
Sarah Goslee
2018-11-27 11:28:03 UTC
Permalink
Hi,

Using rseek.org to search for exponential regression turns up lots of
information, as does using Google.

Which tutorials have you worked thru already, and what else are you looking
for?

Sarah
Post by Tolulope Adeagbo
Good day,
Please i nee useful materials to understand how to use R for exponential
regression.
Many thanks.
[[alternative HTML version deleted]]
______________________________________________
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.
--
Sarah Goslee (she/her)
http://www.sarahgoslee.com

[[alternative HTML version deleted]]

______________________________________________
R-***@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.
Sarah Goslee
2018-11-27 17:10:38 UTC
Permalink
Hi,

Please also include R-help in your replies - I can't provide
one-on-one tutorials.

Without knowing where you got your sample code, it's hard to help. But
what are you trying to do?

It doesn't have to be that complicated:

x <- 1:10
y <- c(0.00, 0.00,0.0033,0.0009,0.0025,0.0653,0.1142,0.2872,0,1 )
plot(x, y, pch=20)

# basic straight line of fit
fit <- glm(y~x)

abline(fit, col="blue", lwd=2)
exp.lm <- lm(y ~ exp(x))
lines(1:10, predict(exp.lm, newdata=data.frame(x=1:10)))


On Tue, Nov 27, 2018 at 9:34 AM Tolulope Adeagbo
Hello,
So I found this example online but there seems to be an issue with the "Start" points. the result is giving somewhat a straight line
# get underlying plot
x <- 1:10
y <- c(0.00, 0.00,0.0033,0.0009,0.0025,0.0653,0.1142,0.2872,0,1 )
plot(x, y, pch=20)
# basic straight line of fit
fit <- glm(y~x)
co <- coef(fit)
abline(fit, col="blue", lwd=2)
# exponential
f <- function(x,a,b) {a * exp(b * x)}
fit <- nls(y ~ f(x,a,b), start = c(a=1 , b=c(0,1)))
co <- coef(fit)
curve(f(x, a=co[1], b=co[2]), add = TRUE, col="green", lwd=2)
# exponential
f <- function(x,a,b) {a * exp(b * x)}
fit <- nls(y ~ f(x,a,b), start = c(a=1, b=1))
co <- coef(fit)
curve(f(x, a=co[1], b=co[2]), add = TRUE, col="green", lwd=2)
# logarithmic
f <- function(x,a,b) {a * log(x) + b}
fit <- nls(y ~ f(x,a,b), start = c(a=1, b=1))
co <- coef(fit)
curve(f(x, a=co[1], b=co[2]), add = TRUE, col="orange", lwd=2)
# polynomial
f <- function(x,a,b,d) {(a*x^2) + (b*x) + d}
fit <- nls(y ~ f(x,a,b,d), start = c(a=1, b=1, d=1))
co <- coef(fit)
curve(f(x, a=co[1], b=co[2], d=co[3]), add = TRUE, col="pink", lwd=2)
Hi,
Using rseek.org to search for exponential regression turns up lots of information, as does using Google.
Which tutorials have you worked thru already, and what else are you looking for?
Sarah
Post by Tolulope Adeagbo
Good day,
Please i nee useful materials to understand how to use R for exponential
regression.
Many thanks.
--
Sarah Goslee (she/her)
http://www.numberwright.com

______________________________________________
R-***@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.
Bert Gunter
2018-11-27 17:38:17 UTC
Permalink
... but do note that a nonlinear fit to the raw data will give a(somewhat)
different result than a linear fit to the transformed data. In the former,
the errors are additive and in the latter they are multiplicative. Etc.

Cheers,
Bert


Bert Gunter

"The trouble with having an open mind is that people keep coming along and
sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
Post by Sarah Goslee
Hi,
Please also include R-help in your replies - I can't provide
one-on-one tutorials.
Without knowing where you got your sample code, it's hard to help. But
what are you trying to do?
x <- 1:10
y <- c(0.00, 0.00,0.0033,0.0009,0.0025,0.0653,0.1142,0.2872,0,1 )
plot(x, y, pch=20)
# basic straight line of fit
fit <- glm(y~x)
abline(fit, col="blue", lwd=2)
exp.lm <- lm(y ~ exp(x))
lines(1:10, predict(exp.lm, newdata=data.frame(x=1:10)))
On Tue, Nov 27, 2018 at 9:34 AM Tolulope Adeagbo
Hello,
So I found this example online but there seems to be an issue with the
"Start" points. the result is giving somewhat a straight line
# get underlying plot
x <- 1:10
y <- c(0.00, 0.00,0.0033,0.0009,0.0025,0.0653,0.1142,0.2872,0,1 )
plot(x, y, pch=20)
# basic straight line of fit
fit <- glm(y~x)
co <- coef(fit)
abline(fit, col="blue", lwd=2)
# exponential
f <- function(x,a,b) {a * exp(b * x)}
fit <- nls(y ~ f(x,a,b), start = c(a=1 , b=c(0,1)))
co <- coef(fit)
curve(f(x, a=co[1], b=co[2]), add = TRUE, col="green", lwd=2)
# exponential
f <- function(x,a,b) {a * exp(b * x)}
fit <- nls(y ~ f(x,a,b), start = c(a=1, b=1))
co <- coef(fit)
curve(f(x, a=co[1], b=co[2]), add = TRUE, col="green", lwd=2)
# logarithmic
f <- function(x,a,b) {a * log(x) + b}
fit <- nls(y ~ f(x,a,b), start = c(a=1, b=1))
co <- coef(fit)
curve(f(x, a=co[1], b=co[2]), add = TRUE, col="orange", lwd=2)
# polynomial
f <- function(x,a,b,d) {(a*x^2) + (b*x) + d}
fit <- nls(y ~ f(x,a,b,d), start = c(a=1, b=1, d=1))
co <- coef(fit)
curve(f(x, a=co[1], b=co[2], d=co[3]), add = TRUE, col="pink", lwd=2)
Post by Sarah Goslee
Hi,
Using rseek.org to search for exponential regression turns up lots of
information, as does using Google.
Post by Sarah Goslee
Which tutorials have you worked thru already, and what else are you
looking for?
Post by Sarah Goslee
Sarah
On Tue, Nov 27, 2018 at 5:44 AM Tolulope Adeagbo <
Post by Tolulope Adeagbo
Good day,
Please i nee useful materials to understand how to use R for
exponential
Post by Sarah Goslee
Post by Tolulope Adeagbo
regression.
Many thanks.
--
Sarah Goslee (she/her)
http://www.numberwright.com
______________________________________________
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.
[[alternative HTML version deleted]]

______________________________________________
R-***@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.
Tolulope Adeagbo
2018-11-27 18:44:19 UTC
Permalink
Thank you for the clarification.
I'll share a function I got tomorrow morning.

Regards
Post by Bert Gunter
... but do note that a nonlinear fit to the raw data will give a(somewhat)
different result than a linear fit to the transformed data. In the former,
the errors are additive and in the latter they are multiplicative. Etc.
Cheers,
Bert
Bert Gunter
"The trouble with having an open mind is that people keep coming along and
sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
Post by Sarah Goslee
Hi,
Please also include R-help in your replies - I can't provide
one-on-one tutorials.
Without knowing where you got your sample code, it's hard to help. But
what are you trying to do?
x <- 1:10
y <- c(0.00, 0.00,0.0033,0.0009,0.0025,0.0653,0.1142,0.2872,0,1 )
plot(x, y, pch=20)
# basic straight line of fit
fit <- glm(y~x)
abline(fit, col="blue", lwd=2)
exp.lm <- lm(y ~ exp(x))
lines(1:10, predict(exp.lm, newdata=data.frame(x=1:10)))
On Tue, Nov 27, 2018 at 9:34 AM Tolulope Adeagbo
Hello,
So I found this example online but there seems to be an issue with the
"Start" points. the result is giving somewhat a straight line
# get underlying plot
x <- 1:10
y <- c(0.00, 0.00,0.0033,0.0009,0.0025,0.0653,0.1142,0.2872,0,1 )
plot(x, y, pch=20)
# basic straight line of fit
fit <- glm(y~x)
co <- coef(fit)
abline(fit, col="blue", lwd=2)
# exponential
f <- function(x,a,b) {a * exp(b * x)}
fit <- nls(y ~ f(x,a,b), start = c(a=1 , b=c(0,1)))
co <- coef(fit)
curve(f(x, a=co[1], b=co[2]), add = TRUE, col="green", lwd=2)
# exponential
f <- function(x,a,b) {a * exp(b * x)}
fit <- nls(y ~ f(x,a,b), start = c(a=1, b=1))
co <- coef(fit)
curve(f(x, a=co[1], b=co[2]), add = TRUE, col="green", lwd=2)
# logarithmic
f <- function(x,a,b) {a * log(x) + b}
fit <- nls(y ~ f(x,a,b), start = c(a=1, b=1))
co <- coef(fit)
curve(f(x, a=co[1], b=co[2]), add = TRUE, col="orange", lwd=2)
# polynomial
f <- function(x,a,b,d) {(a*x^2) + (b*x) + d}
fit <- nls(y ~ f(x,a,b,d), start = c(a=1, b=1, d=1))
co <- coef(fit)
curve(f(x, a=co[1], b=co[2], d=co[3]), add = TRUE, col="pink", lwd=2)
Post by Sarah Goslee
Hi,
Using rseek.org to search for exponential regression turns up lots of
information, as does using Google.
Post by Sarah Goslee
Which tutorials have you worked thru already, and what else are you
looking for?
Post by Sarah Goslee
Sarah
On Tue, Nov 27, 2018 at 5:44 AM Tolulope Adeagbo <
Post by Tolulope Adeagbo
Good day,
Please i nee useful materials to understand how to use R for
exponential
Post by Sarah Goslee
Post by Tolulope Adeagbo
regression.
Many thanks.
--
Sarah Goslee (she/her)
http://www.numberwright.com
______________________________________________
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.
[[alternative HTML version deleted]]

______________________________________________
R-***@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.
Loading...