twolodzko / kernelboot

Smoothed bootstrap and functions for sampling from kernel densities
3 stars 1 forks source link

ignore parameter doesn't work #7

Closed abnormally-distributed closed 4 years ago

abnormally-distributed commented 4 years ago

I am having issues getting kernelboot to work with data frames containing factor variables. This is true even when the model formula being fit only uses numeric variables.

Here is a simple reproducible example, trying both the default bw.silv and trying bw.nrd0

f <- function(dat){coef(lm(Sepal.Width ~ . , data = dat))}
kernelboot(iris, f, ignore = "Species")
**Error in bw.silv(data) : all columns need to be numeric**

kernelboot(iris, f, ignore = "Species", bw = "nrd0")
**Error in is.data.frame(x) : (list) object cannot be coerced to type 'double'**

The same occurs when omitting the factor variable from the model formula.

f <- function(dat){coef(lm(Sepal.Width ~ . -Species, data = dat))}
kernelboot(iris, f, ignore = "Species")
**Error in bw.silv(data) : all columns need to be numeric**

kernelboot(iris, f, ignore = "Species", bw = "nrd0")
**Error in is.data.frame(x) : (list) object cannot be coerced to type 'double'**
twolodzko commented 4 years ago

Thanks, this is a bug. I prepared a fix, will test it & merge, then post to CRAN.

twolodzko commented 4 years ago

FYI, I submitted it on CRAN.

abnormally-distributed commented 4 years ago

Thanks! I'll check it out.