1

enter image description here

This plot means drugs Concentration.

And I want to change this plot like sigmoid plot which is a curve.

[raw data]

μM <- c(0.01, 0.03, 0.1, 0.3, 1, 3, 10, 30)
log_μM <- log(c(0.01, 0.03, 0.1, 0.3, 1, 3, 10, 30))
DMSO <- c(97.01, 98.43, 98.29, 97.66, 96.51, 88.39, 38.54, 2.63) # D137
log_DMSO <- log(c(97.01, 98.43, 98.29, 97.66, 96.51, 88.39, 38.54, 2.63))

The raw data is small, but I want to express it well, and get the R-Square value.

  • I believe there are two issues with your request. First, your data isn't a true binary, so you can't fit a logistic regression curve like the sigmoid function, only some type of nonlinear regression. The other issue is with R2. Given this has a nonlinear function, which R2 are you looking for? – Shawn Hemelstrand Nov 17 '22 at 00:07
  • I want to find an equation that is most similar to the data. If it's not sigmoid, I want to draw a plot like an exponential function, and I want to find the R-Square value to see if the green plot and data are similar. Is it impossible because the data is too small? – JeongSoo Na Nov 17 '22 at 00:27
  • Green plot? I only see a red plot here. – Shawn Hemelstrand Nov 17 '22 at 00:49
  • Oh, There was a translation problem. Not green plot, It's drawed plot. sorry for my english – JeongSoo Na Nov 17 '22 at 01:10

1 Answers1

2

On the original (not log-log) scale, a sigmoid curve turns out to be a good fit.

## pack data into a data frame (best practice)
dd <- data.frame(μM, DMSO)
## fit with "self-starting 4-parameter logistic model"
fit <- nls(DMSO ~ SSfpl(μM, l_asy, r_asy, xmid, scal), data = dd)
## plot:
par(las = 1, bty = "l") ## cosmetic
plot(DMSO ~ μM, data = dd)  ## points
mvec <- seq(min(μM), max(μM), length.out = 101)
pvec <-predict(fit, newdata = data.frame(μM = mvec))
lines(mvec, pvec)

enter image description here

If you want to plot this on a log-log scale, just add log = "xy" to the plot() command, but note that the plot won't look sigmoidal:

enter image description here

The ?SSfpl web page gives the equation

l_asy+(r_asy-l_asy)/(1+exp((xmid-μM)/scal))

coef(fit) will give you the estimated coefficients.

As for R^2: you can calculate an R^2 value via 1-mean(residuals(fit)^2)/var(μM) (I think — the second term might be off by factor of n/(n-1) or so because var() uses n-1 in the denominator ...) but there's lots of discussion (which you should read!) about why you might not want to/why it might not mean what you think it means ...

PS: it's a nuisance to have a variable name (μM) that can't easily be typed on a plain keyboard — might want to reconsider that choice ...

Ben Bolker
  • 211,554
  • 25
  • 370
  • 453