exp4p: 4-parametric exponential function

View source: R/exp4p.R

exp4pR Documentation

4-parametric exponential function

Description

Fits an exponential function of the form a*e^(b*(x+c))+d

Usage

exp4p(x, y, digits = 2, plot = FALSE, las = 1, col = 1:6, legarg = NULL, ...)

Arguments

x, y

x and y Data

digits

significant digits for rounding R^2. DEFAULT: 2

plot

plot data and fitted functions? DEFAULT: FALSE

las

label axis style, see par. DEFAULT: 1

col

6 colors for lines and legend texts. DEFAULT: 1:6

legarg

Arguments passed to legend. DEFAULT: NULL

...

further graphical parameters passed to plot

Details

This is mainly a building block for mReg

Value

Data.frame with the 4 parameters for each optim method

Note

Optim can be slow! It refers to the functions rmse and rsquare, also in this package. L-BFGS-B needs finite values. In case it doesn't get any with the initial parameters (as in the first example Dataset), it tries again with the parameters optimized via Nelder Mead.

Author(s)

Berry Boessenkool, berry-b@gmx.de, 2012-2013, outsourced from mReg in July 2014

See Also

mReg, lm

Examples

## Not run: ## Skip time consuming checks on CRAN
# exponential decline of temperature of a mug of hot chocolate
tfile <- system.file("extdata/Temp.txt", package="berryFunctions")
temp <- read.table(tfile, header=TRUE, dec=",")
head(temp)
plot(temp)
temp <- temp[-20,] # missing value - rmse would complain about it
x <- temp$Minuten
y <- temp$Temp
rm(tfile, temp)

exp4p(x,y, plot=TRUE)
# y=49*e^(-0.031*(x - 0  )) + 25 correct, judged from the model:
# Temp=T0 - Te *exp(k*t) + Te     with    T0=73.76,  Tend=26.21, k=-0.031
# optmethod="Nelder-Mead"  # y=52*e^(-0.031*(x + 3.4)) + 26 wrong

## End(Not run)


berryFunctions documentation built on April 12, 2023, 12:36 p.m.