Creating Mills Ratio in R for large values
问题 I'm using R to create a function, that amongst others uses Mills Ratio (See here). This is not a complicated formula, and at first I just programmed it like this: mill <- function(x) { return((1 - pnorm(x)) / dnorm(x)) } I soon found out however, that for very large values (x >= 9) of x , this function returns zero. Even more dramatic, at around x >= 37, it starts returning NaN , which really messes up my stuff. Following the article, for now I've changed the function into this: mill <-