Sigmoid curve corresponding to R

I'm new to R, and I'm trying to fit a curve onto a dataset, which (for example) might look like this:

(x- value)  (y-value)
105 423
115 471
125 567
135 808
145 921.5
155 1040

The x value represents the number of stimuli, and the y values ​​represent motor responses (in uV). These are the average values ​​for 10 subjects, where the x values ​​are the same for each object.

I was told that this dataset usually follows a sigmoidal fit. I tried installing it with the following:

fit <- lm( y ~ poly(x, 3) )

But I'm not sure if this is a suitable way to do this :(

My code looks like this:

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

Optional: as soon as I fit the curve, I would also like to get a slope (calculated as the value of the tangent at the steepest point of the curve)

Thanks in advance, any help would be greatly appreciated!

+4
1

, poly(), , :

   lm1=lm(y~I(x^3)+I(x^2)+x)

. . x. x.

, .

+1

All Articles