update
Update a Fitted Model Object

Description

Creates a new model or object, using the same call used for an earlier model or object, except for some changes.

Usage

update(object, ...)
## Default S3 method:
update(object, formula., ..., evaluate = TRUE)
## S3 method for class 'formula':
update(old, new, ...)
getCall(x, ...)
## Default S3 method:
getCall(x, ...)

Arguments

object, x any object with a component or S4 slot named "call", typically the result of fitting a model.
formula., old, new a modeling formula, such as y ~ a + b. A single dot . on either side of the ~ of formula. or new gets replaced by the left or right side of the formula in object or old. The dot on the left can be omitted. By default, it refits object using the same formula as in object.
... any other arguments that are appropriate for the particular call. These must all be named, and may be abbreviated, in the same manner they could be as arguments to the fitting function itself. Arguments in the previous fit; that is, in object$call, can be removed by putting nothing on the right side of the =. For example, the argument x=, in a call to update() causes the x argument, if present in object$call, to be removed.
evaluate if TRUE (the default), the new call is evaluated; otherwise, the call is returned as an unevaluated expression.

Details

Value
update returns either a new updated object, or it returns an unevaluated expression for creating such an object.
getCall returns the list component or S4 slot, but not the attribute, named "call".
References
Chambers, J. M. and Hastie, T .J. (Eds.) 1992. Statistical Models in S. Pacific Grove, CA.: Wadsworth & Brooks/Cole. Chapter 4.
See Also
add1, drop1, methods, eval.
Examples
fit <- lm(Fuel ~ Weight + Type, data = Sdatasets::fuel.frame)
# Refit, unchanged
update(fit)
# Refit, adding term
update(fit, ~ . + Disp.) # add displacement to the model
# Transform response to log scale; drop intercept
update(fit, log(.) ~ . -1)
# Use all the 2nd order interactions of original fit
update(fit, ~ .^2)
# Supply a subset
update(fit, subset= (Type != "Van"))  # look only at cars, exclude vans
# Remove an argument, prevent evaluation (would fail)
update(fit, data =, evaluate = FALSE)
getCall(fit)
Package stats version 6.1.1-7
Package Index