R-beta: nlm
Ennapadam Venkatraman
VENKAT at biosta.mskcc.org
Sat Jun 7 00:37:00 CEST 1997
I am trying to use the function "nlm" to find the mle. I want to use a
generic function for the likelihood which would require me to use both the
parameters and the data as arguments. But nlm requires the function to
have only the parameters as arguments for this function (see example below).
> testfun <- function(x,y) sum((x-y)^2) # x - parameters, y - data
> nlm(tfun,0)
Error: Argument "y" is missing, with no default
Thus the problem I have is as follows:
llkfun -- generic function to calculate the likelihood
for given data and parameters
mlefun -- function to evaluate mle for a given dataset which calls
nlm(llkfun,...)
I tried using "get", "sys.???" etc in 'llkfun' so that it can be written as
just a function of parameters. But it doesn't seem to work, always giving me
an error message -- data not found. (It works if I just call 'llkfun' inside
'mlefun' -- only the nlm step doesn't). So I want data defined in the frame
for 'mlefun' to be passed down to 'llkfun' through 'nlm'.
Can anyone help me?
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
More information about the R-help
mailing list