1

I would like to plot a smooth titration curve with empirical values in R. Unfortunately, I was not able to calculate the point of inflection of the curve where the equivalence point is located.
Do you have any ideas on how I can do this?

par(mfrow=c(1, 1))

vtit <- c(7.05, 9.00, 11.10, 13.00, 15.00, 17.00, 18.05, 18.95, 20.00, 21.00,
          21.95, 23.05, 24.00, 25.05, 26.00, 28.10, 30.00, 33.05, 36.10, 39.05,
          41.10, 42.10, 42.55, 43.15, 44.99)
vtit. <- vtit - 7.05

pH <- c(2.99, 3.48, 3.82, 4.02, 4.18, 4.30, 4.37, 4.42, 4.45, 4.51, 4.57, 4.64,
        4.67, 4.74, 4.79, 4.86, 4.99, 5.18, 5.42, 5.77, 6.33, 9.01, 10.62,
        11.06, 11.39)

plot(vtit., pH, type="o", lwd=2, main="Titration of acetic acid with 0.86M NaOH",
     cex.main=0.8, xlab=expression(italic(V[NaOH])), ylab=expression(pH))

model <- lm(pH ~ poly(vtit.,17))
pHcurve <- predict(model)
lines(vtit., pHcurve, col='green', lwd=2)

abline(v=34.9, lty=2)

enter image description here

Dave2e
  • 22,192
  • 18
  • 42
  • 50
Rolu Rostl
  • 11
  • 2

1 Answers1

0

One option is to try the approx() function in order to attempt a reasonable smoothing of the curve. In the code below I am using 200 points, you may want to try increasing or decreasing this value to see how the results may change.
For this example this method works reasonably well,

plot(vtit., pH, type="o", lwd=2, main="Titration of acetic acid with 0.86M NaOH",
     cex.main=0.8, xlab=expression(italic(V[NaOH])), ylab=expression(pH))

#use the approx function
#plot(approx(vtit., pH, n=200))
app<-approx(vtit., pH, n=200)

#calculate the slope
slope <- (app$y-lag(app$y))/(app$x-lag(app$x))     
#find the titration point with max slope
equ_pt <- app$x[which.max(slope)]

#plot initial estimate aganist found point
abline(v=34.9, lty=2)
abline(v=equ_pt, lty=2, col="red")

Here is the original chart with the initial estimate and the current estimate in red.

enter image description here

Dave2e
  • 22,192
  • 18
  • 42
  • 50