Use fitted(object) for the stored response-scale fitted values, preserving
vector or matrix shape, row order, names, and missing values. It does not
recompute a fit or imply prediction at new points. For harmonic.smoother()
results it returns harmonic_predictions. The basic
perform.harmonic.smoothing() result remains an unclassed list, accessed
through $harmonic_predictions; density probability masses remain $rho.
Usage
# S3 method for class 'lps'
fitted(object, ...)
# S3 method for class 'lps'
residuals(object, ...)
# S3 method for class 'malps'
fitted(object, ...)
# S3 method for class 'malps'
residuals(object, ...)
# S3 method for class 'ps_lps'
fitted(object, ...)
# S3 method for class 'ps_lps'
residuals(object, ...)
# S3 method for class 'chart_kernel'
fitted(object, ...)
# S3 method for class 'chart_kernel'
residuals(object, ...)
# S3 method for class 'local_likelihood'
fitted(object, ...)
# S3 method for class 'local_likelihood'
residuals(object, ...)
# S3 method for class 'lpl_tf'
fitted(object, ...)
# S3 method for class 'lpl_tf'
residuals(object, ...)
# S3 method for class 'slpl_tf'
fitted(object, ...)
# S3 method for class 'slpl_tf'
residuals(object, ...)
# S3 method for class 'metric.graph.lowpass.fit'
fitted(object, ...)
# S3 method for class 'metric.graph.lowpass.fit'
residuals(object, ...)
# S3 method for class 'metric.graph.lowpass.refit'
fitted(object, ...)
# S3 method for class 'metric.graph.lowpass.refit'
residuals(object, ...)
# S3 method for class 'ssrhe.hessian.fit'
fitted(object, ...)
# S3 method for class 'ssrhe.hessian.fit'
residuals(object, ...)
# S3 method for class 'ssrhe.hessian.refit'
fitted(object, ...)
# S3 method for class 'ssrhe.hessian.refit'
residuals(object, ...)
# S3 method for class 'ssrhe.hessian.l1.fit'
fitted(object, ...)
# S3 method for class 'ssrhe.hessian.l1.fit'
residuals(object, ...)
# S3 method for class 'graph.trend.filtering.fit'
fitted(object, ...)
# S3 method for class 'graph.trend.filtering.fit'
residuals(object, ...)
# S3 method for class 'pttf.trend.filtering.fit'
fitted(object, ...)
# S3 method for class 'pttf.trend.filtering.fit'
residuals(object, ...)
# S3 method for class 'harmonic_smoother'
fitted(object, ...)Details
residuals(object) returns stored response residuals where available,
including missing-label masks. Otherwise it computes y - fitted.values
only when the evaluation coordinates equal the training coordinates.
Residuals at different evaluation points are undefined and cause an error,
even when training and evaluation have the same number of rows. Binomial
residuals are on the response (probability) scale, not Pearson or deviance
residuals. These accessors do not change which refit results are reusable.
Examples
X <- matrix(seq(0, 1, length.out = 20), ncol = 1)
model <- fit.malps(X, X[, 1]^2, degree = 1L,
support.type = "knn", support.size = 8L)
head(fitted(model))
#> [1] -0.011878001 0.001253097 0.014713513 0.029752682 0.047433476
#> [6] 0.068993593
head(residuals(model))
#> [1] 0.0118780010 0.0015169866 -0.0036331804 -0.0048219340 -0.0031121466
#> [6] 0.0002584847