Exponential regression with plotting
Description
uses lm
; plots data if add=FALSE, draws the regression line
with abline
and confidence interval with polygon
and writes the formula with legend
Usage
1 2 3 4 5 6  expReg(x, y = NULL, data = NULL, logy = TRUE, predictnew = NULL,
interval = "confidence", plot = TRUE, digits = 2, inset = 0,
xpd = par("xpd"), pos1 = "top", pos2 = NULL, add = FALSE, pch = 16,
col = rgb(0, 0, 0, 0.5), modcol = 2, lwd = 1,
xlab = deparse(substitute(x)), ylab = deparse(substitute(y)),
main = "exponential regression", xlim = range(x), ylim = range(y), ...)

Arguments
x 
Numeric or formula (see examples). Vector with values of explanatory variable 
y 
Numeric. Vector with values of dependent variable. DEFAULT: NULL 
data 
Dataframe. If x is a formula, the according columns from data are used as x and y. DEFAULT: NULL 
logy 
Plot with a logarithmic y axis? Calls 
predictnew 
Vector with values to predict outcome for. Passed as 
interval 
Interval for prediction. DEFAULT: "confidence" 
plot 
Plot things at all? If FALSE, predictnew will still be returned. DEFAULT: TRUE 
digits 
Numeric vector of length ≥ 1. Specifies number of digits a,b,r,e are rounded to in the formula "y=a*log(x)+b, R^2, RMSE=e", respectively. If values are not specified, they are set equal to the first. DEFAULT: 2 
inset 
Numeric vector of length ≤ 2. inset distance(s) from the margins as a fraction of the plot region when formula is placed by keyword. DEFAULT: 0 
xpd 
Logical, specifying wheter formula can be written only inside the plot region (when FALSE) or inside the figure region including mar (when TRUE) or in the entire device region including oma (when NA). DEFAULT: par("xpd") 
pos1 

pos2 
For numerical coordinates, this is the yposition. DEFAULT: NULL, as in 
add 
Logical. If TRUE, line and text are added to the existing graphic. DEFAULT: FALSE (plots datapoints first and then the line.) 
pch 
Point Character, see 
col 
Color of points, see 
modcol 
color of model line. DEFAULT: 2 
lwd 
Numeric. Linewidth, see 
xlab, ylab, main 
Character / Expression. axis label and graph title if add=FAlSE. DEFAULT: internal from names 
xlim, ylim 
graphic range. DEFAULT: range(x) 
... 
Further arguments passed to 
Value
predict.lm
result.
Author(s)
Berry Boessenkool, berryb@gmx.de, Dec. 2014
See Also
lm
, mReg
, linReg
.
Examples
1 2 3 4 5 6 7 