# How to calculate Cook's distance for lm.ridge objects in R

How can I calculate Cook's distance for lm.ridge objects?

I first created a glmnet object and carried out ridge regression finding suitable shrinkage parameter. After that, I am calculating the beta values:

object<-cv.glmnet(as.matrix(indp_data),response_data,type.measure = "mse")
fit_lm<-MASS:::lm.ridge(formula,data,lambda = seq(object$lambda.min,0.1,len=10),model=TRUE) whichIsBest <- which.min(fit_lm$GCV)
gcv_est<-data.frame(coef(fit_lm)[whichIsBest,])
row.names(gcv_est)[1]<-"Intrecept"
colnames(gcv_est)[1] <- "Estimates"

Beta_Values<-as.matrix(gcv_est)[-1,]


All variables are of class numeric. I have calculated the residual by subtracting fitted values from the observed. But how can I calculate Cook's distance from here?

## migrated from stackoverflow.comDec 21 '16 at 14:34

This question came from our site for professional and enthusiast programmers.