On Mon, Nov 19, 2012 at 11:36 AM, Hadley Wickham <span dir="ltr"><<a href="mailto:h.wickham@gmail.com" target="_blank">h.wickham@gmail.com</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">> To be fair with the R language, I would have compare with the use of real<br>
> primitives :<br>
><br>
> vaccBubu <- function(age, female, ily) {<br>
> gender <- female * 1.25<br>
> gender[!female] <- 0.75<br>
> p <- (0.25 + 0.3 * 1 / (1 - exp(0.04 * age)) + 0.1 * ily) * gender<br>
> p[p < 0] <- 0<br>
> p[p > 1] <- 1<br>
> p<br>
> }<br>
><br>
<br>
</div>I think you could do it a bit more elegantly with<br>
<br>
gender <- 0.75 + female * 0.5<br>
<br>
but pmin and pmax are "real" primitives, so I think it's fine to use them.</blockquote><div><br></div><div>In the folklore ifelse, pmin and pmax are know to be slow. I know that there was some work on pmin and pmax but I think they are still more sluggish than desired.</div>
<div><br></div><div>In early work on generalized linear mixed models i did some profiling and discovered that an inordinate amount of time was spent on evaluating the inverse link, derivative and variance functions and a lot of that could be traced to pmin and pmax.</div>
<div> </div></div></div>