SteffenMoritz / ridge

CRAN R Package: Ridge Regression with automatic selection of the penalty parameter
GNU General Public License v2.0
18 stars 11 forks source link

Error in numeric(nPCs) : invalid 'length' argument #2

Closed badbye closed 4 years ago

badbye commented 5 years ago

Here in https://github.com/cran/ridge/blob/master/R/linearRidge.R#L96,

nPCs <- which.max(propVar[propVar < 90]) + 1

what if all the elements in propVar are greater than 90? It will throw an error, which is the title of this issue.

SteffenMoritz commented 5 years ago

THX for your bug report. I tried to fix it. Would you mind making a install from Github to see if the error disappeared?

badbye commented 5 years ago

A similar error:

Error in if (which.max(propVar[propVar < 90]) > 0) { :
  argument is of length zero
badbye commented 5 years ago

Hi, I do not mind share my data and code:

mydata = read.csv('https://gist.githubusercontent.com/badbye/c4be83a28f4f6f10e2e067189f67d834/raw/a42b4bc7e4b3c570267902cd9e140a33343bfe8e/test%2520the%2520%2560ridge%2560%2520package')
m = linearRidge(y ~ ., data = mydata)

You can use it to test your code. I know this dataset do not need to use ridge regression. It is still better to make this package more robust. Hope you agree with me.

SteffenMoritz commented 5 years ago

Took me some time (cause I had multiple other things to do...). But I think I fixed the issue.

Thanks again badbye for reporting the bug !! :-)