Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/66.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 如何在我的ggplot上绘制逻辑增长曲线_R_Ggplot2 - Fatal编程技术网

R 如何在我的ggplot上绘制逻辑增长曲线

R 如何在我的ggplot上绘制逻辑增长曲线,r,ggplot2,R,Ggplot2,我有一些数据看起来像逻辑增长曲线。我可以用geom_平滑在上面画一条黄土曲线,但我想拟合一条合适的逻辑曲线 data <- data.frame(conc = c(10, 1, 0.1, 0.01, 0.001, 1e-04, 1e-05, 1e-06, 1e-07, 1e-08, 1e-09, 10, 1, 0.1, 0.01, 0.001, 1e-04, 1e-05, 1e-06, 1e-07, 1e-08,

我有一些数据看起来像逻辑增长曲线。我可以用geom_平滑在上面画一条黄土曲线,但我想拟合一条合适的逻辑曲线

data <- data.frame(conc = c(10, 1, 0.1, 0.01, 0.001, 1e-04, 1e-05, 1e-06, 1e-07, 1e-08, 
                            1e-09, 10, 1, 0.1, 0.01, 0.001, 1e-04, 1e-05, 1e-06, 1e-07, 1e-08, 
                            1e-09, 10, 1, 0.1, 0.01, 0.001, 1e-04, 1e-05, 1e-06, 1e-08, 1e-09, 
                            10, 1, 0.1, 0.01, 0.001, 1e-04, 1e-05, 1e-06, 1e-08, 1e-09, 1e-10),
                   value = c(22832, 26910, 9303, 4128, 521, 44, 64, 31, 50, 39, 284, 19993, 
                             24205, 9230, 4030, 447, 42, 51, 175, 38, 35, 161, 23072, 27382, 
                             7036, 2416, 320, 58, 30, 37, 40, 110, 26630, 28568, 6262, 2854, 
                             314, 102, 50, 39, 34, 77, 30))
ggplot(data, aes(x=conc, y=value)) +
  geom_point() +
  geom_smooth() +
  scale_x_continuous(trans = 'log10')
数据类似的东西

ggplot(data, aes(x=conc, y=value/max(value))) +
  geom_point() +
  # geom_smooth() +
  # scale_x_continuous(trans = 'log10')
  stat_smooth(formula = "y ~ x", method = "glm", 
              method.args = list(family="quasibinomial"), se = T) +
  scale_y_continuous(labels = function(x) x * max(data$value))
像这样的东西

ggplot(data, aes(x=conc, y=value/max(value))) +
  geom_point() +
  # geom_smooth() +
  # scale_x_continuous(trans = 'log10')
  stat_smooth(formula = "y ~ x", method = "glm", 
              method.args = list(family="quasibinomial"), se = T) +
  scale_y_continuous(labels = function(x) x * max(data$value))

要拟合四参数逻辑曲线,可以执行以下操作:

library(ggplot2)
library(nlme)

ggplot(data, aes(x=conc, y=value)) +
  geom_point() +
  geom_smooth(
    method = "nls", formula = y ~ SSfpl(log(x), A, B, xmid, scal),
    se = FALSE
  ) 
但是你的数据有一个奇异的梯度,因此产生了一个误差。如果符合
值的对数

ggplot(data, aes(x=conc, y=log(value))) +
  geom_point() +
  geom_smooth(
    method = "nls", formula = y ~ SSfpl(log(x), A, B, xmid, scal),
    se = FALSE
  ) 

要拟合四参数逻辑曲线,可以执行以下操作:

library(ggplot2)
library(nlme)

ggplot(data, aes(x=conc, y=value)) +
  geom_point() +
  geom_smooth(
    method = "nls", formula = y ~ SSfpl(log(x), A, B, xmid, scal),
    se = FALSE
  ) 
但是你的数据有一个奇异的梯度,因此产生了一个误差。如果符合
值的对数

ggplot(data, aes(x=conc, y=log(value))) +
  geom_point() +
  geom_smooth(
    method = "nls", formula = y ~ SSfpl(log(x), A, B, xmid, scal),
    se = FALSE
  ) 

太好了,这是正确的。但是,是否可以保留y轴,而不必使值介于0-1之间?@Mike Updated。看看,太好了,这是正确的。但是,是否可以保留y轴,而不必使值介于0-1之间?@Mike Updated。过来看。