[R] How to fit a Hill model using braidrm package?

varin sacha v@r|n@@ch@ @end|ng |rom y@hoo@|r
Thu Sep 25 16:21:13 CEST 2025


Hi,


the drc package provides a Hill function. You could try this : 



library(drc)

# Fit Hill function

hill_mod <- drm(

  Response ~ Dose,

  data = df,

  fct = hill(names = c("Top", "Bottom", "Kd", "nH"))

)

summary(hill_mod)

# Plot (log-scale on x-axis)

plot(hill_mod, log = "x")





The 4 parameters are:

Top : max response at low dose
Bottom : min response at high dose
Kd : inflection point
nH : Hill slope 
Your data has Response ≈ 895 at low Dose and goes down to ≈ 850 at high Dose, so the Hill curve must be decreasing.

That means:

Top ≈ 895 
Bottom ≈ 850 
Kd ≈ midpoint dose (where Response ≈ halfway between 895 and 850 : ~872). Looking at your doses, this is around 10^{-6}.
nH ≈ slope (start with 1, adjust later)


Using your data

library(drc)

# Your data
df = data.frame(
  Response = c(890.72, 890.94, 880.16, 895.46, 890.8, 884.15,
               895.63, 887.22, 879.57, 894.72, 888.91, 878.89,
               895.49, 890.83, 882.27, 893.59, 889.92, 881.59,
               892.53, 891.76, 880.98, 895.06, 890.32, 881.45,
               897.21, 886.35, 876.19, 889.27, 878.11, 868.32,
               876.05, 866.57, 859.16, 850.53, 857.96, 859.34,
               862.02, 859.04, 859.73, 858.36, 863.64, 861.19),
  Dose = c(0.0000000015, 0.0000000015, 0.0000000015, 0.000000003,
           0.000000003, 0.000000003, 0.000000006, 0.000000006,
           0.000000006, 0.000000012, 0.000000012, 0.000000012,
           0.000000024, 0.000000024, 0.000000024, 0.000000048,
           0.000000048, 0.000000048, 0.000000095, 0.000000095,
           0.000000095, 0.00000018, 0.00000018, 0.00000018,
           0.00000038, 0.00000038, 0.00000038, 0.00000078,
           0.00000078, 0.00000078, 0.0000015, 0.0000015,
           0.0000015, 0.000007, 0.000007, 0.000007,
           0.000025, 0.000025, 0.000025, 0.00005, 0.00005, 0.00005)
)

# Fit Hill function with starting values
hill_mod <- drm(
  Response ~ Dose,
  data = df,
  fct = hill(names = c("Top", "Bottom", "Kd", "nH")),
  start = c(Top = 895, Bottom = 850, Kd = 1e-6, nH = 1)
)

summary(hill_mod)

# Plot fit on log-scale x-axis
plot(hill_mod, log = "x", ylim = c(840, 900))



Then, you can extract the fitted parameters (including Kd and nH) directly.



# Coefficients (parameter estimates)

coef(hill_mod)



# More detailed summary with SEs and p-values

summary(hill_mod)



# Confidence intervals for parameters

confint(hill_mod)



# Extract just the estimated Kd (dissociation constant)

Kd_est <- coef(hill_mod)["Kd:(Intercept)"]



# Extract Hill slope (nH)

nH_est <- coef(hill_mod)["nH:(Intercept)"]

Kd_est

nH_est



Best,






