From: Bill Shipley <bill.shipley_at_usherbrooke.ca>

Date: Sat 17 Jul 2004 - 03:49:35 EST

R-help@stat.math.ethz.ch mailing list

https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Sat Jul 17 04:03:13 2004

Date: Sat 17 Jul 2004 - 03:49:35 EST

Earlier, I posted a question concerning the syntax of nls() when the
nonlinear function within the call is specified outside of nls().
Sundar showed me how to do this. Now I have a slightly more complex
problem that is analogous to a broken-stick regression but in a
non-linear context.

I want my data to be fit to a non-rectangular hyperbola if the value of the independent variable (I) is less than some value (“Icut”, to be estimated) and to be fit to a constant value (to be estimated) if the value of the independent variable is greater than or equal to “Icut”. That is, if the value of the independent variable is less than Icut, then fit the non-rectangular hyperbola, otherwise fit a constant.

Here is the function that I wrote. “a” is the non-rectangular hyperbola and “b” is the constant. When I give this to nls() I get an error message stating:

Error in nlsModel(formula, mf, start) : singular gradient matrix at initial parameter estimates

> NRHyperbolic.cut

function (Am,alpha,theta,Rd,I,Icut,const)

{

b<-rep(1e6,length(I))

yes<- (I>=Icut)

vec<-as.numeric(yes)

a<-(1/(2*theta))*(alpha*I+Am-sqrt((alpha*I+Am)^2-4*theta*alpha*I*Am))-Rd

b[yes]<-vec[yes]*rep(const,length(I[yes]))

apply(cbind(a,b),1,min)

}

This is a non-rectangular hyperbola (a)

Bill Shipley

Subject Matter Editor, Ecology

North American Editor, Annals of Botany

Département de biologie, Université de Sherbrooke,

Sherbrooke (Québec) J1K 2R1 CANADA

Bill.Shipley@USherbrooke.ca

<http://callisto.si.usherb.ca:8080/bshipley/> http://callisto.si.usherb.ca:8080/bshipley/

[[alternative HTML version deleted]]

R-help@stat.math.ethz.ch mailing list

https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Sat Jul 17 04:03:13 2004

*
This archive was generated by hypermail 2.1.8
: Wed 03 Nov 2004 - 22:55:03 EST
*