我是 R 的初学者,我正在尝试将曲线拟合到(例如)可能如下所示的数据集:
(x- value) (y-value)
105 423
115 471
125 567
135 808
145 921.5
155 1040
x 值代表刺激量,y 值代表运动反应(单位为 uV)。这些是 10 个科目的平均值,其中每个科目的 x 值相同。
有人告诉我,这个数据集通常遵循 sigmoidal 拟合。我尝试使用以下内容对其进行安装:
fit <- lm( y ~ poly(x, 3) )
但我不确定这是否是合适的方法:(
到目前为止,我的代码如下所示:
p <- ggplot (data, aes(x, y)) +
geom_point(shape= 21, fill= "blue", colour= "black", size=2) +
xlab("X value") + ylab("Y value") +
geom_smooth(method= "lm", se= FALSE, colour= "red", formula=y ~ poly(x, 3, raw=TRUE)) +
geom_errorbar(aes(ymin=y-SE, ymax=y+SE), width=.9)+
ggtitle ("Title")
p
另外:一旦我拟合了曲线,我还想获得斜率(计算为曲线最陡点处的切线值)
在此先感谢,任何帮助将不胜感激!