Skip to contents

Fit a new response while reusing the geometry or operators in a supported fitted object. R selects the method from the class of object.

Usage

refit(object, y, ...)

# Default S3 method
refit(object, y, ...)

Arguments

object

A fitted MALPS, local polynomial lifting trend filter, synchronized lifting trend filter, metric graph low-pass, quadratic Hessian-energy, or Hessian L1 model.

y

New response. MALPS and the two lifting trend filters accept a vector; Hessian L1 accepts one response; metric graph low-pass and quadratic Hessian methods also accept a matrix with one response per column. MALPS and both Hessian methods reuse the stored response when y is omitted or NULL. The other methods require y.

...

Method-specific controls, described in the linked method help. Unrecognized arguments are errors.

Value

A refitted object or refit summary, as documented by the method.

Details

Refitting does not automatically repeat the original model selection:

malps

refit.malps reuses supports and averaging weights; accepts observation weights. Robust local residual weights, if used, are recomputed for the new response.

lpl_tf

refit.lpl_tf reuses the residual operator and penalty, or accepts a new fixed lambda.

slpl_tf

refit.slpl_tf reuses both operators and penalties, or accepts fixed lambda1 and lambda2.

metric.graph.lowpass.fit

refit.metric.graph.lowpass.fit reuses the spectral basis and smoothing parameter. Set per.column.gcv = TRUE to select a parameter for each response column.

ssrhe.hessian.fit

refit.ssrhe.hessian.fit reuses the Hessian operator and fixed penalties, with optional lambda1, lambda2, weights, and ridge. This also handles CV- and GCV-selected fits, retaining their selected penalties by default.

ssrhe.hessian.l1.fit

refit.ssrhe.hessian.l1.fit reuses the derivative operator with fixed or CV-selected penalties; accepts lambda.grid, lambda.selection, and solver controls.

Use the original fitted object for repeated metric graph low-pass or quadratic Hessian refits: their refit results are summaries, not reusable input fits. Other supported families return reusable fitted objects.

Migration

The six former exported refit.*() functions are replaced by refit(object, y, ...). Replace named fitted.model and y.new arguments with object and y, respectively. Method-specific controls and return classes are preserved. Call the generic rather than an individual S3 method; the former help names remain available for navigation.

See also

Examples

X <- matrix(seq(0, 1, length.out = 20), ncol = 1)
fit <- fit.malps(X, X[, 1]^2, degree = 1L,
                 support.type = "knn", support.size = 8L)
updated <- refit(fit, y = X[, 1]^3)
head(predict(updated))
#> [1] -0.004590707 -0.001399860  0.001750168  0.005533468  0.010686466
#> [6]  0.018201032