Hi,

I obtained custom code for the infamous HL test, which I know is frowned
upon here.

In any event,  I'm feeding it a matrix and a data frame.  How can I set the
function to ignore missing values?

I tried:

 HL <- function(p, y, NA.rm=T)
{
options(na.action=na.exclude)
y <- y[order(p)];
p <- p[order(p)];
n <- length(p);
idx <- (0:(n-1)) %/% (n/10);
R.decile <- 0;
for (i in 0:9)
{
ybar <- sum(y[idx==i]) ;
m <- sum(idx==i) ;
pbar <- mean(p[idx==i]) ;
R.decile <- R.decile + (ybar - m*pbar)^2/(m*pbar*(1-pbar));
}
print(paste("HL Decile:", R.decile, ", P=", 1 - pchisq(R.decile, df=8)));
}

Thank you!

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to