ridgelm_tidiers {broom} | R Documentation |
These methods tidies the coefficients of a ridge regression model chosen at each value of lambda into a data frame, or constructs a one-row glance of the model's choices of lambda (the ridge constant)
## S3 method for class 'ridgelm' tidy(x, ...) ## S3 method for class 'ridgelm' glance(x, ...)
x |
An object of class "ridgelm" |
... |
extra arguments (not used) |
All tidying methods return a data.frame without rownames, whose structure depends on the method chosen.
tidy.ridgelm
returns one row for each combination of
choice of lambda and term in the formula, with columns:
lambda |
choice of lambda |
GCV |
generalized cross validation value for this lambda |
term |
the term in the ridge regression model being estimated |
estimate |
estimate of scaled coefficient using this lambda |
scale |
Scaling factor of estimated coefficient |
glance.ridgelm
returns a one-row data.frame with the columns
kHKB |
modified HKB estimate of the ridge constant |
kLW |
modified L-W estimate of the ridge constant |
lambdaGCV |
choice of lambda that minimizes GCV |
This is similar to the output of select.ridgelm
, but it is returned
rather than printed.
names(longley)[1] <- "y" fit1 <- MASS::lm.ridge(y ~ ., longley) tidy(fit1) fit2 <- MASS::lm.ridge(y ~ ., longley, lambda = seq(0.001, .05, .001)) td2 <- tidy(fit2) g2 <- glance(fit2) # coefficient plot library(ggplot2) ggplot(td2, aes(lambda, estimate, color = term)) + geom_line() # GCV plot ggplot(td2, aes(lambda, GCV)) + geom_line() # add line for the GCV minimizing estimate ggplot(td2, aes(lambda, GCV)) + geom_line() + geom_vline(xintercept = g2$lambdaGCV, col = "red", lty = 2)