> Le 25 sept. 2025 à 13:41, Luigi Marongiu <marongiu.luigi using gmail.com> a écrit :
> 
> Hello,
> it was an assembler problem of the machine. I now managed to install
> the package, I tried to fit a 4 or 5 parameters model but the fitting
> is not good:
> 
> ```
> df = data.frame(Response =    c(890.72,    890.94,    880.16,
> 895.46,    890.8,    884.15,
>                             895.63,    887.22,    879.57,    894.72,
>  888.91,    878.89,
>                             895.49,    890.83,    882.27,    893.59,
>  889.92,    881.59,
>                             892.53,    891.76,    880.98,    895.06,
>  890.32,    881.45,
>                             897.21,    886.35,    876.19,    889.27,
>  878.11,    868.32,
>                             876.05,    866.57,    859.16,    850.53,
>  857.96,    859.34,
>                             862.02,    859.04,    859.73,    858.36,
>  863.64,    861.19),
>                Dose =    c(0.0000000015,    0.0000000015,
> 0.0000000015,    0.000000003,
>                         0.000000003,    0.000000003,    0.000000006,
>  0.000000006,
>                         0.000000006,    0.000000012,    0.000000012,
>  0.000000012,
>                         0.000000024,    0.000000024,    0.000000024,
>  0.000000048,
>                         0.000000048,    0.000000048,    0.000000095,
>  0.000000095,
>                         0.000000095,    0.00000018,    0.00000018,
> 0.00000018,    0.00000038,
>                         0.00000038,    0.00000038,    0.00000078,
> 0.00000078,    0.00000078,
>                         0.0000015,    0.0000015,    0.0000015,
> 0.000007,    0.000007,
>                         0.000007,    0.000025,    0.000025,
> 0.000025,    0.00005,    0.00005,    0.00005)
> )
> plot(Response~log10(Dose), df)
> library(drc)
> mod = drm(Response~Dose, data = df, fct=L.4())
> plot(mod)
> ```
> How can I set a Hill function with `drm`?
> Thank you
> 
>> On Thu, Sep 25, 2025 at 1:01 PM varin sacha <varinsacha using yahoo.fr> wrote:
>> 
>> Hi,
>> 
>> What about directly calling the model function with basicdrm library ?
>> 
>> library(basicdrm)
>> 
>> # Fit Hill model
>> m <- drm(Response ~ Dose, data = df, fct = hillfct())
>> 
>> summary(m)
>> 
>> # Predict & plot
>> plot(m, log = "x")
>> 
>> Best,
>> SV
>> 
>>>> Le 25 sept. 2025 à 10:12, varin sacha via R-help <r-help using r-project.org> a écrit :
>>> 
>>> 
>>> Hi,
>>> Could you paste me the exact error message you’re getting when trying install.packages("drc")
>>> 
>>> 
>>>> Le 25 sept. 2025 à 09:02, Luigi Marongiu <marongiu.luigi using gmail.com> a écrit :
>>>> 
>>>> I got the same errors:
>>>> ```
>>>>> library(basicdrm)
>>>>> findBestHill(Response~Dose, df)
>>>> Error in findBestHill(Response ~ Dose, df) :
>>>> could not find function "findBestHill"
>>>>> evalHillEqn(Response~Dose, df)
>>>> Error in evalHillEqn(Response ~ Dose, df) :
>>>> could not find function "evalHillEqn"
>>>> ```
>>>> 
>>>>>> On Wed, Sep 24, 2025 at 1:47 PM peter dalgaard <pdalgd using gmail.com> wrote:
>>>>> 
>>>>> They're in basicdrm, not braidrm...
>>>>> 
>>>>> -pd
>>>>> 
>>>>>>> On 24 Sep 2025, at 11:52 , Luigi Marongiu <marongiu.luigi using gmail.com> wrote:
>>>>>> 
>>>>>> Hello,
>>>>>> I have a set of data coming from a dissociation experiment
>>>>>> (protein/ligand). Since the data is required to calculate the constant
>>>>>> of dissociation (Kd) of this pair, I am looking for a way of fitting a
>>>>>> Hill function to the data.
>>>>>> I have seen that the package braidrm
>>>>>> (https://cran.r-project.org/web/packages/braidrm/index.html) provides
>>>>>> this function, but when I launch the function `evalHillEqn`,
>>>>>> `findBestHill` and so forth I get the error of function not found.
>>>>>> Yet, the package is given as properly installed by the system.
>>>>>> How can I run this package?
>>>>>> Is there an alternative way to fit a Hill function to these data?
>>>>>> Thank you
>>>>>> 
>>>>>> ```
>>>>>> df = data.frame(Response =    c(890.72,    895.46,    895.63,
>>>>>> 894.72,    895.49,    893.59,
>>>>>>             892.53,    895.06,    897.21,    889.27,    876.05,
>>>>>> 857.96,    862.02,    858.36,
>>>>>>             890.94,    890.8,    887.22,    888.91,    890.83,
>>>>>> 889.92,    891.76,    890.32,
>>>>>>             886.35,    878.11,    866.57,    859.04,    863.64,
>>>>>> 880.16,    884.15,    879.57,
>>>>>>             878.89,    882.27,    881.59,    880.98,    881.45,
>>>>>> 876.19,    868.32,    859.16,
>>>>>>             850.53,    853.21,    859.34,    859.73,    861.19),
>>>>>>             Dose =    c(0.0000000015,    0.000000003,
>>>>>> 0.000000006,    0.000000012,
>>>>>>                    0.000000024,    0.000000048,    0.000000095,
>>>>>> 0.00000018,
>>>>>>                    0.00000038,    0.00000078,    0.0000015,
>>>>>> 0.000013,    0.000025,
>>>>>>                    0.00005,    0.0000000015,    0.000000003,
>>>>>> 0.000000006,
>>>>>>                    0.000000012,    0.000000024,    0.000000048,
>>>>>> 0.000000095,
>>>>>>                    0.00000018,    0.00000038,    0.00000078,
>>>>>> 0.0000015,    0.000025,
>>>>>>                    0.00005,    0.0000000015,    0.000000003,
>>>>>> 0.000000006,
>>>>>>                    0.000000012,    0.000000024,    0.000000048,
>>>>>> 0.000000095,
>>>>>>                    0.00000018,    0.00000038,    0.00000078,
>>>>>> 0.0000015,    0.000003,
>>>>>>                    0.000006,    0.000013,    0.000025,    0.00005)
>>>>>> )
>>>>>> plot(Response~log10(Dose), df)
>>>>>> library(braidrm)
>>>>>> evalHillEqn(Response~Dose, df)
>>>>>> findBestHill(Response~Dose, df)
>>>>>> ```
>>>>>> 
>>>>>> ______________________________________________
>>>>>> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
>>>>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>>>>> PLEASE do read the posting guide https://www.R-project.org/posting-guide.html
>>>>>> and provide commented, minimal, self-contained, reproducible code.
>>>>> 
>>>>> --
>>>>> Peter Dalgaard, Professor,
>>>>> Center for Statistics, Copenhagen Business School
>>>>> Solbjerg Plads 3, 2000 Frederiksberg, Denmark
>>>>> Phone: (+45)38153501
>>>>> Office: A 4.23
>>>>> Email: pd.mes using cbs.dk  Priv: PDalgd using gmail.com
>>>>> 
>>>> 
>>>> 
>>>> --
>>>> Best regards,
>>>> Luigi
>>>> 
>>>> ______________________________________________
>>>> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
>>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>>> PLEASE do read the posting guide https://www.R-project.org/posting-guide.html
>>>> and provide commented, minimal, self-contained, reproducible code.
>>> 
>>>   [[alternative HTML version deleted]]
>>> 
>>> ______________________________________________
>>> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>> PLEASE do read the posting guide https://www.R-project.org/posting-guide.html
>>> and provide commented, minimal, self-contained, reproducible code.
>> 
> 
> 
> --
> Best regards,
> Luigi

	[[alternative HTML version deleted]]



More information about the R-help mailing list