[R] non-linear plot parameters
Peter Ehlers
ehlers at ucalgary.ca
Fri Aug 27 11:51:56 CEST 2010
On 2010-08-26 15:52, Marlin Keith Cox wrote:
> I agree. I typically do not use non-linear functions, so am seeing the
> "art" in describing functions of non-linear plots. One last thing. I tried
> to use a self-starting Weibull function with the posted data and received
> the following error.
>
> model<-nls(Level~ SSweibull(Time,Asym,Drop,lrc,pwr))
> Error in qr.default(.swts * attr(rhs, "gradient")) :
> NA/NaN/Inf in foreign function call (arg 1)
>
> I do not understand the error statement.
The problem is the zeros in your independent variable (see
the definition of coefficient 'lrc'). You can try using
SSweibull(Time + 0.000001, ...). But a better way would
be to use
init <- getInitial(Level~ SSweibull(Time,Asym,Drop,lrc,pwr))
(which will often give the converged values). You can
follow up with
fm <- nls(Level ~ Asym-Drop*exp(-exp(lrc)*Time^pwr), start = init)
-Peter Ehlers
>
> kc
> On Thu, Aug 26, 2010 at 1:44 PM, Bert Gunter<gunter.berton at gene.com> wrote:
>
>> My opinions only below; consume at your own risk.
>>
>> On Thu, Aug 26, 2010 at 2:20 PM, Marlin Keith Cox<marlinkcox at gmail.com>
>> wrote:
>>> The background you requested are energetic level (joules) in a group of
>>> starved fish over a time period of 45 days. Weekly, fish (n=5) were
>> removed
>>> killed and measured for energy. This was done at three temperatures. I
>> am
>>> comparing the rates at which the fish consume stored body energy at each
>> of
>>> the three temperatures. Initial data looks like the colder fish
>>> have different rates (as would be expected) than do warmer fish. In all
>>> cases the slope is greatest at the beginning of the curve and flattens
>> after
>>> several weeks. This is what is interesting - where in time the line
>>> starts to flatten out.
>>>
>>> By calculating a non-linear equation of a line, I was hoping to use the
>>> first and second derivatives of the function to compare and explain
>>> differences between the three temperature.
>>
>> Bad idea. Derivatives from fitted curves are generally pretty
>> imprecisely determined. And you don't need them: If the curves are
>> being (adequately/appropriately) parameterized as Weibull, then all
>> the information is in the parameters anyway, which can be directly
>> modeled, fitted, and compared as functions of temperature -- provided
>> that the design permits this (i.e. provides sufficient precision for
>> the characterizations/comparisons).
>>
>> If you don't know how to do this, seek further statistical help.
>>
>> --
>> Bert Gunter
>> Genentech Nonclinical Statistics
>>
>>
>>>
>>> The data originally posted was an example of one of the curves
>> experienced.
>>>
>>> kc
>>>
>>> On Thu, Aug 26, 2010 at 9:48 AM, David Winsemius<dwinsemius at comcast.net
>>> wrote:
>>>
>>>>
>>>> On Aug 26, 2010, at 1:35 PM, Marlin Keith Cox wrote:
>>>>
>>>> I need the parameters estimated for a non-linear equation, an example
>> of
>>>>> the
>>>>> data is below.
>>>>>
>>>>>
>>>>> # rm(list=ls()) I really wish people would add comments to
>> destructive
>>>>> pieces of code.
>>>>>
>>>>
>>>> Time<-c( 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4,
>>>>> 4, 4, 5, 5, 5, 5, 5, 8, 8, 8, 8, 8)
>>>>> Level<-c( 100, 110, 90, 95, 87, 60, 65, 61, 55, 57, 40, 41,
>> 50,
>>>>> 47,
>>>>> 44, 44, 42, 38, 40, 37, 37, 35, 40, 34, 32, 20, 22, 25,
>> 27,
>>>>> 29)
>>>>> plot(Time,Level,pch=16)
>>>>>
>>>>
>>>> You did not say what sort of "non-linear equation" would best suit, nor
>> did
>>>> you offer any background regarding the domain of study. There must be
>> many
>>>> ways to do this. After looking at the data, a first pass looks like
>> this:
>>>>
>>>>> lm(log(Level) ~Time )
>>>>
>>>> Call:
>>>> lm(formula = log(Level) ~ Time)
>>>>
>>>> Coefficients:
>>>> (Intercept) Time
>>>> 4.4294 -0.1673
>>>>
>>>>> exp(4.4294)
>>>> [1] 83.88107
>>>>> points(unique(Time), exp(4.4294 -unique(Time)*0.1673), col="red",
>> pch=4)
>>>>
>>>> Maybe a Weibull model would be more appropriate.
>>>>
>>>>
>>>> --
>>>>
>>>> David Winsemius, MD
>>>> West Hartford, CT
>>>>
>>>>
>>>
>>>
>>
>>> [[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<http://www.r-project.org/posting-guide.html>
>>> and provide commented, minimal, self-contained, reproducible code.
>>>
>>
>>
>>
>> --
>> Bert Gunter
>> Genentech Nonclinical Biostatistics
>> 467-7374
>> http://devo.gene.com/groups/devo/depts/ncb/home.shtml
>>
>
>
More information about the R-help
mailing list