Dear all,
Has anyone written a self-starting power law function of the form
mypower=function(x,a,b,c){a+b*x^c}
?
Or is there a nonlinear regression package containing more selfStart() functions
than nlme?
Thank you very much for your help!
Best wishes
Christoph
[running R 3.0.1 on Windows 7 32-Bit]
Dear all,
I have just written the self-starting power law function myself. Here it is:
##
# Self-starting power law function written by C. Scherber
powermodel=function(x,a,b,c)
{a+b*x^c}
powermodelInit=function(mCall,LHS,data){
xy=sortedXyData(mCall[["x"]],LHS,data)
lmFit1=lm(xy[,"y"]~1) #for "intercept", a
lmFit2=lm(log(xy[,"y"])~log(xy[,"x"])) #for b and c
coefs1=coef(lmFit1)
coefs2=coef(lmFit2)
a=coefs1
b=exp(coefs2[1])
c=coefs2[2]
value=c(a,b,c)
names(value)=mCall[c("a","b","c")]
value
}
SSpower=selfStart(powermodel,powermodelInit,c("a","b","c"))
##
# make sure that x and y are positive when using the function.
Best wishes,
Christoph
Hi Christoph! Actually I had this doubt and thanks for the help! Although i have kind of a problem: while you just have one variable (x) i have three and respective interactions (let's say x1, x2 and x3 where x2 and x3 are categorical variables) the self-construct is still applicable? Best regards, Tiago Henriques -- View this message in context: http://r.789695.n4.nabble.com/Self-starting-nonlinear-power-law-function-tp4681626p4712967.html Sent from the R help mailing list archive at Nabble.com.