[R] modelling 4-parameter curve in R does not match data - how to proceed?

Duncan Murdoch murdoch@dunc@n @end|ng |rom gm@||@com
Wed Mar 17 20:58:21 CET 2021


On 17/03/2021 12:37 p.m., Luigi Marongiu wrote:
> sorry, I don't get it...

Modify your rutledge function to print x, and you'll see the values of 
high printed.  x should be 1:45.

Duncan Murdoch

> 
> On Wed, Mar 17, 2021 at 2:35 PM Duncan Murdoch <murdoch.duncan using gmail.com> wrote:
>>
>> On 17/03/2021 6:59 a.m., Luigi Marongiu wrote:
>>> yes, but in `rutledge` I model y as `y = (M / ( 1 + exp(-(x-m)/s)) ) +
>>> B`, with x being 1:45. Isn't that the equivalent of what I fed Desmos
>>> with? Tx
>>
>> No, it's not.
>>
>> Duncan Murdoch
>>
>>>
>>> On Wed, Mar 17, 2021 at 11:31 AM Duncan Murdoch
>>> <murdoch.duncan using gmail.com> wrote:
>>>>
>>>> On 17/03/2021 5:41 a.m., Luigi Marongiu wrote:
>>>>> Hello,
>>>>> I have a dataset from a polymerase chain reaction. I am using the
>>>>> equation given by Rutledge
>>>>> (https://pubmed.ncbi.nlm.nih.gov/15601990/) but the profile I get in R
>>>>> does not match the data. I ran the same thing in Desmos and instead
>>>>> the profile is correct (attached).
>>>>> Why do I not get the same matching model as in Desmos? I believe the
>>>>> formula in R is the same as the one in Desmos, and I am using the same
>>>>> parameters.
>>>>> Is there a procedure to debug models?
>>>>> Thanks
>>>>>
>>>>> Here is the code:
>>>>> ```
>>>>> high <- c(120.64, 66.14, 34.87, 27.11, 8.87, -5.8, 4.52, -7.16, -17.39,
>>>>>           -14.29, -20.26, -14.99, -21.05, -20.64, -8.03, -21.56, -1.28, 15.01,
>>>>>           75.26, 191.76, 455.09, 985.96, 1825.59, 2908.08, 3993.18, 5059.94,
>>>>>           6071.93, 6986.32, 7796.01, 8502.25, 9111.46, 9638.01, 10077.19,
>>>>>           10452.02, 10751.81, 11017.49, 11240.37, 11427.47, 11570.07, 11684.96,
>>>>>           11781.77, 11863.35, 11927.44, 11980.81, 12021.88)
>>>>> plot(1:45, high, type = "l")
>>>>> rutledge <- function(p, x) {
>>>>>      m = p$half_fluorescence
>>>>>      s = p$slope
>>>>>      M = p$max_fluorescence
>>>>>      B = p$back_fluorescence
>>>>>      y = (M / ( 1 + exp(-(x-m)/s)) ) + B
>>>>>      return(y)
>>>>> }
>>>>> desmos <- rutledge(list(half_fluorescence = 27.1102, slope = 2.76798,
>>>>>                            max_fluorescence = 11839.8, back_fluorescence
>>>>> = -138.864) , high)
>>>>>
>>>>> points(1:45, desmos, type="l", col="blue")
>>>>
>>>>
>>>> In your calculation of desmos, you are using the Y variable for x in the
>>>> formula.  Calculate it this way instead:
>>>>
>>>> desmos <- rutledge(list(half_fluorescence = 27.1102, slope = 2.76798,
>>>>                              max_fluorescence = 11839.8, back_fluorescence
>>>>     = -138.864) , 1:45)
>>>>
>>>> Duncan Murdoch
>>>>
>>>
>>>
>>
> 
>



More information about the R-help mailing list