Skip to content

npudens(np) Error missing value where TRUE/FALSE needed

2 messages · carolien lavigne, Jim Lemon

#
Hi,

 

I am looking for some help concerning the npudens function
in the np package.

I am trying to find a kernel density function of a
multivariate dataset and the density evaluated at each of the 176 points. 

I have 2 continuous and 3 ordered discrete variables. My
sample size is 176.

So edata is a 176x(2+3) data frame, while tdat is a 1x(2+3)
vector. 

bw_cx[i,] is a 1x (2+3) vector representing the bandwidths h for each variable, which were calculated using the npcdensbw function. (no this is not a mistake, I deliberately use the conditional one)

For this I use the below function in R.

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

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

This version was installed on a very old (read very slow and
about to crash) computer.

I recently installed version 3.2.4 on my new computer, and
now I get the following error message when I try to execute the npudens
function:

 

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.

But as I am not an expert in writing functions, this error
message doesn?t really help.Changing it to the following also doesn't help: kerz <- npudens(bws=(bw_cx[i,]),ckertype="epanechnikov",,okertype="liracine",tdat=tdata,edat=dat)

 

Am I doing something wrong here? 

Were some changes made to this function and
do I need to alter some arguments to these changes?

Or might this be a bug?

 

Thanks!

 

Carolien
#
Hi Carolien,
There was a recent request involving a change in the functionality of
R that may be relevant to your problem. The usual trigger for the
"missing value where TRUE/FALSE needed" error is a conditional
expression that doesn't evaluate because of an NA value. As some
coercion or summary functions that worked in older versions of R but
have been deprecated in more recent ones, your code may be generating
NA values at some point where it did not before.

Jim


On Fri, Apr 22, 2016 at 7:15 PM, carolien lavigne
<carolienlavigne at hotmail.com> wrote: