... 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.
Post by Sarah GosleeHi,
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 GosleeHi,
Using rseek.org to search for exponential regression turns up lots of
information, as does using Google.
Post by Sarah GosleeWhich tutorials have you worked thru already, and what else are you
looking for?
Post by Sarah GosleeSarah
On Tue, Nov 27, 2018 at 5:44 AM Tolulope Adeagbo <
Post by Tolulope AdeagboGood day,
Please i nee useful materials to understand how to use R for
exponential
--
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.