Nonlinear regression - how to fit a dose-response curve in R
TileStats TileStats
18K subscribers
3,001 views
0

 Published On Jun 5, 2023

https://www.tilestats.com/

R code
X=c(1e-9 , 1e-8 , 1e-7 , 1e-6 , 1e-5 , 1e-4 , 1e-3 , 1e-2) #Dose
Y=c(0, 3, 8, 19, 31, 38, 40, 41) #Response
df=data.frame(X,Y)
plot(X,Y,log="x",xlab="Dose (M)",ylab="Response")
bottom=0 # Fix bottom to zero
f1=Y~ bottom+(top-bottom)/(1+10^((logEC50-log10(X))*h))
nls(f1,data=df, start=list(logEC50=-6,h=1,top=42))
Plot
m1=nls(f1,data=df, start=list(logEC50=-6,h=1,top=42)) # Save output
logEC50=coef(m1)[1]
h=coef(m1)[2]
top=coef(m1)[3]
X1=seq(-9,-2,0.1) # X-data for the curve
y=bottom+(top-bottom)/(1+10^((logEC50-X1)*h)) # Y data
lines(10^X1,y,col="blue",lwd=2) # plot the curve

show more

Share/Embed