uses lm
; plots data if add=FALSE, draws the regression line
with abline
and confidence interval with polygon
and writes the formula with legend
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),
...
)
predict.lm
result.
Numeric or formula (see examples). Vector with values of explanatory variable
Numeric. Vector with values of dependent variable. DEFAULT: NULL
Dataframe. If x is a formula, the according columns from data are used as x and y. DEFAULT: NULL
Plot with a logarithmic y axis? Calls logAxis
. DEFAULT: TRUE
Vector with values to predict outcome for. Passed as newdata
to predict.lm
. DEFAULT: NULL
Interval for prediction. DEFAULT: "confidence"
Plot things at all? If FALSE, predictnew will still be returned. DEFAULT: TRUE
Numeric vector of length \(\ge 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
Numeric vector of length \(\le 2\). inset distance(s) from the margins as a fraction of the plot region when formula is placed by keyword. DEFAULT: 0
Logical, specifying whether 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")
xy.coords
-acceptable position of the formula. DEFAULT: "top"
For numerical coordinates, this is the y-position. DEFAULT: NULL, as in legend
Logical. If TRUE, line and text are added to the existing graphic. DEFAULT: FALSE (plots datapoints first and then the line.)
Point Character, see par
. DEFAULT: 16
Color of points, see par
. DEFAULT: rgb(0,0,0, 0.5)
color of model line. DEFAULT: 2
Numeric. Linewidth, see par
. DEFAULT: 1
Character / Expression. axis label and graph title if add=FALSE. DEFAULT: internal from names
graphic range. DEFAULT: range(x)
Berry Boessenkool, berry-b@gmx.de, Dec. 2014
lm
, mReg
, linReg
.
x <- runif(100, 1, 10)
y <- 10^(0.3*x+rnorm(100, sd=0.3)+4)
plot(x,y)
expReg(x,y)
expReg(x,y, logy=FALSE)
expReg(x,y, predictnew=6, plot=FALSE)
expReg(x,y, predictnew=3:6, interval="none", plot=FALSE)
Run the code above in your browser using DataLab