Dear R users, I am trying to minimise a function using "nlm". I am getting the following error message: "Error: function is too long to keep source" The function is really very long (about 100 A4 pages). Is there anything I could do to solve this problem? At the moment I am using "nlmin" in S-Plus with no problems but I'd prefer to use R. Thank you very much in advance. Regards. Marcel Marcel Vieira Social Statistics University of Southampton
Have you considered "optim" in library(MASS)? "optim" will optionally output the hessian, which can be used to obtain confidence intervals in many cases. hope this helps. spencer graves Marcel Vieira wrote:> Dear R users, > > I am trying to minimise a function using "nlm". > > I am getting the following error message: "Error: function is too long > to keep source" > > The function is really very long (about 100 A4 pages). > > Is there anything I could do to solve this problem? > > At the moment I am using "nlmin" in S-Plus with no problems but I'd > prefer to use R. > > Thank you very much in advance. > > Regards. > Marcel > > Marcel Vieira > Social Statistics > University of Southampton > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://www.stat.math.ethz.ch/mailman/listinfo/r-help
Thanks a lot for your help. But I am getting that error message when I am trying to load my function. Then I can't use anything to minimise it. Is there anything I can do to increase R's capacity for loading very long functions? Many thanks. Marcel>Have you considered "optim" in library(MASS)? "optim" will optionally >output the hessian, which can be used to obtain confidence intervals in >many cases. > >hope this helps. spencer graves > >Marcel Vieira wrote: >>Dear R users, >> >>I am trying to minimise a function using "nlm". >> >>I am getting the following error message: "Error: function is too long to >>keep source" >> >>The function is really very long (about 100 A4 pages). >> >>Is there anything I could do to solve this problem? >> >>At the moment I am using "nlmin" in S-Plus with no problems but I'd prefer >>to use R. >> >>Thank you very much in advance. >> >>Regards. >>Marcel >> >>Marcel Vieira >>Social Statistics >>University of Southampton >> >>______________________________________________ >>R-help at stat.math.ethz.ch mailing list >>https://www.stat.math.ethz.ch/mailman/listinfo/r-help > >Marcel Vieira Social Statistics University of Southampton
On Thu, 4 Sep 2003, Marcel Vieira wrote:> Dear R users, > > I am trying to minimise a function using "nlm". > > I am getting the following error message: "Error: function is too long to > keep source" > > The function is really very long (about 100 A4 pages). > > Is there anything I could do to solve this problem?Assuming that the obvious solution (splitting up the function into pieces) doesn't work you can use options(keep.source=FALSE) to tell R not to store the source text in addition to the parsed code. The only disadvantage of this is that when you list the function source inside R there aren't any comments, but you don't want to do this with 100 pages of code anyway. -thomas