[R] npudens(np) Error missing value where TRUE/FALSE needed
carolien lavigne
carolienlavigne at hotmail.com
Fri Apr 22 11:15:00 CEST 2016
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 doesnt evaluate to a TRUE or
FALSE somewhere in the npudens function.
But as I am not an expert in writing functions, this error
message doesnt 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
[[alternative HTML version deleted]]
More information about the R-help
mailing list