I'm attempting to calculate a regression in R that I normally use Prism for, because the formula isn't pretty by any means.
Prism presents the formula (which is in the Prism equation library as Heterologous competition with depletion, if anyone is curious) in these segments: KdCPM = KdnM*SpAct*Vol*1000 R=NS+1 S=(1+10^(X-LogKi))*KdCPM+Hot a=-1*R b=R*S+NS*Hot+BMax c = -1*Hot*(S*MS+BMax) Y = (-1*b+sqrt(b*b-4*a*c))/(2*a) I'm only trying to solve for NS, LogKi, and BMax. I have everything else (KdnM, SpAct, Vol, Hot). I would use the simple formula at the bottom and then backsolve for the terms I'm looking for, but the simple formula at the bottom takes out the X term, which is contained within S, which it itself contained in both b and c. So I tried to substitute all the terms back into Y and got the following formula<-as.formula("Y ~ (-1*(((NS+1)*((1+10^(X-LogKi))*(KdnM*SpAct*Vol*1000)+Hot))+NS*Hot+BMax)+sqrt((((NS+1)*((1+10^(X-LogKi))*(KdnM*SpAct*Vol*1000)+Hot))+NS*Hot+BMax)*(((NS+1)*((1+10^(X-LogKi))*(KdnM*SpAct*Vol*1000)+Hot))+NS*Hot+BMax)-4*(-1*(NS+1))*(-1*Hot*(((1+10^(X-LogKi))*(KdnM*SpAct*Vol*1000)+Hot)*NS+BMax))))/(2*-1*(NS+1))") But trying to use that formula gives me the single gradient message, which I wasn't entirely surprised by. fit<-nls(formula=formula,data=data,start=list(NS=.01,LogKi=-7,BMax=33000)) Error in nls(formula = formula, data = all_no_outliers, start = list(NS = 0.01, : singular gradient I've never worked with a formula this complicated in R. Is it even possible to do something like this? Any ideas or points in the right direction would be greatly appreciated. Thanks, Jared [[alternative HTML version deleted]] ______________________________________________ R-help@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.