residuals.l2boost: Model residuals for the training set of an l2boost model...

Description Usage Arguments Value See Also Examples

View source: R/residuals.l2boost.R

Description

residuals is a generic function which extracts model residuals from objects returned by modeling functions.

residuals.l2boost returns the training set residuals from an l2boost object. By default, the residuals are returned at the final iteration step m=M.

Usage

1
2
## S3 method for class 'l2boost'
residuals(object, m = NULL, ...)

Arguments

object

an l2boost object for the extraction of model coefficients.

m

the iteration number with the l2boost path. If m=NULL, the coefficients are obtained from the last iteration M.

...

arguments (unused)

Value

a vector of n residuals

See Also

residuals and l2boost and predict.l2boost

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#--------------------------------------------------------------------------
# Example: Diabetes 
#  
# For diabetes data set, see Efron B., Hastie T., Johnstone I., and Tibshirani R. 
# Least angle regression. Ann. Statist., 32:407-499, 2004.
data(diabetes, package = "l2boost")

l2.object <- l2boost(diabetes$x,diabetes$y, M=1000, nu=.01)
rsd<-residuals(l2.object)
rsd.mid <- residuals(l2.object, m=500)

# Create diagnostic plots
par(mfrow=c(2,2))
qqnorm(residuals(l2.object), ylim=c(-3e-13, 3e-13))
qqline(residuals(l2.object), col=2)

qqnorm(residuals(l2.object, m=500), ylim=c(-3e-13, 3e-13))
qqline(residuals(l2.object, m=500), col=2)

# Tukey-Anscombe's plot
plot(y=residuals(l2.object), x=fitted(l2.object), main="Tukey-Anscombe's plot",
   ylim=c(-3e-13, 3e-13))
lines(smooth.spline(fitted(l2.object), residuals(l2.object), df=4), type="l", 
  lty=2, col="red", lwd=2)
abline(h=0, lty=2, col = 'gray')

plot(y=residuals(l2.object, m=500), x=fitted(l2.object, m=500), main="Tukey-Anscombe's plot", 
  ylim=c(-3e-13, 3e-13))
lines(smooth.spline(fitted(l2.object,m=500), residuals(l2.object, m=500), df=4), type="l", 
  lty=2, col="red", lwd=2)
abline(h=0, lty=2, col = 'gray')

l2boost documentation built on Feb. 11, 2022, 5:10 p.m.