Elizabeth,

It's difficult to troubleshoot without the data.  Could you provide the
output from
     dput(FG2)
or if your data set is quite large, perhaps
     dput(FG2[1:50, ])

If you want to fit a third parameter to represent the base of the log, you
could use
     nls(CO2 ~ log(a*Time) / log(c) + b, start=c(a=68, b=400, c=10),
data=FG2)
where c represents the base of the log in this relation:
CO2 = log_c(a*Time) + b

Jean




On Mon, Jul 8, 2013 at 9:27 PM, Elizabeth Webb
<webb.elizabet...@gmail.com>wrote:

> Hi-
> I am trying to fit a log function to my data, with the ultimate goal of
> finding the second derivative of the function.  However, I am stalled on
> the first step of fitting a curve.
>
> When I use the following code:
> FG2.model<-(nls((CO2~log(a*Time)+b), start=setNames(coef(lm(CO2 ~
> log(Time), data=FG2)), c("a", "b")),data=FG2))
> I get the following error:
> Error in numericDeriv(form[[3L]], names(ind), env) :
>   Missing value or an infinity produced when evaluating the model
> In addition: Warning messages:
> 1: In min(x) : no non-missing arguments to min; returning Inf
> 2: In max(x) : no non-missing arguments to max; returning -Inf
> 3: In log(a * Time) : NaNs produced
> 4: In log(a * Time) : NaNs produced
>
> When I fit the curve in Plot and use the coefficients as starting values:
> start=c(a=68,b=400)
> FG2.model<-(nls((CO2~log(a*Time)+b), start=start,data=FG2))
> I get the following error:
> Error in nls((CO2 ~ log(a * Time) + b), start = start, data = FG2) :
>   singular gradient
> In addition: Warning messages:
> 1: In min(x) : no non-missing arguments to min; returning Inf
> 2: In max(x) : no non-missing arguments to max; returning -Inf
>
> So then when I substituded nlxb for nls in the above two models, I got this
> error:
> Error in nlxb((CO2 ~ log(a * Time) + b), start = start, data = FG2) :
>   NaN in Jacobian
>
>
> A few questions:
> 1.) How can I get R to fit my curve without returning errors?
>
> 2.) I am not sure that this data is log base 10.  Is there a way I can ask
> R to try for logs of different functions?  For example,
>
> FG2.model<-(nlxb((CO2~log(a*Time,c)+b), start=start,data=FG2)), where c is
> an additional variable.  When I try this, R tells me Non-numeric argument
> to mathematical function
>
> Thank you in advance,
> Elizabeth
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help@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.
>

        [[alternative HTML version deleted]]

______________________________________________
R-help@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.

Reply via email to