predict.gsl_nls {gslnls} | R Documentation |
Calculate model predicted values
Description
Returns predicted values for the expected response from a fitted "gsl_nls"
object.
Asymptotic confidence or prediction (tolerance) intervals at a given level
can be evaluated
by specifying the appropriate interval
argument.
Usage
## S3 method for class 'gsl_nls'
predict(
object,
newdata,
scale = NULL,
interval = c("none", "confidence", "prediction"),
level = 0.95,
...
)
Arguments
object |
An object inheriting from class |
newdata |
A named list or data.frame in which to look for variables with which to predict. If
|
scale |
A numeric scalar or vector. If it is set, it is used as the residual standard deviation (or vector of residual standard deviations) in the computation of the standard errors, otherwise this information is extracted from the model fit. |
interval |
A character string indicating if confidence or prediction (tolerance) intervals at the specified level should be returned. |
level |
A numeric scalar between 0 and 1 giving the confidence level for the intervals (if any) to be calculated. |
... |
At present no optional arguments are used. |
Value
If interval = "none"
(default), a vector of predictions for the mean response. Otherwise,
a matrix with columns fit
, lwr
and upr
. The first column (fit
) contains
predictions for the mean response. The other two columns contain lower (lwr
) and upper (upr
)
confidence or prediction bounds at the specified level
.
See Also
Examples
## data
set.seed(1)
n <- 25
xy <- data.frame(
x = (1:n) / n,
y = 2.5 * exp(-1.5 * (1:n) / n) + rnorm(n, sd = 0.1)
)
## model
obj <- gsl_nls(fn = y ~ A * exp(-lam * x), data = xy, start = c(A = 1, lam = 1))
predict(obj)
predict(obj, newdata = data.frame(x = 1:(2 * n) / n))
predict(obj, interval = "confidence")
predict(obj, interval = "prediction", level = 0.99)