How to review lm.ridge?

I wonder if there is a way to get a summary for ridge regression in R? This is the result of the lm.ridge{MASS} function.

For the standard linear model, you are simply summary(lm_model) , but what about the ridge regression model? Thanks for the help.

+6
source share
3 answers

I just added a method that sums up (or rather tidies ) "ridgelm" objects to broom . It takes the form of two S3 generics: tidy and glance . You can install it with devtools::install_github("dgrtwo/broom") (although you need to install devtools ).

As an example, you can configure ridge regression:

 library(MASS) names(longley)[1] <- "y" fit <- lm.ridge(y ~ ., longley, lambda = seq(0.001, .05, .001)) 

The tidy function provides a data frame that shows each combination of lambda and evaluated term:

 library(broom) td <- tidy(fit) head(td) ## lambda GCV term estimate ## 1 0.001 0.1240 GNP 23.02 ## 2 0.002 0.1217 GNP 21.27 ## 3 0.003 0.1205 GNP 19.88 ## 4 0.004 0.1199 GNP 18.75 ## 5 0.005 0.1196 GNP 17.80 ## 6 0.006 0.1196 GNP 16.99 

While the glance function creates a one-line resume, in particular, choosing a lambda in various ways:

 g <- glance(fit) g ## kHKB kLW lambdaGCV ## 1 0.006837 0.05267 0.006 

This is useful because it makes it easy to build and analyze data yourself, rather than relying on MASS plotters:

 library(ggplot2) ggplot(td, aes(lambda, estimate, color = term)) + geom_line() 

enter image description here

 # plot of GCV versus lambda ggplot(td, aes(lambda, GCV)) + geom_line() + geom_vline(xintercept = g$lambdaGCV, col = "red", lty = 2) 

enter image description here

For more information on these methods, see ?ridgelm_tidiers or see package vignettes for the more general tidy and glance methods.

+9
source

There is no summary method for ridgelm class:

 > methods(class = 'ridgelm') [1] coef.ridgelm* plot.ridgelm* print.ridgelm* select.ridgelm* 

What should return this resume? You can extract all the necessary information from the ridgelm object.

However, you can also write your own summary methods for your purposes (check the code for summary.lm() to get started). If you are satisfied with this, you can send it to the accompanying MASS.

+2
source

You can use my lmridge package from CRAN.

+1
source

Source: https://habr.com/ru/post/976728/


All Articles