R-beta: nlm

Ennapadam Venkatraman (VENKAT@biosta.mskcc.org)
6 Jun 97 17:37:00 EST

Message-Id: <199706022138.XAA03770@hypatia.math.ethz.ch>
Date: 6 Jun 97 17:37:00 EST
From: "Ennapadam Venkatraman" <VENKAT@biosta.mskcc.org>
Subject: R-beta: nlm
To: "r-help" <r-help@stat.math.ethz.ch>

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

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@stat.math.ethz.ch