Dear R-Helpers, I'm working with immunoassay data and 5PL logistic model. I wanted to experiment with different forms of weighting and parameter selection, which is not possible in instrument software, so I turned to R. I am using R 2.14.2 under Win7 64bit, and the 'nls' library to fit the model - I started with the same model and weighting type (1/y) as in the instrument to see if I'll get similar results. However, in some instances I don't get any results - just errors. Here is an example calibration data, representative of my experiment. Instrument soft had no problem fitting it: x <- structure(list(SPL = structure(c(1L, 1L, 2L, 2L, 3L, 3L, 4L, 4L, 5L, 5L, 6L, 6L, 7L, 7L), .Label = c("St1", "St2", "St3", "St4", "St5", "St6", "St7"), class = "factor"), MFI = c(10755.5, 9839, 5142.5, 4857, 1510.5, 1505, 502.5, 451, 215, 195.5, 58, 57, 15, 15), nom = c(206, 206, 125, 125, 68, 68, 38, 38, 24, 24, 13, 13, 6.5, 6.5), weights = c(0.0013946353028683, 0.00152454517735542, 0.00291686922702965, 0.00308832612723904, 0.0099304865938431, 0.00996677740863787, 0.0298507462686567, 0.0332594235033259, 0.0697674418604651, 0.0767263427109974, 0.258620689655172, 0.263157894736842, 1, 1)), .Names = c("SPL", "MFI", "nom", "weights"), row.names = c(NA, -14L), class = "data.frame") And here is the nls fit: fit <- nls(MFI~a + b/((1+(nom/c)^d)^f), data=x, weights=x$weights, start=c(a=100, b=10000, c=100, d=-1, f=1)) I've tried every possible combination of starting values, including the values fitted by the instrument soft - to no avail. I've probably seen all possible error messages from 'nls' trying to fit this. If anyone has an idea why it's not working - let me know. Best regards, -- Michal J. Figurski, PhD HUP, Pathology & Laboratory Medicine Biomarker Research Laboratory 3400 Spruce St. 7 Maloney S Philadelphia, PA 19104 tel. (215) 662-3413
Plot the data. You're clearly overfitting. (If you don't know what this means or why it causes the problems you see, try a statistical help list or consult your local statistician). -- Bert On Wed, May 2, 2012 at 12:32 PM, Michal Figurski <figurski at mail.med.upenn.edu> wrote:> Dear R-Helpers, > > I'm working with immunoassay data and 5PL logistic model. I wanted to > experiment with different forms of weighting and parameter selection, which > is not possible in instrument software, so I turned to R. > > I am using R 2.14.2 under Win7 64bit, and the 'nls' library to fit the model > - I started with the same model and weighting type (1/y) as in the > instrument to see if I'll get similar results. However, in some instances I > don't get any results - just errors. > > Here is an example calibration data, representative of my experiment. > Instrument soft had no problem fitting it: > x <- structure(list(SPL = structure(c(1L, 1L, 2L, 2L, 3L, 3L, 4L, > 4L, 5L, 5L, 6L, 6L, 7L, 7L), .Label = c("St1", "St2", "St3", > "St4", "St5", "St6", "St7"), class = "factor"), MFI = c(10755.5, > 9839, 5142.5, 4857, 1510.5, 1505, 502.5, 451, 215, 195.5, 58, > 57, 15, 15), nom = c(206, 206, 125, 125, 68, 68, 38, 38, 24, > 24, 13, 13, 6.5, 6.5), weights = c(0.0013946353028683, 0.00152454517735542, > 0.00291686922702965, 0.00308832612723904, 0.0099304865938431, > 0.00996677740863787, 0.0298507462686567, 0.0332594235033259, > 0.0697674418604651, 0.0767263427109974, 0.258620689655172, > 0.263157894736842, > 1, 1)), .Names = c("SPL", "MFI", "nom", "weights"), row.names = c(NA, > -14L), class = "data.frame") > > And here is the nls fit: > fit <- nls(MFI~a + b/((1+(nom/c)^d)^f), data=x, weights=x$weights, > start=c(a=100, b=10000, c=100, d=-1, f=1)) > > I've tried every possible combination of starting values, including the > values fitted by the instrument soft - to no avail. I've probably seen all > possible error messages from 'nls' trying to fit this. > > If anyone has an idea why it's not working - let me know. > > Best regards, > > -- > Michal J. Figurski, PhD > HUP, Pathology & Laboratory Medicine > Biomarker Research Laboratory > 3400 Spruce St. 7 Maloney S > Philadelphia, PA 19104 > tel. (215) 662-3413 > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.-- Bert Gunter Genentech Nonclinical Biostatistics Internal Contact Info: Phone: 467-7374 Website: http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm
Gabor Grothendieck
2012-May-03 18:32 UTC
[R] Problem with 'nls' fitting logistic model (5PL)
On Wed, May 2, 2012 at 3:32 PM, Michal Figurski <figurski at mail.med.upenn.edu> wrote:> Dear R-Helpers, > > I'm working with immunoassay data and 5PL logistic model. I wanted to > experiment with different forms of weighting and parameter selection, which > is not possible in instrument software, so I turned to R. > > I am using R 2.14.2 under Win7 64bit, and the 'nls' library to fit the model > - I started with the same model and weighting type (1/y) as in the > instrument to see if I'll get similar results. However, in some instances I > don't get any results - just errors. > > Here is an example calibration data, representative of my experiment. > Instrument soft had no problem fitting it: > x <- structure(list(SPL = structure(c(1L, 1L, 2L, 2L, 3L, 3L, 4L, > 4L, 5L, 5L, 6L, 6L, 7L, 7L), .Label = c("St1", "St2", "St3", > "St4", "St5", "St6", "St7"), class = "factor"), MFI = c(10755.5, > 9839, 5142.5, 4857, 1510.5, 1505, 502.5, 451, 215, 195.5, 58, > 57, 15, 15), nom = c(206, 206, 125, 125, 68, 68, 38, 38, 24, > 24, 13, 13, 6.5, 6.5), weights = c(0.0013946353028683, 0.00152454517735542, > 0.00291686922702965, 0.00308832612723904, 0.0099304865938431, > 0.00996677740863787, 0.0298507462686567, 0.0332594235033259, > 0.0697674418604651, 0.0767263427109974, 0.258620689655172, > 0.263157894736842, > 1, 1)), .Names = c("SPL", "MFI", "nom", "weights"), row.names = c(NA, > -14L), class = "data.frame") > > And here is the nls fit: > fit <- nls(MFI~a + b/((1+(nom/c)^d)^f), data=x, weights=x$weights, > start=c(a=100, b=10000, c=100, d=-1, f=1)) >This looks quite linear to me: fo <- log(MFI) ~ log(nom) plot(fo, x) abline(lm(fo, x)) Try using that as the basis for an alternate model. -- Statistics & Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.com
Reasonably Related Threads
- How to estimate the residual SD for each sample separately in mixed-effects model?
- Estimating correlation in multiple measures data
- Problem comparing hazard ratios
- Beginner's question: number formatting
- Problem with plotting survival predictions from cph model