[Rd] suggested modification to the 'mle' documentation?
Spencer Graves
spencer.graves at pdf.com
Thu Dec 6 18:38:22 CET 2007
Hello:
I wish to again express my appreciation to all who have
contributed to making R what it is today.
At this moment, I'm particularly grateful for whoever modified the
'mle' code so data no longer need be passed via global variables. I
remember struggling with this a couple of years ago, and I only today
discovered that it is no longer the case.
I'd like to suggest that the 'mle' help file be modified to
advertise this fact, e.g., by adding one of the two examples appearing
below.
Best Wishes,
Spencer Graves
################################
x <- 0:10
y <- c(26, 17, 13, 12, 20, 5, 9, 8, 5, 4, 8)
# Pass data via function arguments rather than global variables
ll.5 <- function(ymax=15, xhalf=6, x., y.)
-sum(stats::dpois(y., lambda=ymax/(1+x./xhalf), log=TRUE))
(fit.5 <- mle(ll.5, start=list(ymax=15, xhalf=6),
fixed=list(x.=x, y.=y)))
ll3 <- function(lymax=log(15), lxhalf=log(6), x., y.)
-sum(stats::dpois(y.,
lambda=exp(lymax)/(1+x./exp(lxhalf)), log=TRUE))
(fit3 <- mle(ll3, start=list(lymax=0, lxhalf=0),
fixed=list(x.=x, y.=y)))
More information about the R-devel
mailing list