Hi, I am completely new to R and I feel kind of lost. Although I can accomplish most of the basic taks, I am very confused when I am trying to do the following: I have multiple sets of 2D data that are coming from distributions of the form: y = A(x-C)^B (Eq.1) I am trying to estimate for each set the best values of A, B, and C so that Eq.1 will be the best fit for the data. I guess that it should be easy to do, but I lack the experience :( I would appreciate any help on this. Thanks, Panagiotis -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
"Panagiotis G. Ipeirotis" <pirot at cs.columbia.edu> writes:> Hi, > > I am completely new to R and I feel kind of lost. > Although I can accomplish most of the basic taks, > I am very confused when I am trying to do the > following: > > I have multiple sets of 2D data that are coming from > distributions of the form:^^^^^^^^^^^^^ relations? functions?> y = A(x-C)^B (Eq.1) > > I am trying to estimate for each set the best values > of A, B, and C so that Eq.1 will be the best fit for > the data. I guess that it should be easy to do, but > I lack the experience :( > > I would appreciate any help on this.Sounds like nonlinear least squares might be used. Try library(nls) ?nls and have a look at the examples. -- O__ ---- Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
> I have multiple sets of 2D data that are coming from > distributions of the form: > > y = A(x-C)^B (Eq.1) > > I am trying to estimate for each set the best values > of A, B, and C so that Eq.1 will be the best fit for > the data. I guess that it should be easy to do, but > I lack the experience :(Do this: library(nls) ?nls Here is an example x<-3:13 y<-2*(x-3)^1.5 #fake perfect data fit<-nls(y~a*(x-b)^c,start=list(a=2,b=3,c=1.5)) This gives: Error in numericDeriv(form[[3]], names(ind), env) : Missing value or an Infinity produced when evaluating the model Maybe others here can say what is wrong. I personally tend to use nlm() and minimize the sum of squared errors... Once it works do summary(fit) to see the fit results. Bill -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Bill Simpson wrote:> >>I have multiple sets of 2D data that are coming from >>distributions of the form: >> >>y = A(x-C)^B (Eq.1) >> >>I am trying to estimate for each set the best values >>of A, B, and C so that Eq.1 will be the best fit for >>the data. I guess that it should be easy to do, but >>I lack the experience :( >> > Do this: > library(nls) > ?nls > Here is an example > x<-3:13 > y<-2*(x-3)^1.5 #fake perfect data > fit<-nls(y~a*(x-b)^c,start=list(a=2,b=3,c=1.5)) > > This gives: > Error in numericDeriv(form[[3]], names(ind), env) : > Missing value or an Infinity produced when evaluating the model > Maybe others here can say what is wrong. > > I personally tend to use nlm() and minimize the sum of squared errors... > > Once it works do summary(fit) to see the fit results. > > Bill > > -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- > r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html > Send "info", "help", or "[un]subscribe" > (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch > _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._ >-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._