0

I am using the npudens function in the np package for R.

I am trying to find a kernel density function of a multivariate dataset and the density evaluated at each of the 632 points to run a conditional efficiency analysis.

I have 4 continuous one dummy variable and my sample size is 632 observations.

I use the below function in R.

kerz <- npudens(bws=bw_cx[i,], cykertype="epanechnikov", cxkertype="epanechnikov",
                oxkertype="liracine", tdat=tdata, edat=dat)

In earlier versions, this worked fine, as I was able to retrieve the necessary density estimates with kerz$dens.

In newer version and in Rstudio Cloud I get an error:

Error in if (any(a <= 0)) warning(paste("variable", which(a <= 0), " appears to be constant",:missing value where TRUE/FALSE needed

I suppose some if-statement doesn't evaluate to a TRUE or FALSE somewhere in the npudens function. I have tried to debug the command by changing it to the following command:

kerz2 <- npudens(bws=(bw_cx[i,]), ckertype="epanechnikov",, okertype="liracine",
                 tdat=tdata, edat=dat)

Unfortunately, I get the same error.

Any help/advice on how to fix this would be greatly appreciated.

r2evans
  • 141,215
  • 6
  • 77
  • 149
  • Please make your question reproducible by adding the data, e.g. with ´dput(kerz)´. See also [How to make a great R reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example/5963610#5963610) – help-info.de Sep 19 '19 at 15:38
  • ErikAlda, I suggested an edit to improve formatting/presentation, and added some spaces for a little of (my opinion of) readability. If I stepped out of line, my apologies. I noticed two things: (1) you have an empty argument (two commas) in your second call, is that intentional? And (2) code is either *inline* with single ticks (`\`npudens\``) or code blocks with leading triple-ticks *and a language* (e.g., `\`\`\`lang-r\n`, where `\n` is a newline); see https://stackoverflow.com/editing-help#syntax-highlighting for info on this second one. – r2evans Sep 19 '19 at 15:47
  • It's possible that that empty argument (second comma) might produce that error; I don't know, but see if that fixes things. – r2evans Sep 19 '19 at 15:48
  • Thank you for your edits @help-info.de it is much appreciated. I will make a reproducible example and post it. – Erik Alda Sep 19 '19 at 15:50

0 Answers0