I'm tyring to fit a relatively simple nls model to some data, but keep coming up against the same error (code follows): Oto=nls(Otolith ~ Linf*(1-exp(-k(AGE-to))), data = ages, start = list(Linf=1000, k=0.1, to=0.1), trace = TRUE) The error message I keep getting is "Error in eval(expr, envir, enclos) : could not find function "k"". I've used this line of code for other nls models (with different data, parameter estimates, etc.), but have never gotten this error. The data is AGE,Otolith,Scale 1,207.1052632,207.1052632 2,329.962963,332.7586207 3,401.9473684,406 4,422,413.1111111 5,452.6785714,458.34375 6,510.75,533 7,477,674 8,643,704 9,,615 10,695.5, 12,615, Are the missing values (e.g., no value for Otolith, AGE 9) having an effect? I am using Tinn-R as an editor I'm new to R, trying to get away from Rcmdr (though it has been helpful), and still trying to learn the language with the aid of several books on the R. A search of the R Archive did not prove fruitful. Thanks in advance, SR Steven H. Ranney Graduate Research Assistant (Ph.D) USGS Montana Cooperative Fishery Research Unit Montana State University PO Box 173460 Bozeman, MT 59717-3460 phone: (406) 994-6643 fax: (406) 994-7479 [[alternative HTML version deleted]]
On Tue, 2008-06-10 at 16:56 -0600, Ranney, Steven wrote:> I'm tyring to fit a relatively simple nls model to some data, but keep coming up against the same error (code follows): > > Oto=nls(Otolith ~ Linf*(1-exp(-k(AGE-to))), > data = ages, > start = list(Linf=1000, k=0.1, to=0.1), > trace = TRUE)Try putting a * in after the k in the formula. Simon.> > The error message I keep getting is "Error in eval(expr, envir, enclos) : could not find function "k"". I've used this line of code for other nls models (with different data, parameter estimates, etc.), but have never gotten this error. The data is > > AGE,Otolith,Scale > 1,207.1052632,207.1052632 > 2,329.962963,332.7586207 > 3,401.9473684,406 > 4,422,413.1111111 > 5,452.6785714,458.34375 > 6,510.75,533 > 7,477,674 > 8,643,704 > 9,,615 > 10,695.5, > 12,615, > > Are the missing values (e.g., no value for Otolith, AGE 9) having an effect? I am using Tinn-R as an editor > > I'm new to R, trying to get away from Rcmdr (though it has been helpful), and still trying to learn the language with the aid of several books on the R. A search of the R Archive did not prove fruitful. > > Thanks in advance, > > SR > > Steven H. Ranney > Graduate Research Assistant (Ph.D) > USGS Montana Cooperative Fishery Research Unit > Montana State University > PO Box 173460 > Bozeman, MT 59717-3460 > > phone: (406) 994-6643 > fax: (406) 994-7479 > > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.-- Simon Blomberg, BSc (Hons), PhD, MAppStat. Lecturer and Consultant Statistician Faculty of Biological and Chemical Sciences The University of Queensland St. Lucia Queensland 4072 Australia Room 320 Goddard Building (8) T: +61 7 3365 2506 http://www.uq.edu.au/~uqsblomb email: S.Blomberg1_at_uq.edu.au Policies: 1. I will NOT analyse your data for you. 2. Your deadline is your problem. The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data. - John Tukey.
Hi On 11/06/2008 at 10:56 a.m., "Ranney, Steven" <steven.ranney at montana.edu> wrote:> I'm tyring to fit a relatively simple nls model to some data, but keep coming > up against the same error (code follows): > > Oto=nls(Otolith ~ Linf*(1-exp(-k(AGE-to))), > data = ages, > start = list(Linf=1000, k=0.1, to=0.1), > trace = TRUE) > > The error message I keep getting is "Error in eval(expr, envir, enclos) : > could not find function "k"". I've used this line of code for other nls > models (with different data, parameter estimates, etc.), but have never > gotten this error. The data is > > AGE,Otolith,Scale > 1,207.1052632,207.1052632 > 2,329.962963,332.7586207 > 3,401.9473684,406 > 4,422,413.1111111 > 5,452.6785714,458.34375 > 6,510.75,533 > 7,477,674 > 8,643,704 > 9,,615 > 10,695.5, > 12,615, > > Are the missing values (e.g., no value for Otolith, AGE 9) having an effect? > I am using Tinn-R as an editor > > I'm new to R, trying to get away from Rcmdr (though it has been helpful), > and still trying to learn the language with the aid of several books on the > R. A search of the R Archive did not prove fruitful. > > Thanks in advance, > > SR > > Steven H. RanneyYou've made a typo. Check out the formula you passed to nls -- you forget to include a "*" after k. What I think you want is something like Oto <- nls(Otolith ~ Linf * (1 - exp(-k * (AGE - t0) ) ), ...) Cheers, Michael -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: michael_manning.vcf URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20080611/a98be3b9/attachment.pl>
Hi r-help-bounces at r-project.org napsal dne 11.06.2008 00:56:19:> I'm tyring to fit a relatively simple nls model to some data, but keepcoming> up against the same error (code follows): > > Oto=nls(Otolith ~ Linf*(1-exp(-k(AGE-to))), > data = ages, > start = list(Linf=1000, k=0.1, to=0.1), > trace = TRUE) > > The error message I keep getting is "Error in eval(expr, envir, enclos):> could not find function "k"". I've used this line of code for other nls> models (with different data, parameter estimates, etc.), but have nevergotten> this error. The data isDoes Oto=nls(Otolith ~ Linf*(1-exp(-k*(AGE-to))), data = ages, start = list(Linf=1000, k=0.1, to=0.1), trace = TRUE) help? Regards Petr> > AGE,Otolith,Scale > 1,207.1052632,207.1052632 > 2,329.962963,332.7586207 > 3,401.9473684,406 > 4,422,413.1111111 > 5,452.6785714,458.34375 > 6,510.75,533 > 7,477,674 > 8,643,704 > 9,,615 > 10,695.5, > 12,615, > > Are the missing values (e.g., no value for Otolith, AGE 9) having aneffect?> I am using Tinn-R as an editor > > I'm new to R, trying to get away from Rcmdr (though it has beenhelpful), and> still trying to learn the language with the aid of several books on theR. A> search of the R Archive did not prove fruitful. > > Thanks in advance, > > SR > > Steven H. Ranney > Graduate Research Assistant (Ph.D) > USGS Montana Cooperative Fishery Research Unit > Montana State University > PO Box 173460 > Bozeman, MT 59717-3460 > > phone: (406) 994-6643 > fax: (406) 994-7479 > > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html> and provide commented, minimal, self-contained, reproducible code.