Weber, Sam
2009-Oct-19 13:50 UTC
[R] How to get slope estimates from a four parameter logistic with SSfpl?
Hi, I was hoping to get some advice on how to derive estimates of slopes from four parameter logistic models fit with SSfpl. I fit the model using: model<-nls(temp~SSfpl(time,a,b,c,d)) summary(model) I am interested in the values of the lower and upper asymptotes (parameters a and b), but also in the gradient of the line at the inflection point (c) which I assume tells me my rate of increase when it is steepest (?). However, I cannot work out how to derive a slope estimate. I'm guessing it has something to do with the scaling parameter d but having searched the internet for hours I have not made any progress, and it is probably quite simple. Any help would be hugely appreciated! All the best Sam [[alternative HTML version deleted]]
Peter Ehlers
2009-Oct-19 18:17 UTC
[R] How to get slope estimates from a four parameter logistic with SSfpl?
Weber, Sam wrote:> Hi, > > I was hoping to get some advice on how to derive estimates of slopes from four parameter logistic models fit with SSfpl. > > I fit the model using: > > model<-nls(temp~SSfpl(time,a,b,c,d)) > summary(model) > > I am interested in the values of the lower and upper asymptotes (parameters a and b), but also in the gradient of the line at the inflection point (c) which I assume tells me my rate of increase when it is steepest (?). > > However, I cannot work out how to derive a slope estimate. I'm guessing it has something to do with the scaling parameter d but having searched the internet for hours I have not made any progress, and it is probably quite simple. Any help would be hugely appreciated! >Sam, If I understand you correctly, all you want is the derivative of the fpl wrt the input. You can differentiate the fpl function or you can use the result provided by predict.nls() in the "gradient" attribute. The gradient wrt 'c' is the negative of the slope you want. The maximum slope will occur at time = c. So this should give you the slope: ypred <- predict(model,newdata=data.frame(Time=coef(model)[3])) myslope <- -attr(ypred, "gradient")[,3] -Peter Ehlers> All the best > > Sam > > [[alternative HTML version deleted]] > > ______________________________________________ > 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. > >
Prof. John C Nash
2009-Oct-20 12:27 UTC
[R] How to get slope estimates from a four parameter logistic with SSfpl?
Is the following helpful? pdd<-deriv(~a+(b-a)/(1+exp((c-t)/d)),"d") > pdd expression({ .expr1 <- b - a .expr2 <- c - t .expr4 <- exp(.expr2/d) .expr5 <- 1 + .expr4 .value <- a + .expr1/.expr5 .grad <- array(0, c(length(.value), 1L), list(NULL, c("d"))) .grad[, "d"] <- .expr1 * (.expr4 * (.expr2/d^2))/.expr5^2 attr(.value, "gradient") <- .grad .value }) Or perhaps you want it with respect to "t"? JN> Message: 46 > Date: Mon, 19 Oct 2009 14:50:15 +0100 > From: "Weber, Sam" <Sam.Weber at exeter.ac.uk> > Subject: [R] How to get slope estimates from a four parameter logistic > with SSfpl? > To: "r-help at R-project.org" <r-help at r-project.org> > Message-ID: > <5BB78285B60F9B4DB2C6A4DA8F3E788C12C64B3803 at EXCHMBS04.isad.isadroot.ex.ac.uk> > > Content-Type: text/plain > > Hi, > > I was hoping to get some advice on how to derive estimates of slopes from four parameter logistic models fit with SSfpl. > > I fit the model using: > > model<-nls(temp~SSfpl(time,a,b,c,d)) > summary(model) > > I am interested in the values of the lower and upper asymptotes (parameters a and b), but also in the gradient of the line at the inflection point (c) which I assume tells me my rate of increase when it is steepest (?). > > However, I cannot work out how to derive a slope estimate. I'm guessing it has something to do with the scaling parameter d but having searched the internet for hours I have not made any progress, and it is probably quite simple. Any help would be hugely appreciated! > > All the best > > Sam