influridge | R Documentation |
This function produces a curve plot showing the optimal tuning paramer when up- or downweighting each observation.
influridge(
X,
y,
nw = 40,
max.weight = 4,
noExpand = 0,
noShrink = 0,
degreeFreedom = FALSE,
control.list = list(factr = 1e-04)
)
X |
numerical input matrix, of dimension nobs x nvars; each row is an observation vector. |
y |
numerical output vector; response variable. |
nw |
scalar, number of grid points for curve. |
max.weight |
scalar, the maximum weight for the curve. |
noExpand |
scalar, number of expanders to be highlighted (less than 5). |
noShrink |
scalar, number of shrinkers to be highlighted (less than 5). |
degreeFreedom |
logical, should the degrees of freedom be plotted instead of the tuning parameter (default = FALSE). |
control.list |
list, a list of control parameters for the optim function. See 'Details' under graphics::optim. |
p <- 5
n <- 20
sigma <- 1
beta <- rep(1, p)
## Simulating design matrix, X
set.seed(556)
X <- matrix(rnorm(n * p), n, p)
## Simulate outcome vector, Y
y <- X %*% beta + rnorm(n, 0, sigma)
## Plot curves (no highlighted shrinkers/expanders)
influridge(X, y)
## Adding a large positive residual to observation 10 creates an influential shrinker
y[10] <- y[10] + 3
influridge(X, y, noShrink = 1, nw = 20)
## Plot degrees of freedom
influridge(X, y, noShrink = 1, nw = 20, degreeFreedom = TRUE)
## Not run:
## Make plot for Body Fat dataset
require(mfp)
data(bodyfat)
X <- bodyfat[, 6:17] # Omit non-continous age variable
y <- bodyfat$siri
n <- dim(X)[1]
X <- scale(X, center = FALSE) # Scale data
X <- cbind(rep(1, n), X) # Add intercept to design matrix
influridge(X, y, noShrink = 1, noExpand = 1, degreeFreedom = TRUE)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.