Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/82.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在R中的grotwth曲线中绘制渐近线_R_Math_Statistics - Fatal编程技术网

在R中的grotwth曲线中绘制渐近线

在R中的grotwth曲线中绘制渐近线,r,math,statistics,R,Math,Statistics,如何绘制上面这条曲线的渐近线 # Create Data Conc <- c(0.03125, 0.06250, 0.12500, 0.25000, 0.50000, 1.00000, 0.03125, 0.06250, 0.12500, 0.25000, 0.50000, 1.00000, 0.03125, 0.06250, 0.12500, 0.25000, 0.50000, 1.00000, 0.03125, 0.06250, 0.12500, 0.25000, 0.500

如何绘制上面这条曲线的渐近线

 # Create Data
    Conc <- c(0.03125, 0.06250, 0.12500, 0.25000, 0.50000, 1.00000, 0.03125, 0.06250, 0.12500, 0.25000, 0.50000, 1.00000, 0.03125, 0.06250, 0.12500, 0.25000, 0.50000, 1.00000, 0.03125, 0.06250, 0.12500, 0.25000, 0.50000, 1.00000, 0.03125, 0.06250, 0.12500, 0.25000, 0.50000, 1.00000, 0.03125, 0.06250, 0.12500, 0.25000, 0.50000, 1.00000)

    Response <- c(167.11246201, 53.96960486, 128.42857143, 43.67173252, 4.51975684, 0.34042553, 120.10334347, 101.14589666, 155.17629179, 35.31306991, 8.56534954, 1.71124620, 146.34954407, 108.50151976, 163.60182371, 64.70212766, 2.88145897, 0.50759878, 82.92401216, 109.80547112, 116.69300912, 26.85410334, 3.01519757, 0.37386018, 87.06990881, 84.82978723, 118.36474164, 27.52279635, 2.34650456, 0.10638298, 89.47720365, 109.47112462, 85.43161094, 17.69300912, 2.31306991, 0.07294833)

    df <- data.frame(Conc = Conc, Response = Response)

    #Make Modell
    library(drc)
    #adjust model
    drm <- drm(Response ~ Conc, data = df, fct = LL.4())
    #plot
    plot(drm)
#创建数据
Conc试试这个:

library(drc)

#adjust model
drm <- drm(Response ~ Conc, data = df, fct = LL.4())

#plot
plot(drm)
abline(a=112.6868 , 0)
库(drc)
#调整模型

drm您可以从
drm
对象中提取渐近线的值:

asymptote <- coef(drm)[3]

我不确定这里的正确方法是什么,但我通常是这样做的:

后勤职能 仍然不知道如何使用
LL.4()

flogis <- function(x, b, c, d, e){
  c + (d - c)/(1 + exp(b*(log(x) - log(e))))
}
绘图数据 (很抱歉,没有时间玩文本标签,也不明白示例图上的
phi2+phi3
是什么意思,但可以肯定的是,这是EC50周围发生的事情)


a=渐近线
b=0
尝试
abline
,不幸的是它不起作用,这就是mensage:abline中的错误(a=渐近线,b=0):找不到对象“渐近线”。对不起,我不清楚。我的意思是将渐近线的值分配给参数
a
。见下文
flogis <- function(x, b, c, d, e){
  c + (d - c)/(1 + exp(b*(log(x) - log(e))))
}
dose <- rep(exp(seq(-5, 5, length.out = 10)), each = 3)
dat <- data.frame(
  dose = dose,
  response = flogis(dose, -1, 0, 1, .5) + rnorm(length(dose), 0, .05)
)

head(dat)
#  dose   response
#1 0.006737947 0.01310683
#2 0.006737947 0.08292573
#3 0.006737947 0.03263079
#4 0.020468076 0.02763111
#5 0.020468076 0.01934260
#6 0.020468076 0.01296994
library(drc)

model <- drm(response ~ dose, data = dat, fct = LL.4())

summary(model)
#Model fitted: Log-logistic (ED50 as parameter) (4 parms)
#
#Parameter estimates:
#
#                Estimate Std. Error  t-value   p-value    
#b:(Intercept) -1.0012680  0.0887792 -11.2782 1.637e-11 ***
#c:(Intercept)  0.0049506  0.0243151   0.2036    0.8402    
#d:(Intercept)  0.9889417  0.0163848  60.3573 < 2.2e-16 ***
#e:(Intercept)  0.4054848  0.0419639   9.6627 4.310e-10 ***
#---
#Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#
#Residual standard error:
#
#0.04466107 (26 degrees of freedom)
coefs <- setNames(coef(model), c("b", "c", "d", "e"))
y50 <- predict(model, newdata = data.frame(dose = coefs["e"]))
ggplot(dat, aes(x = dose, y = response)) +
  stat_function(fun = function(x, b, c, d, e){
    c + (d - c)/(1 + exp(b*(log(x) - log(e))))
  }, args = coefs, col = "skyblue", lwd = 1) +
  geom_point(pch = 21, fill = "white") +
  geom_hline(yintercept = coefs[c("c", "d")], lty = 2, colour = "gray50") +
  geom_segment(aes(x = coefs["e"], y = 0, xend = coefs["e"], yend = y50), 
               lty = 2, colour = "gray50") +
  geom_segment(aes(x = coefs["e"], y = y50, xend = 0, yend = y50), 
               lty = 2, colour = "gray50") +
  scale_x_log10(
    breaks = scales::trans_breaks("log10", function(x) 10^x),
    labels = scales::trans_format("log10", scales::math_format(10^.x))
  ) +
  annotation_logticks(sides = "b") +
  labs(x = "Dose",
       y = "Response"
  ) +
  expand_limits(y = 1) +
  ggthemes::theme_few()